Subject: Re: bug#58506: Use ".dir-locals.eld" and ".dir-locals-2.eld" when they exist

From: Juri Linkov <[email-masked]>
Date: Tue, 18 Oct 2022 10:28:27 +0300

> I think the above is better written:
>
>     ((nil
>       (tab-width . 8)
>       (sentence-end-double-space . t)
>       (fill-column . 70)
>       (emacs-lisp-docstring-fill-column . 65)
>       (vc-git-annotate-switches . "-w")
>       (bug-reference-url-format . "https://debbugs.gnu.org/%s")
>       (diff-add-log-use-relative-names . t))
>      (c-mode
>       (c-file-style . "GNU")
>       (c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" "UNINIT" "CALLBACK" "ALIGN_STACK"))
>       (electric-quote-comment . nil)
>       (electric-quote-string . nil)
>       (indent-tabs-mode . t)
>       (mode . bug-reference-prog)))

So the dotted pair notation should be avoided only at the first level.

Then what about making it closer to the syntax of display-buffer-alist rules
where CONDITION is passed to buffer-match-p that can match not only major-mode,
but also a regular expression of a buffer name.  And display-buffer-alist's
ACTION alist already looks like dir-locals's alist.

> Maybe something like:
>
>     (c-mode
>      (:set c-file-style "GNU")
>      (:set treesit-thing t)
>      (:set odd-list (cons 3 odd-list))
>      (:minor-mode indent-tabs-mode -1) ;; Disable
>      (:minor-mode blink-parentheses-mode))

The drawback of the current syntax is that `mode` and `eval`
are used like variables, but really are keywords.  Using the
keyword syntax `:` will help to resolve this ambiguity.

Then for backwards-compatibility dir-locals could support both
the current dotted pairs and new :keyword syntax, where unrecognized
keywords are simply ignored in older versions.

Also should file-local variables support the same :keyword syntax?