From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64415: [PATCH] Use first match in dir-local `auto-mode-alist' Date: Sat, 08 Jun 2024 19:38:09 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26226"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 64415@debbugs.gnu.org To: Shynur Xie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 09 01:48:18 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sG5nF-0006fG-JX for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jun 2024 01:48:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sG5ml-0001Gt-Ou; Sat, 08 Jun 2024 19:47:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sG5mk-0001GR-3C for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 19:47:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sG5mj-0000lB-QB for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 19:47:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sG5mz-000104-Qq for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 19:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jun 2024 23:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64415 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64415-submit@debbugs.gnu.org id=B64415.17178904553763 (code B ref 64415); Sat, 08 Jun 2024 23:48:01 +0000 Original-Received: (at 64415) by debbugs.gnu.org; 8 Jun 2024 23:47:35 +0000 Original-Received: from localhost ([127.0.0.1]:48408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sG5mZ-0000yc-9R for submit@debbugs.gnu.org; Sat, 08 Jun 2024 19:47:35 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sG5mX-0000yA-Id for 64415@debbugs.gnu.org; Sat, 08 Jun 2024 19:47:34 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E731380822; Sat, 8 Jun 2024 19:38:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1717889890; bh=C1j4uwXJs09Jgwja64HICu6Lvje1MTtKN6e3ve1vFfE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ph2QQVo1YueX1LAB78vZNIaO2CrbSWd7g9SfyISYwqF8lRivgllzQo9+YMPKeCMz1 yIsF88QAgtj532pDHR8YwHfxfKe6YBTWd5IFfJi+bT0cnj8F7Sqe7BFScuqjWuA2wR WkwPvChzdnqS7oI/g24fwboYsAmM+1xcGD5ieOfWJU7z+Lt0tkQQHaM/KOa6QRSKRB zZXLmM+2NhMOuijupTy9/xTrpICq1iCgqwP/aeWIWaKhiUJSPCWaibIywKjdul3spo 95T1AS4QWp612zXLt2k8AkYbk8yBMNnXqTPUPzCWzhAjjp4qUasMbnN5O8ok5QbiVZ OuiISHbt4EAiA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D17F1805E0; Sat, 8 Jun 2024 19:38:10 -0400 (EDT) Original-Received: from pastel (unknown [24.140.236.196]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A6445120475; Sat, 8 Jun 2024 19:38:10 -0400 (EDT) In-Reply-To: (Shynur Xie's message of "Sun, 2 Jul 2023 10:29:13 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286898 Archived-At: > * 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