GNU bug report logs - #75961
set-auto-mode--apply-alist

Previous Next

Package: emacs;

Reported by: nat chapman <nat.chapman <at> proton.me>

Date: Fri, 31 Jan 2025 07:59:02 UTC

Severity: normal

To reply to this bug, email your comments to 75961 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75961; Package emacs. (Fri, 31 Jan 2025 07:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to nat chapman <nat.chapman <at> proton.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 31 Jan 2025 07:59:02 GMT) Full text and rfc822 format available.

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

From: nat chapman <nat.chapman <at> proton.me>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: set-auto-mode--apply-alist
Date: Fri, 31 Jan 2025 06:24:02 +0000
[Message part 1 (text/plain, inline)]
On https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html, the manual says: "If the element has the form (regexp mode-function flag) and flag is non-nil, then after calling mode-function (if it is non-nil), Emacs discards the suffix that matched regexp and searches the list again for another match. This “recursive extension stripping” is used for files which have multiple extensions, and the “outer” extension hides the “inner” one that actually specifies the right mode. For example, backup files and GPG-encrypted files with .gpg extension use this feature."

My understanding of this paragraph is that the outside mode-function should be called, and then subsequent mode-functions should be called after. Currently, only the inner-most matched suffix has its mode-function called.

I believe this was changed in this commit: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ad5faa424a5d2f0d67265906d21f7af98220df26

It looks like the (when mode (set-auto-mode-0 ...)) was moved from inside the (while name ...) to outside when the section was pulled into its own function. It's been four and a half years, so maybe it doesn't matter anymore, but if that's the case the manual should be updated; it would have saved me a couple hours of difficulty.

nat
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75961; Package emacs. (Fri, 31 Jan 2025 08:17:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: nat chapman <nat.chapman <at> proton.me>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, Tom Tromey <tom <at> tromey.com>
Cc: 75961 <at> debbugs.gnu.org
Subject: Re: bug#75961: set-auto-mode--apply-alist
Date: Fri, 31 Jan 2025 10:16:03 +0200
> Date: Fri, 31 Jan 2025 06:24:02 +0000
> From:  nat chapman via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> On https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html, the manual says:
> "If the element has the form (regexp mode-function flag) and flag is non-nil, then after calling
> mode-function (if it is non-nil), Emacs discards the suffix that matched regexp and searches the list again
> for another match. This “recursive extension stripping” is used for files which have multiple extensions, and
> the “outer” extension hides the “inner” one that actually specifies the right mode. For example, backup files
> and GPG-encrypted files with .gpg extension use this feature." 
> 
> My understanding of this paragraph is that the outside mode-function should be called, and then
> subsequent mode-functions should be called after. Currently, only the inner-most matched suffix has its
> mode-function called.
> 
> I believe this was changed in this commit:
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ad5faa424a5d2f0d67265906d21f7af98220df26
> 
> It looks like the (when mode (set-auto-mode-0 ...)) was moved from inside the (while name ...) to outside
> when the section was pulled into its own function. It's been four and a half years, so maybe it doesn't matter
> anymore, but if that's the case the manual should be updated; it would have saved me a couple hours of
> difficulty.

Thanks.

Do you have a recipe for showing some failure, preferably starting
from "emacs -Q", to behave according to the documentation, due to the
above change?  If so, can you please show such a recipe?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75961; Package emacs. (Fri, 31 Jan 2025 17:25:04 GMT) Full text and rfc822 format available.

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

From: nat chapman <nat.chapman <at> proton.me>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 75961 <at> debbugs.gnu.org, Tom Tromey <tom <at> tromey.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#75961: set-auto-mode--apply-alist
Date: Fri, 31 Jan 2025 15:42:32 +0000
On Friday, January 31st, 2025 at 02:16, Eli Zaretskii <eliz <at> gnu.org> wrote:

> 
> 
> > Date: Fri, 31 Jan 2025 06:24:02 +0000
> 
> > From: nat chapman via "Bug reports for GNU Emacs,
> > the Swiss army knife of text editors" bug-gnu-emacs <at> gnu.org
> > 
> > On https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html, the manual says:
> > "If the element has the form (regexp mode-function flag) and flag is non-nil, then after calling
> > mode-function (if it is non-nil), Emacs discards the suffix that matched regexp and searches the list again
> > for another match. This “recursive extension stripping” is used for files which have multiple extensions, and
> > the “outer” extension hides the “inner” one that actually specifies the right mode. For example, backup files
> > and GPG-encrypted files with .gpg extension use this feature."
> > 
> > My understanding of this paragraph is that the outside mode-function should be called, and then
> > subsequent mode-functions should be called after. Currently, only the inner-most matched suffix has its
> > mode-function called.
> > 
> > I believe this was changed in this commit:
> > https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ad5faa424a5d2f0d67265906d21f7af98220df26
> > 
> > It looks like the (when mode (set-auto-mode-0 ...)) was moved from inside the (while name ...) to outside
> > when the section was pulled into its own function. It's been four and a half years, so maybe it doesn't matter
> > anymore, but if that's the case the manual should be updated; it would have saved me a couple hours of
> > difficulty.
> 
> 
> Thanks.
> 
> Do you have a recipe for showing some failure, preferably starting
> from "emacs -Q", to behave according to the documentation, due to the
> above change? If so, can you please show such a recipe?

emacs -Q --eval '(progn (define-derived-mode test-mode fundamental-mode "TEST" (message "Test mode called")) (add-to-list (quote auto-mode-alist) (quote ("\\.test$" test-mode t))))' file.html.test file.test

Buffer visiting file.html.test is in mhtml-mode, buffer visiting file.test is in fundamental mode, no message is emitted. 

Using edebug to step through set-auto-mode--apply alist, (regexp mode-function t) matches correctly but the mode-function is never called.





This bug report was last modified 1 day ago.

Previous Next


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