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

From: Stefan Monnier <[email-masked]>
Date: Sat, 15 Oct 2022 11:19:09 -0400

> I don't know what the new syntax would look like -- the current syntax
> is, er, very implementation-friendly and user-hostile.  I.e., it's easy
> for Emacs to parse, and difficult for people to write:

As Philip points out, "hard to write" is circumvented by
`add-dir-local-variable`.
The more serious problem IMO is that it's hard for humans to read.

[ Also, while it's not ELisp code, I think it's code more than it's
  data.  And indeed this discussion is about making it more like
  code.  ]

> ((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))))

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)))

> Perhaps a more imperative style would be nice.  Err...  something
> like...
>
> (in-mode c-mode
>   (set c-file-style "GNU")
>   (set-early treesit-thing t)
>   (add-to-list odd-list 3)
>   (minor-mode indent-tabs-mode)
>   (minor-mode blink-parentheses-mode))

I fully agree with Philip here that it looks too much like ELisp.
We should either make it use a proper subset of ELisp, or make it use
a syntax that's sufficiently different.

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))

[ I dropped the "set-early" because I still haven't heard any good
  reason why we'd need that nor what that would really mean (e.g. how it
  could be implemented).  ]

> `safep' would have to be a bit adjusted -- a `safep' for `odd-list'
> would be (cl-every #'oddp) etc.

Sorry, I don't know what problem you're alluding to.
Why would `safep` need to be adjusted?

        Stefan