Subject: bug#65891: 29.0.91; Could the error msg be better for this?

From: Drew Adams <[email-masked]>
Date: Tue, 12 Sep 2023 17:11:58 +0000

> > I'm guessing that it's flagged as a "file mode specification" error
> > because it's from a mode hook?
> 
> It comes from processing auto-mode-alist, see normal-mode:
> 
>     (with-demoted-errors "File mode specification error: %s"
>       (set-auto-mode))
> 
> > But major modes are not necessarily about file buffers.
> 
> auto-mode-alist is only about matching file names to modes, so the error
> message looks fitting.

Fair enough, I guess.  But I still have the question
of whether we can do better here.

Also, I think `C-x b foo' followed by `M-x org-mode'
behaves the same, though no file buffer is involved.

A mode hook doesn't have any necessary relation to any
file or to `auto-mode-alist'.  It may be that Emacs
has chosen to relate the two in this way, as a kind of
shortcut, but there's no necessary connection, right?