Subject: bug#61211: 28.2; Feature request; facility for dispatch type major mode

From: Yuan Fu <[email-masked]>
Date: Thu, 9 Feb 2023 17:29:26 -0800

Ikumi Keita <[email-masked]> writes:

> 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)
>   ...)
> because it doesn't respond to directory local variable entry of the form
> ((japanese-latex-mode
>   ...))
> in that case.
>
> So I hope emacs to have facility to handle such superficial major modes
> in a clean way.
>
> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine

Another use-case is for tree-sitter modes: we want to dispatch to
tree-sitter/non-tree-sitter major modes automatically.

Yuan