GNU bug report logs - #64415
[PATCH] Use first match in dir-local `auto-mode-alist'

Previous Next

Package: emacs;

Reported by: Shynur Xie <one.last.kiss <at> outlook.com>

Date: Sun, 2 Jul 2023 10:35:01 UTC

Severity: normal

Tags: patch

Full log


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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Shynur Xie <one.last.kiss <at> outlook.com>
Cc: 64415 <at> debbugs.gnu.org
Subject: Re: bug#64415: [PATCH] Use first match in dir-local `auto-mode-alist'
Date: Sat, 08 Jun 2024 19:38:09 -0400
> * 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.