auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. ccfe3167c40a4b4c241bb


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. ccfe3167c40a4b4c241bbc4f3b0445381f6ace8d
Date: Sun, 15 May 2016 07:12:10 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  ccfe3167c40a4b4c241bbc4f3b0445381f6ace8d (commit)
      from  5886c49d94ac761020bf2494afb42677987b3e90 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ccfe3167c40a4b4c241bbc4f3b0445381f6ace8d
Author: Tassilo Horn <address@hidden>
Date:   Fri May 13 08:36:50 2016 +0200

    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.

diff --git a/tex-buf.el b/tex-buf.el
index f2017cd..0fe7b9d 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -892,6 +892,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,
@@ -899,7 +918,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 6902de9..8ea0b45 100644
--- a/tex.el
+++ b/tex.el
@@ -1271,7 +1271,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))))

-----------------------------------------------------------------------

Summary of changes:
 tex-buf.el |   25 ++++++++++++++++++++++++-
 tex.el     |    2 +-
 2 files changed, 25 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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