Re: c-ts-mode: How to set indent-style in dir-locals

Stefan Monnier via Users list for the GNU Emacs text editor <[email protected]> Tue, 19 May 2026 16:54:40 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> Should not the solution be that (one day) Emacs will process
> ‘.dir-locals.el’ files differently than it does now so that
> variables and user options are set appropriately and
> transparently so that users can simply write the expressions
> using the same syntax for both?  That is, the following
> expression would set the user option
> ‘c-ts-mode-indent-style’:
>
>  ((c-mode . ((c-ts-mode-indent-style . bsd)))))

Yes, that would make a lot of sense.
I suggest you `M-x report-emacs-bug`.

Note that this requires `setopt-local` (which didn't exist before
Emacs-31), so it's no wonder that we don't do that yet.

Also it may have some security implications (tho there's a good chance
it's nothing new) and it may also have consequences for the order in
which file/dir-local vars are set: assuming X1≠X2, we know that

   (setq-local X1 V1) (setq-local X2 V2)
   ==
   (setq-local X2 V2) (setq-local X1 V1)

so it doesn't matter in which order we set them.  But it's not as
obvious that `setopt-local` will always satisfy this constraint.


=== Stefan