[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61211: 28.2; Feature request; facility for dispatch type major mode
From: |
Ikumi Keita |
Subject: |
bug#61211: 28.2; Feature request; facility for dispatch type major mode |
Date: |
Thu, 11 May 2023 21:23:26 +0900 |
>>>>> Stefan Monnier <monnier@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