Subject: bug#75961: closed (Re: bug#75961: set-auto-mode--apply-alist)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 16 Feb 2025 16:55:01 +0000

Your bug report

#75961: set-auto-mode--apply-alist

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
75961: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75961
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#75961: set-auto-mode--apply-alist
From: Stefan Monnier <[email-masked]>
To: nat chapman <[email-masked]>
Cc: Eli Zaretskii <[email-masked]>, [email-masked], [email-masked]
Date: Sun, 16 Feb 2025 11:54:36 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> I'm not an expert, but the supplied test doesn't appear to check that
> text-mode is actually called when the mode falls through.  I suspect
> that test would succeed even if you didn't make any change to
> set-auto-mode--apply alist,

The test does fail in Emacs-30 because `foo.text` is left in
`fundamental-mode` there, so it is useful.

But you're right that in the case of `foo.html.text` I did not bother to
check if `text-mode` was called before calling the html mode.
I pushed the patch with an improved test which fixes that weakness, thanks.

BTW, I pushed this to `master`, but as mentioned the bug is present in
Emacs-30 as well.  Not sure it's worth taking the risk in `emacs-30`.

        Stefan

Subject: set-auto-mode--apply-alist
From: nat chapman <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Fri, 31 Jan 2025 06:24:02 +0000
List-Id: <debbugs-submit.debbugs.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.

nat