From: Shynur Xie <one.last.kiss@outlook.com>
To: 64415@debbugs.gnu.org
Subject: bug#64415: [PATCH] Use first match in dir-local `auto-mode-alist'
Date: Sun, 2 Jul 2023 10:29:13 +0000 [thread overview]
Message-ID: <PH0PR11MB747042BADD45AB375A9B4BBAD728A@PH0PR11MB7470.namprd11.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 298 bytes --]
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
[-- Attachment #2: 0001-Use-first-match-in-dir-local-auto-mode-alist.patch --]
[-- Type: application/octet-stream, Size: 1227 bytes --]
From 6cb2063a807b7dc2c3da9378db1c134b2e82a0a3 Mon Sep 17 00:00:00 2001
From: Shynur <one.last.kiss@outlook.com>
Date: Sun, 2 Jul 2023 18:15:02 +0800
Subject: [PATCH] Use first match in dir-local `auto-mode-alist'
* 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)
--
2.39.1
next reply other threads:[~2023-07-02 10:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 10:29 Shynur Xie [this message]
2023-07-02 10:58 ` bug#64415: [PATCH] Use first match in dir-local `auto-mode-alist' Eli Zaretskii
2023-07-02 11:16 ` Shynur Xie
2023-07-02 11:29 ` Shynur Xie
2024-06-08 23:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PH0PR11MB747042BADD45AB375A9B4BBAD728A@PH0PR11MB7470.namprd11.prod.outlook.com \
--to=one.last.kiss@outlook.com \
--cc=64415@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).