emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex a3f4cac 29/36: Implement forward-search for View


From: Stefan Monnier
Subject: [elpa] externals/auctex a3f4cac 29/36: Implement forward-search for View command on TeX-region.
Date: Fri, 28 Nov 2014 17:25:51 +0000

branch: externals/auctex
commit a3f4cac866bce4784858cc1a2e8e3661576445f4
Author: Tassilo Horn <address@hidden>
Date:   Fri Nov 21 11:03:11 2014 +0100

    Implement forward-search for View command on TeX-region.
    
    * tex.el (TeX-evince-sync-view): Use line/col information from the
    TeX-region buffer if the View command is made on a region.
    
    * tex-buf.el (TeX-region-create): Position point in the same
    line/col as in the original buffer to make forward search work.
---
 ChangeLog  |    8 ++++++++
 tex-buf.el |   20 ++++++++++++++------
 tex.el     |   19 +++++++++++--------
 3 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d83ac0f..59a020f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-11-21  Tassilo Horn  <address@hidden>
+
+       * tex.el (TeX-evince-sync-view): Use line/col information from the
+       TeX-region buffer if the View command is made on a region.
+
+       * tex-buf.el (TeX-region-create): Position point in the same
+       line/col as in the original buffer to make forward search work.
+
 2014-11-20  Mos� Giordano  <address@hidden>
 
        * latex.el (LaTeX-env-figure): Fix indentation when there is the
diff --git a/tex-buf.el b/tex-buf.el
index 7b6905b..27a4b5c 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -365,9 +365,9 @@ asked if it is positive, and suppressed if it is not."
     ;; the command, but keep them if the command to be run is View.
     (unless (string= name "View")
       (if (frame-live-p TeX-error-overview-frame)
-                  (delete-frame TeX-error-overview-frame))
-     (if (get-buffer TeX-error-overview-buffer-name)
-        (kill-buffer TeX-error-overview-buffer-name)))
+         (delete-frame TeX-error-overview-frame))
+      (if (get-buffer TeX-error-overview-buffer-name)
+         (kill-buffer TeX-error-overview-buffer-name)))
 
     ;; Now start the process
     (setq file (funcall file))
@@ -1447,7 +1447,7 @@ original file."
                               ""
                             (re-search-forward "[\r\n]" nil t)
                             (buffer-substring (point-min) (point)))))))))
-
+        (header-offset 0)
         ;; We search for the trailer from the master file, if it is
         ;; not present in the region.
         (trailer-offset 0)
@@ -1485,8 +1485,9 @@ original file."
                header
                TeX-region-extra
                "\n\\message{ !name(" original ") !offset(")
-       (insert (int-to-string (- offset
-                                 (1+ (TeX-current-offset))))
+       (setq header-offset (- offset
+                              (1+ (TeX-current-offset))))
+       (insert (int-to-string header-offset)
                ") }\n"
                region
                "\n\\message{ !name("  master-name ") !offset(")
@@ -1495,6 +1496,13 @@ original file."
                ") }\n"
                trailer)
        (setq TeX-region-orig-buffer orig-buffer)
+       ;; Position point at the line/col that corresponds to point's line in
+       ;; orig-buffer in order to make forward search work.
+       (let ((line-col (with-current-buffer orig-buffer
+                         (cons (line-number-at-pos)
+                               (current-column)))))
+         (goto-line (abs (- header-offset (car line-col))))
+         (forward-char (cdr line-col)))
        (run-hooks 'TeX-region-hook)
        (if (string-equal (buffer-string) original-content)
            (set-buffer-modified-p nil)
diff --git a/tex.el b/tex.el
index ffd0ecf..3b530cb 100644
--- a/tex.el
+++ b/tex.el
@@ -1112,14 +1112,17 @@ the requirements are met."
                 uri
                 t)))
     (if owner
-       (dbus-call-method
-        :session owner
-        "/org/gnome/evince/Window/0"
-        "org.gnome.evince.Window"
-        "SyncView"
-        (buffer-file-name)
-        (list :struct :int32 (line-number-at-pos) :int32 (1+ (current-column)))
-        :uint32 0)
+       (with-current-buffer (or (when TeX-current-process-region-p
+                                  (get-file-buffer (TeX-region-file t)))
+                                (current-buffer))
+         (dbus-call-method
+          :session owner
+          "/org/gnome/evince/Window/0"
+          "org.gnome.evince.Window"
+          "SyncView"
+          (buffer-file-name)
+          (list :struct :int32 (line-number-at-pos) :int32 (1+ 
(current-column)))
+          :uint32 0))
       (error "Couldn't find the Evince instance for %s" uri))))
 
 (defvar TeX-view-program-list-builtin



reply via email to

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