* bug#61211: 28.2; Feature request; facility for dispatch type major mode
@ 2023-02-01 12:28 Ikumi Keita
2023-02-10 1:29 ` Yuan Fu
2023-05-09 15:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 5+ messages in thread
From: Ikumi Keita @ 2023-02-01 12:28 UTC (permalink / raw)
To: 61211; +Cc: Stefan Monnier
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
In GNU Emacs 28.2 (build 1, x86_64-unknown-freebsd13.1, GTK+ Version 3.24.33, cairo version 1.17.4)
of 2022-09-15 built on freebsd.vmware
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: 13.1-RELEASE-p5
Configured using:
'configure --with-canna --with-canna-includes=/usr/local/canna/include
--with-canna-libraries=/usr/local/canna/lib --without-xim
--disable-largefile --without-modules --with-sound=yes
--with-file-notification=yes CFLAGS=-O3'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBXML2 NOTIFY KQUEUE PDUMPER PNG RSVG SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB
Important settings:
value of $EMACSLOADPATH: /home/keita/elisp:
value of $LANG: ja_JP.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
shell-dirtrack-mode: t
TeX-PDF-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
Load-path shadows:
/home/keita/.emacs.d/elpa/transient-20230124.2013/transient hides /usr/local/share/emacs/28.2/lisp/transient
~/elisp/reftex-parse hides /usr/local/share/emacs/28.2/lisp/textmodes/reftex-parse
/home/keita/.emacs.d/elpa/soap-client-3.2.1/soap-inspect hides /usr/local/share/emacs/28.2/lisp/net/soap-inspect
/home/keita/.emacs.d/elpa/soap-client-3.2.1/soap-client hides /usr/local/share/emacs/28.2/lisp/net/soap-client
Features:
(pp shadow emacsbug mh-thread supercite regi mh-identity mh-letter
mh-comp sendmail reftex-sel reftex-ref reftex-parse preview reftex-dcr
reftex-auc reftex reftex-loaddefs reftex-vars tex-bar toolbar-x noutline
outline tex-mode shell pcomplete font-latex tex-jp latex easy-mmode
latex-flymake flymake-proc flymake project compile comint ansi-color
ring warnings tex-ispell tex-style tex texmathp latexenc mh-search qp
mm-archive smiley mail-extr mh-mime mh-gnus mh-alias multi-prompt crm
mh-show goto-addr thingatpt gnus-cite gnus-art mm-uu mml2015 mm-view
mml-smime smime dig gnus-sum shr svg dom gnus-group gnus-undo gnus-start
gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
gnus-spec gnus-int message dired dired-loaddefs rfc822 mml mml-sec
mm-decode mm-bodies mm-encode gmm-utils mailheader gnus-win gnus-range
gnus nnheader wid-edit mh-seq mh-inc hl-line mh-tool-bar mh-xface
mh-utils mh-folder which-func imenu gnus-util rmail rmail-loaddefs
mail-utils text-property-search mh-scan mh-e mh-compat mailabbrev
mh-buffers mh-loaddefs skeleton misearch multi-isearch conf-mode
mule-util kinsoku cl-extra help-mode parse-time iso8601 time-date
ucs-normalize epa derived epg rfc6068 epg-config url-http url-auth
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw
nsm rmc puny jka-compr twittering-mode advice xml edmacro kmacro
preview-latex tex-site canna-im info package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
japan-util iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind kqueue lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 865676 104494)
(symbols 48 23604 44)
(strings 32 132282 18657)
(string-bytes 1 5868969)
(vectors 16 74186)
(vector-slots 8 1681559 71081)
(floats 8 424 893)
(intervals 56 21817 8038)
(buffers 992 35))
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#61211: 28.2; Feature request; facility for dispatch type major mode
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
1 sibling, 1 reply; 5+ messages in thread
From: Yuan Fu @ 2023-02-10 1:29 UTC (permalink / raw)
To: ikumi; +Cc: monnier, 61211
Ikumi Keita <ikumi@ikumi.que.jp> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#61211: 28.2; Feature request; facility for dispatch type major mode
2023-02-10 1:29 ` Yuan Fu
@ 2023-02-10 5:10 ` Ikumi Keita
0 siblings, 0 replies; 5+ messages in thread
From: Ikumi Keita @ 2023-02-10 5:10 UTC (permalink / raw)
To: Yuan Fu; +Cc: monnier, 61211
>>>>> Yuan Fu <casouri@gmail.com> writes:
> Another use-case is for tree-sitter modes: we want to dispatch to
> tree-sitter/non-tree-sitter major modes automatically.
Yeah, reasonable consideration.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#61211: 28.2; Feature request; facility for dispatch type major mode
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-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
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-09 15:21 UTC (permalink / raw)
To: Ikumi Keita; +Cc: 61211
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#61211: 28.2; Feature request; facility for dispatch type major mode
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
0 siblings, 0 replies; 5+ messages in thread
From: Ikumi Keita @ 2023-05-11 12:23 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 61211
>>>>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-11 12:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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).