GNU bug report logs - #61211
28.2; Feature request; facility for dispatch type major mode

Previous Next

Package: emacs;

Reported by: Ikumi Keita <ikumi <at> ikumi.que.jp>

Date: Wed, 1 Feb 2023 12:29:02 UTC

Severity: wishlist

Found in version 28.2

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 61211 <at> debbugs.gnu.org
Subject: bug#61211: 28.2; Feature request; facility for dispatch type major mode
Date: Tue, 09 May 2023 11:21:20 -0400
> I'd like to discuss dispatch functions or "superficial" major modes.
> AUCTeX has the following major mode functions:
> context-en-mode, context-nl-mode, japanese-latex-mode, japanese-plain-tex-mode
> They only do language-specific set-ups and turn into context-mode,
> latex-mode or plain-tex-mode eventually. In some aspects, they are
> similar with dispatch functions `tex--guess-mode' and `TeX-tex-mode'
> (AUCTeX) which guess a proper major mode and call it:
> - They can be specified as `mode' tag of file local variable and entry
>   of `auto-mode-alist'.
> - They never hold their own `major-mode' value.
> - When called, they eventually turn into another proper major mode.
> For these reasons, they can be called "superficial" major modes.
>
> Note that it isn't enough to define them like
> (define-derived-mode japanese-latex-mode latex-mode "LaTeX"
>   ...
>   (setq major-mode 'latex-mode)
>   ...)

IOW what are the advantages/disadvantages of using (setq major-mode
'latex-mode) above?

Also, this seems different from the case of dispatch functions like
`tex--guess-mode' and `TeX-tex-mode' since these may end up choosing
`latex-mode` but they're definitely not "child" of `latex-mode`.

[ Similarly for the tree-sitter case mentioned in another message: the
  function that dispatches to TS-vs-nonTS major modes can't be considered
  a child of those two major modes.  ]

> because it doesn't respond to directory local variable entry of the form
> ((japanese-latex-mode
>   ...))
> in that case.

If we make `japanese-latex-mode` a proper child mode, then this problem
disappears, right?

I'm also thinking that maybe `set-auto-mode` should remember the name of
the "mode function" it called so we could consult this (in addition to
the value of `major-mode`) when applying directory-local vars?


        Stefan





This bug report was last modified 2 years and 37 days ago.

Previous Next


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