[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AUCTeX and "builtin latex mode" integration
From: |
Stefan Monnier |
Subject: |
Re: AUCTeX and "builtin latex mode" integration |
Date: |
Thu, 05 Oct 2023 17:33:22 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> (a) The mode names change as follows:
> plain-tex-mode -> plain-TeX-mode
> latex-mode -> LaTeX-mode
> doctex-mode -> docTeX-mode
> context-mode -> ConTeXt-mode
> texinfo-mode -> Texinfo-mode
> ams-tex-mode -> AmSTeX-mode
> japanese-plain-tex-mode -> japanese-plain-TeX-mode
> japanese-latex-mode -> japanese-LaTeX-mode
> context-en-mode DELETED
> context-nl-mode DELETED
> TeX-tex-mode UNCHANGED
> TeX-mode NEW
LGTM.
> (a-2) Now `TeX-add-local-master' adds entry of new mode names such as
> %%% Local Variables:
> %%% mode: LaTeX <-- not `latex'
> %%% End:
I don't like this very much: IMO the `mode:` cookie should really not specify
the "mode" to use but rather describe the file-type (Emacs could/should
aim to support "mime types" kind of names), and then which mode to use
for each file-type is decided based on the user's configuration.
> (b) All new modes (except TeX-tex-mode) are defined by
> `define-derived-mode'. The inheritance relations are:
[...]
> (c) The compatibility with the former mode names with respect to
> function call are retained by redirections or aliases.
No objection here.
> [Incompatibility]
> 1. directory local variables
> Currently, directory local variables are prepared in a entry like
> (latex-mode (reftex-label-alist . (("equation" ?e "eq:%f-" "\\eqref{%s}")
> ("align" ?e "eq:%f-" "\\eqref{%s}")
> ("gather" ?e "eq:%f-" "\\eqref{%s}")))))
> in .dir-locals.el. In this feature branch, mode name is `LaTeX-mode',
> thus this entry is ignored.
>
> The facility of major-mode-remap-list still does not handle this
> situation.
>
> We can announce this fact and ask users to rewrite their
> .dir-locals.el, but that can't be done if the user doesn't have write
> access for that particular .dir-locals.el. (Maybe we can ignore such
> corner cases?)
We should fix this for Emacs-30.
[ And then add some backward compatibility hack (presumably using
an advice for when AUCTeX is used on Emacs<30). ]
Maybe using `major-mode-remap-list` is not the right answer, tho (some
settings may be specific to a particular major mode and may cause
problems for other major modes used for the same file-type; I'm
thinking here of remapping between things like doc-view-mode and
pdf-view-mode, or image-mode and postscript-mode, or
image-mode and C-mode (for XPM files), ...).
We should make the directory-local code pay attention to:
- `derived-mode-p`.
- some additional "pseudo-derived-p" thingy for cases like `LaTeX-mode`
where there isn't a true `derived-mode-p` relation, but the other mode
can be treated as a sort of parent nevertheless. Maybe we should change
`derived-mode-p` so it handles that directly (i.e. offer some way for
a major mode to declare itself as being a descendant of other
modeS in addition to its "real" parent. We could (re)user
`define-child-mode` for that).
Maybe in addition to that, we need to be able to say in `dir-locals.el`
that a setting applies only for exactly this major mode, and not
its derivatives, maybe with a syntax like:
((= latex-mode) (reftex-label-alist
. (("equation" ?e "eq:%f-" "\\eqref{%s}")
("align" ?e "eq:%f-" "\\eqref{%s}")
("gather" ?e "eq:%f-" "\\eqref{%s}"))))
> 2. simple-minded reference to auto-mode-alist in emacs core
> As discussed in [2], when elisp codes look at auto-mode-alist
> directly and compare its content with `major-mode', new mode names
> such as `LaTeX-mode' get no hits and lead to failure.
> I added workaround for cedet/semantic/symref/grep.el, but similar
> problematic code still exists at least in cedet/semantic/idle.el:
> ----------------------------------------------------------------------
> (defun semantic-idle-scheduler-work-parse-neighboring-files ()
> ...(snip)...
> ;; Collect all patterns matching files of the same mode we edit.
> (mapc (lambda (pat) (and (eq (cdr pat) major-mode)
> (push (car pat) matching-auto-mode-patterns)))
> auto-mode-alist)
> ----------------------------------------------------------------------
IME, references to the `major-mode` variable in a package is a code
smell :-)
CEDET's code should obey `derived-mode-p` (and its own
`define-child-mode`), indeed. It shouldn't be hard to do.
Stefan