latex-electric-env-pair-mode in AUCTeX
Вопрос
the guys of the plain tex-mode have added a very nice feature with emacs 24.1, a minor mode called latex-electric-env-pair-mode which keeps existing \begin{...} [...] \end{...}
pairs matched. I.e. when changing the environment name in the \begin{...}
tag, its corresponding \end{...}
is changed automatically (very nice when changing from starred to non-starred version of an environment and vice-versa).
However, when comparing with AUCTeX, the tex-mode still sucks... but I really like the new minor mode. I have tried to make a stand-alone minor mode by copying everything that looked like it was used from tex-mode.el to a new file and changed all the descriptors (so they won't conflict with AUCTeX or any remainders for tex-mode). Unfortunately this won't work, the minor mode can be turned on but it is broke: nothing is happening.
I'm not a (e)lisp programmer, that is to say I don't really understand the code. But maybe someone likes the feature of this minor mode and can port it to a stand-alone version? Also there might be some package out there which provides similar/equal functionality?
I'd appreciate any help!
Решение
You probably missed tex-env-mark
(which sets marks that are used later by latex-electric-env-pair-mode
to find environment starters/enders) or latex-syntax-propertize-rules
(which runs tex-env-marks
on relevant parts of the buffer) or the setting of syntax-propertize-function
(which uses latex-syntax-propertize-rules
so that these rules are actually used).
BTW, rather than copying those things, I recommend you try something like the untested code below:
(defconst my-latex-syntax-propertize-function
(with-temp-buffer (latex-mode) syntax-propertize-function))
(add-hook 'LaTeX-mode-hook
(lambda ()
(set (make-local-variable 'syntax-propertize-function)
my-latex-syntax-propertize-function)
(latex-electric-env-pair-mode 1)))