Hi Uwe, Uwe Brauer <o...@mat.ucm.es> writes: > Yesterday, however, I received the announcement of version 14.0.1. Among > the new features was the function *LaTeX-modify-math*, which I very much > appreciate. > > (...) > > When the target environment is an *equation*, could a label not be > inserted automatically?
When LaTeX-modify-math creates an equation environment, it does so via LaTeX-insert-environment, which comes with the hook LaTeX-after-insert-env-hook. I think you get what you want via (LaTeX-modify-math "equation") and the following: --8<---------------cut here---------------start------------->8--- (defun my-after-insert-environment-hook (name beg end) "Add label to newly inserted equation environments. NAME is the environment just inserted, while BEG and END are the positions just before \\begin and \\end." (when (equal name "equation") (unless (save-excursion (goto-char beg) (search-forward "\\label{" end t)) (save-excursion (goto-char beg) (end-of-line) (reftex-label))))) (add-hook 'LaTeX-after-insert-env-hook #'my-after-insert-environment-hook) --8<---------------cut here---------------end--------------->8--- What do you think? This seems to me as capable as introducing an option, but a bit more flexible, because you can control exactly where and how the label is inserted. Paul