GNU bug report logs -
#64415
[PATCH] Use first match in dir-local `auto-mode-alist'
Previous Next
To reply to this bug, email your comments to 64415 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#64415
; Package
emacs
.
(Sun, 02 Jul 2023 10:35:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Shynur Xie <one.last.kiss <at> outlook.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 02 Jul 2023 10:35:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
lispref says var `auto-mode-alist' uses first match, so pseudo
var `auto-mode-alist' in _dir-locals.el should also do that, for
consistency.
Here is a problem caused by the original behavior when Emacs handles
_dir-locals file: <https://emacs.stackexchange.com/questions/77841>.
--
shynur
[0001-Use-first-match-in-dir-local-auto-mode-alist.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#64415
; Package
emacs
.
(Sun, 02 Jul 2023 10:59:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 64415 <at> debbugs.gnu.org (full text, mbox):
> From: Shynur Xie <one.last.kiss <at> outlook.com>
> Date: Sun, 2 Jul 2023 10:29:13 +0000
> msip_labels:
>
> lispref says var `auto-mode-alist' uses first match, so pseudo
> var `auto-mode-alist' in _dir-locals.el should also do that, for
> consistency.
Isn't that an incompatible change in long-time behavior? Your
stack-exchange correspondent might be pleased, but someone else, who
relies on the current behavior, will not be.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#64415
; Package
emacs
.
(Sun, 02 Jul 2023 11:17:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 64415 <at> debbugs.gnu.org (full text, mbox):
GNU Emacs Manual, 49.2.5 Per-Directory Local Variables:
> The special key auto-mode-alist in a .dir-locals.el ... works much
> like the variable auto-mode-alist (see Choosing File Modes).
GNU Emacs Lisp Reference Manual, 24.2.2 How Emacs Chooses a Major
Mode:
> If auto-mode-alist has more than one element whose regexp matches
> the file name, Emacs will use the first match.
___
> Eli> Isn't that an incompatible change in long-time behavior?
That is a bug fix. What do you mean by ‘long-time behavior’? To be
honest, it is a long-time bug IMO.
> Eli> someone else, who relies on the current behavior, will not be.
Yes, so just let them know that this behavior has changed in NEWS.
They just need to reverse their original alist, is that very
difficult? Not to mention that the original behavior was not
guaranteed at all.
You can of course refuse that patch, and the inconsistency between
‘auto-mode-alist’ and dir-local ‘auto-mode-alist’ will last forever.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#64415
; Package
emacs
.
(Sun, 02 Jul 2023 11:30:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 64415 <at> debbugs.gnu.org (full text, mbox):
I agree that compatibility should be considered, but this dir-local
var was introduced since 28, it’s not too late to change it.
The reverse order is so contrary to perception.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#64415
; Package
emacs
.
(Sat, 08 Jun 2024 23:48:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 64415 <at> debbugs.gnu.org (full text, mbox):
> * lisp/files.el (set-auto-mode): Reverse the reversed alist.
> ---
> lisp/files.el | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/files.el b/lisp/files.el
> index 148f47cbc97..fc3b47082ea 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -3396,8 +3396,9 @@ we don't actually set it to the same mode the buffer already has."
> (unless done
> (with-demoted-errors "Directory-local variables error: %s"
> ;; Note this is a no-op if enable-local-variables is nil.
> - (let* ((mode-alist (cdr (hack-dir-local--get-variables
> - (lambda (key) (eq key 'auto-mode-alist))))))
> + (let* ((mode-alist (reverse (cdr (hack-dir-local--get-variables
> + (lambda (key)
> + (eq key 'auto-mode-alist)))))))
> (setq done (set-auto-mode--apply-alist mode-alist
> keep-mode-if-same t)))))
> (and (not done)
AFAICT the reversal happens within `dir-locals-collect-mode-variables`.
I think this is a bug in `hack-dir-local--get-variables`: it should return the
vars in the same order as found in the file.
Stefan
This bug report was last modified 1 year and 6 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.