branch: master commit 47f9ead1c614ff9a9afe474f45b774e589a6fd91 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Respect `TeX-exit-mark' when inserting enviroments * latex.el (LaTeX--env-parse-args): Set `TeX-exit-mark' to current point if not set yet. Move point to the position of `TeX-exit-mark' after parsing the arguments, so hooks can set the value acc. to their needs. * tex.el (TeX-exit-mark): Adjust docstring. --- latex.el | 14 +++++++++----- tex.el | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/latex.el b/latex.el index eea54db4..744257e3 100644 --- a/latex.el +++ b/latex.el @@ -1062,13 +1062,17 @@ If nil, act like the empty string is given, but do not prompt." :type 'string) (defun LaTeX--env-parse-args (args) - "Helper function to insert arguments defined by ARGS." - (save-excursion + "Helper function to insert arguments defined by ARGS. +This function checks if `TeX-exit-mark' is set, otherwise it's +set to the point where this function starts. Point will be at +`TeX-exit-mark' when this function exits." + (let ((TeX-exit-mark (or TeX-exit-mark + (point-marker)))) (LaTeX-find-matching-begin) (end-of-line) - (let ((TeX-exit-mark (or TeX-exit-mark - (make-marker)))) - (TeX-parse-arguments args)))) + (TeX-parse-arguments args) + (goto-char TeX-exit-mark) + (set-marker TeX-exit-mark nil))) (defun LaTeX--env-item (environment) "Helper function running inside `LaTeX-env-item'. diff --git a/tex.el b/tex.el index c5fd9678..d74d10d0 100644 --- a/tex.el +++ b/tex.el @@ -3367,7 +3367,7 @@ Space will complete and exit." (call-interactively #'TeX-insert-macro))))) (defvar TeX-exit-mark nil - "Dynamically bound by `TeX-parse-macro' and `LaTeX-env-args'.") + "Dynamically bound by `TeX-parse-macro' and `LaTeX--env-parse-args'.") (defun TeX-parse-macro (symbol args) "How to parse TeX macros which takes one or more arguments.