[Top][All Lists]

[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 

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 $

I mark it and run C-c C-e test

I get

  $ sdsaf $.  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
          (or (assoc environment LaTeX-indent-environment-list)
              (LaTeX-fill-region content-start (line-beginning-position 2)))
          (set-mark content-start))
    (save-excursion (beginning-of-line 2) (indent-according-to-mode))
    (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: / More information:

reply via email to

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