Qiang Yin <[email protected]> writes: Hi!
> Seems your commit is still not pushed yet. Right, I still can't reach the repos. Savannah seems to have some troubles. https://savannah.gnu.org/forum/forum.php?forum_id=8542 > Would you be kind send me this patch by email? Sure. However, I'm not sure if it'll apply cleanly. Since I can't pull, I haven't been able to rebase it onto Mosè's recent changes. Bye, Tassilo
>From b7a56bb1377e0170d339c9bc636a95281aaa6f37 Mon Sep 17 00:00:00 2001 From: Tassilo Horn <[email protected]> Date: Fri, 13 May 2016 08:36:50 +0200 Subject: [PATCH] Make TeX-view work better with regions * tex-buf.el (TeX-region-update-point): New function which sets point in the region buffer so that it matches the location of point in the current buffer. (TeX-view): Use it. --- tex-buf.el | 25 ++++++++++++++++++++++++- tex.el | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tex-buf.el b/tex-buf.el index 58e1602..0c41692 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -888,6 +888,25 @@ QUEUE is non-nil when we are checking for the printer queue." (goto-char (posn-point (event-start event))) (TeX-view))) +(defun TeX-region-update-point () + "Syncs the location of point in the region file with the current file. + +Thereafter, point in the region file is on the same text as in +the current buffer. + +Does nothing in case the last command hasn't operated on the +region." + (when TeX-current-process-region-p + (let ((region-buf (get-file-buffer (TeX-region-file t))) + (current-line (line-number-at-pos))) + (when region-buf + (with-current-buffer region-buf + (goto-char (point-min)) + (when (re-search-forward "!offset(\\([0-9]+\\)") + (let ((offset (string-to-int (match-string 1)))) + (goto-char (point-min)) + (forward-line (- current-line (1+ offset)))))))))) + (defun TeX-view () "Start a viewer without confirmation. The viewer is started either on region or master file, @@ -895,7 +914,11 @@ depending on the last command issued." (interactive) (let ((output-file (TeX-active-master (TeX-output-extension)))) (if (file-exists-p output-file) - (TeX-command "View" 'TeX-active-master 0) + (progn + ;; When we're operating on a region, we need to update the position + ;; of point in the region file so that forward search works. + (TeX-region-update-point) + (TeX-command "View" 'TeX-active-master 0)) (message "Output file %S does not exist." output-file)))) (defun TeX-output-style-check (styles) diff --git a/tex.el b/tex.el index 7449659..c113ebf 100644 --- a/tex.el +++ b/tex.el @@ -1269,7 +1269,7 @@ entry in `TeX-view-program-list-builtin'." (if (and TeX-source-correlate-mode (fboundp 'pdf-sync-forward-search)) (with-current-buffer (or (when TeX-current-process-region-p - (get-file-buffer (TeX-region-file t))) + (get-file-buffer (TeX-region-file t))) (current-buffer)) (pdf-sync-forward-search)) (let ((pdf (concat file "." (TeX-output-extension)))) -- 2.8.2
_______________________________________________ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
