GNU bug report logs - #58506
Use ".dir-locals.eld" and ".dir-locals-2.eld" when they exist

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Fri, 14 Oct 2022 09:23:01 UTC

Severity: wishlist

Full log


Message #8 received at 58506 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 58506 <at> debbugs.gnu.org, philipk <at> posteo.net, monnier <at> iro.umontreal.ca,
 juri <at> linkov.net
Subject: Re: bug#58506: Use ".dir-locals.eld" and ".dir-locals-2.eld" when they
 exist
Date: Fri, 14 Oct 2022 13:38:27 +0300
> Cc: Juri Linkov <juri <at> linkov.net>, Philip Kaludercic <philipk <at> posteo.net>,
>  Stefan Monnier <monnier <at> iro.umontreal.ca>
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Fri, 14 Oct 2022 11:22:23 +0200
> 
> Severity: wishlist
> 
> [Spun out from Bug#58486.]
> 
> Juri Linkov <juri <at> linkov.net> writes:
> 
> > It's already handled by auto-mode-alist:
> >
> >   (defvar auto-mode-alist
> >        ...
> >        ;; .dir-locals.el is not really Elisp.  Could use the
> >        ;; `dir-locals-file' constant if it weren't defined below.
> >        ("\\.dir-locals\\(?:-2\\)?\\.el\\'" . lisp-data-mode)
> 
> It's nice if we can use the "*.eld" extension for files that are not
> supposed to be executed.  But it's hard to just change that outright, as
> a file ".dir-locals.eld" won't be used on old versions of Emacs.
> 
> So how about doing something like the below, as a future compatibility
> patch?  Then, in some undefined future version, we can consider creating
> ".dir-locals.eld" files by default, instead.
> 
> diff --git a/lisp/files.el b/lisp/files.el
> index 94d110f0b7..bfd1e5e8e1 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -4403,11 +4403,14 @@ dir-locals--all-files
>                                          (dosified-file-name dir-locals-file)
>                                        dir-locals-file)
>                                      directory))
> -           (file-2 (when (string-match "\\.el\\'" file-1)
> +           (is-el (string-match (rx ".el" eos) file-1))
> +           (file-2 (when is-el
>                       (replace-match "-2.el" t nil file-1)))
>            (out nil))
>        ;; The order here is important.
> -      (dolist (f (list file-2 file-1))
> +      ;; Support *.eld files, too.
> +      (dolist (f (list (and is-el (concat file-2 "d")) file-2
> +                       (and is-el (concat file-1 "d")) file-1))

This conses 2 strings, which is a pity, because this code is called a
lot.  Can this be done without so much consing for such a simple job?




This bug report was last modified 2 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.