[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] 'race condition' in LaTeX-insert-environment
From: |
Lars Madsen |
Subject: |
[AUCTeX-devel] 'race condition' in LaTeX-insert-environment |
Date: |
Thu, 25 Sep 2014 14:22:26 +0000 |
I've been playing a bit with adding hooks to environments to add common
cleanups.
There seems to be a problem. I'm adding the env hooks to
LaTeX-after-insert-env-hooks, which states that
Each function is called with three arguments: the name of the
environment just inserted, the buffer position just before
\\begin and the position just before \\end
How ever that is not what I observe
If I have a text like
$ sdf $
test
I mark it and run C-c C-e test
I get
\begin{test}
$ sdsaf $. test
\end{test}
and if I test the positions given to a hook into the test env, the end position
ends up being after the 'e' in test
My guess is this part in LaTeX-insert-environment:
(setq env-end (point))
(insert TeX-esc "end" TeX-grop environment TeX-grcl)
(end-of-line 0)
(if active-mark
(progn
(or (assoc environment LaTeX-indent-environment-list)
(LaTeX-fill-region content-start (line-beginning-position 2)))
(set-mark content-start))
(indent-according-to-mode))
(save-excursion (beginning-of-line 2) (indent-according-to-mode))
(TeX-math-input-method-off)
(run-hook-with-args 'LaTeX-after-insert-env-hooks
environment env-start env-end)))
If I read this correctly 'env-end' is stored before any possible fill-region
might have altered the contents and changed the position of the \end part.
/Lars Madsen
Institut for Matematik / Department of Mathematics
Aarhus Universitet / Aarhus University
Mere info: http://au.dk/address@hidden / More information:
http://au.dk/en/address@hidden
- [AUCTeX-devel] 'race condition' in LaTeX-insert-environment,
Lars Madsen <=