branch: externals/auctex
commit b4dde3e325034f832b0a7a35f3c2acae3fd754af
Author: Paul Nelson <[email protected]>
Commit: Arash Esbati <[email protected]>
Fix `preview-region' on repeated math constructs
* preview.el.in (preview--region-begin): New variable.
(preview-parse-messages, preview-region): Use and set the new
variable in order to make `preview-region' work correctly when
applied to, e.g., the second "$x$" in "$x$ $x$". (bug#62445)
---
preview.el.in | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/preview.el.in b/preview.el.in
index 09836d9e34..9541043997 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -3268,6 +3268,8 @@ Return a new string."
(setq result (concat result string))
result))
+(defvar-local preview--region-begin nil)
+
(defun preview-parse-messages (open-closure)
"Turn all preview snippets into overlays.
This parses the pseudo error messages from the preview
@@ -3538,6 +3540,15 @@ name(\\([^)]+\\))\\)\\|\
(goto-char (point-min))
(forward-line (1- line)))
(setq lpoint (point))
+
+ ;; The following addresses the bug described at
+ ;;
https://lists.gnu.org/archive/html/bug-auctex/2023-03/msg00007.html
+ ;; (bug#62445)
+ (and preview--region-begin
+ (< (point)
+ preview--region-begin)
+ (goto-char preview--region-begin))
+
(cond
((search-forward (concat string after-string)
(line-end-position) t)
@@ -4033,6 +4044,7 @@ stored in `preview-dumped-alist'."
"<none>")
(TeX-current-offset begin)))
(setq TeX-current-process-region-p t)
+ (setq preview--region-begin begin)
(preview-generate-preview (TeX-region-file)
(preview-do-replacements
(TeX-command-expand