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


Message #17 received at 61211 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 61211 <at> debbugs.gnu.org
Subject: Re: bug#61211: 28.2; Feature request;
 facility for dispatch type major mode
Date: Thu, 11 May 2023 21:23:26 +0900
>>>>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> 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?

The rest of the codes are written without considering japanese-*
variants. For example there are codes like
(if (eq major-mode 'LaTeX-mode) ...)
(if (memq major-mode (nth 4 TeX-command-list)) ...)
(assq major-mode ALIST-WITHOUT-JAPANESE-VARIANTS)

Of course, we can "fix" these codes to cover japanese-* variants like
(if (memq major-mode '(LaTeX-mode japanese-LaTeX-mode) ...))
(let ((mode (if (string-prefix-p (symbol-name major-mode) "japanese-")
                (intern (substring 9 major-mode))
              major-mode)))
   (memq mode (nth 4 TeX-command-list)) ...)
(let ((mode (if (string-prefix-p (symbol-name major-mode) "japanese-")
                (intern (substring 9 major-mode))
              major-mode)))
   (assq mode ALIST-WITHOUT-JAPANESE-VARIANTS))

However, such treatments don't look good to me.

It is true that we could make wrapper function/macro to reduce such
complexity. However, practically all third party packages developed by
non-Japanese wouldn't notice the necesity of such wrapper for the first
place and write simply like
(if (eq major-mode 'LaTeX-mode) ...)
; such codes, incompatible with japanse-LaTeX-mode, will continue to
spawn on ELPA, MELPA, stackexchange etc. (or even in AUCTeX itself after
I cease to participate develop, unless a new Japanese developer joins.)

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

Yes, not the same, only a similarity.

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

Yes, restricting the scope only within the availability of directory
local variables.

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

If that's possible, it will be a solution, I think.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine




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

Previous Next


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