auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AUCTeX and "builtin latex mode" integration


From: Ikumi Keita
Subject: Re: AUCTeX and "builtin latex mode" integration
Date: Sun, 25 Sep 2022 21:40:22 +0900

Hi Stefan and all,

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Then the idea of turning AUCTeX into minor mode itself does not help.

> Not necessarily, but it could if we can arrange for latex-mode and
> auctex-mode not to collide in their keymaps (and syntax table, ...), so
> that entries added to `latex-mode-map` wouldn't be hidden by the
> auctex-mode-map (e.g. if that map was added with lower priority than
> latex-mode-map).

Ah, indeed. It would be possible that `LaTeX-mode-map' has a parent
keymap composed of both `latex-mode-map' and `TeX-mode-map'. Similar
treatment would go for syntax table.

>> (a) In addition to being minor mode, AUCTeX uses lower case
>> `latex-mode-hook', `latex-mode-map' and `latex-mode-syntax-table'.
>> In this case, variable aliases `LaTeX-mode-hook' ->
>> `latex-mode-hook' etc. would also be necessary for compatibility.

> It could also just run `latex-mode-hook` in addition to what it already
> runs, without setting up any alias between that and `LaTeX-mode-hook`.

Indeed.

>> (b) AUCTeX abandons the relationship between `LaTeX-mode' and
>> `latex-mode'. I.e. `LaTeX-mode' no longer pretends to be
>> `latex-mode'.

> I think whether it pretends to be is a separate question from whether it
> redirects `latex-mode` to its own implementation.

> E.g. we could start by setting `major-mode` to `LaTeX-mode` rather than
> `latex-mode`.

Hmm, that approach didn't came to my mind. After reconsideration, it
seems faily reasonable than I first saw it.

Possible/potential caveats:
1. Suppose that the file has %%% mode:latex as file variable. When emacs
opens this file, it runs `latex-mode' accordingly, which in turn runs
AUCTeX `LaTeX-mode' by redirectiton. Then it sets `major-mode' to
`LaTeX-mode'. After that, `hack-local-variables' runs; it sees that
`major mode' doesn't match the %%% mode:latex line and runs `latex-mode'
again. In this way, a file with %%% mode:latex or -*- latex -*- always
runs `latex-mode' twice.
I hope that we can find a way to avoid such overheads.

2. In order to keep backward compatibility of an entry of the form
(latex (XXX . t) (YYY . 15) ...) in .dir-locals.el, `LaTeX-mode' should
be a derived mode of `latex-mode'. However, defining `LaTeX-mode' by
(define-derived-mode LaTeX-mode latex-mode ...) would cause infinite
loop when redirection is enabled.
I expect that we can circumvent the difficulty by putting
`derived-mode-parent' property on `LaTeX-mode', without
`define-derived-mode'.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine



reply via email to

[Prev in Thread] Current Thread [Next in Thread]