unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65891: 29.0.91; Could the error msg be better for this?
@ 2023-09-12 15:26 Drew Adams
  2023-09-12 15:48 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2023-09-12 15:26 UTC (permalink / raw)
  To: 65891

A user asked on StackOverflow why s?he got an error with this code.
(https://stackoverflow.com/q/77085788/729907)

(add-hook 'org-mode-hook
          #'(lambda () (local-unset-key (kdb "C-j"))))

The problem was the typo: `kdb' instead of `kbd'.

Actually, s?he didn't see the error msg, and was just wondering why
the key `C-j' wasn't getting unset in Org mode.
And the hook function was of course removed after the error was
raised, so the msg was shown only once.

This is the error msg:

 File mode specification error: (void-function kdb)

Could we maybe provide a better error msg here?

I'm guessing that it's flagged as a "file mode specification" error
because it's from a mode hook?  But major modes are not necessarily
about file buffers.  And anyway, "file mode specification" isn't very
clear or helpful, is it?  At least to me it doesn't say anything useful,
so far - but maybe with an explanation it will make sense.

If this is a generic error msg from a hook function that raises an error
then maybe it would be better to just say that a hook function raised an
error, if we can't say which hook function raised an error and we can't
pass along the msg from the error that the hook function raised?

I guess "(void-function kdb)" is the error raised by the hook function
(but it's not really a user-targeted message).  But why introduce the
error with the mysterious (to me) "File specification error"?

In GNU Emacs 29.0.91 (build 2, x86_64-w64-mingw32) of 2023-05-14 built
 on AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Pro (v10.0.2009.19045.3324)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation
 --without-compress-install --with-tree-sitter CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

(NATIVE_COMP present but libgccjit not available)






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#65891: 29.0.91; Could the error msg be better for this?
  2023-09-12 15:26 bug#65891: 29.0.91; Could the error msg be better for this? Drew Adams
@ 2023-09-12 15:48 ` Andreas Schwab
  2023-09-12 17:11   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2023-09-12 15:48 UTC (permalink / raw)
  To: Drew Adams; +Cc: 65891

On Sep 12 2023, Drew Adams wrote:

> 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.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#65891: 29.0.91; Could the error msg be better for this?
  2023-09-12 15:48 ` Andreas Schwab
@ 2023-09-12 17:11   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2023-09-12 17:11 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 65891@debbugs.gnu.org

> > 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?





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-12 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12 15:26 bug#65891: 29.0.91; Could the error msg be better for this? Drew Adams
2023-09-12 15:48 ` Andreas Schwab
2023-09-12 17:11   ` Drew Adams

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).