unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ikumi Keita <ikumi@ikumi.que.jp>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 61211@debbugs.gnu.org
Subject: bug#61211: 28.2; Feature request; facility for dispatch type major mode
Date: Thu, 11 May 2023 21:23:26 +0900	[thread overview]
Message-ID: <95920.1683807806@localhost> (raw)
In-Reply-To: <jwvzg6dr11v.fsf-monnier+emacs@gnu.org>

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





      reply	other threads:[~2023-05-11 12:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 12:28 bug#61211: 28.2; Feature request; facility for dispatch type major mode Ikumi Keita
2023-02-10  1:29 ` Yuan Fu
2023-02-10  5:10   ` Ikumi Keita
2023-05-09 15:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 12:23   ` Ikumi Keita [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95920.1683807806@localhost \
    --to=ikumi@ikumi.que.jp \
    --cc=61211@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).