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. 0cb3759d548be9b52cf53


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 0cb3759d548be9b52cf53295ab5d10f7bf7d2c92
Date: Wed, 19 Nov 2014 11:47:12 +0000

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  0cb3759d548be9b52cf53295ab5d10f7bf7d2c92 (commit)
      from  e4101ed623fc2e66ff9709a99b1cdb75b20a7c9d (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 0cb3759d548be9b52cf53295ab5d10f7bf7d2c92
Author: Tassilo Horn <address@hidden>
Date:   Wed Nov 19 12:46:15 2014 +0100

    Implement inverse/backward search for TeX regions.
    
    * tex.el (TeX-source-correlate-sync-source): Make backward/inverse
    search form PDF to tex work also for TeX-regions.
    
    * tex-buf.el (TeX-region-orig-buffer): New variable.
    (TeX-region-create): Set TeX-region-orig-buffer.

diff --git a/ChangeLog b/ChangeLog
index 49310be..7321d9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-11-19  Tassilo Horn  <address@hidden>
 
+       * tex.el (TeX-source-correlate-sync-source): Make backward/inverse
+       search form PDF to tex work also for TeX-regions.
+
+       * tex-buf.el (TeX-region-orig-buffer): New variable.
+       (TeX-region-create): Set TeX-region-orig-buffer.
+
        * tex.el (TeX-submit-bug-report): Adapt bug report intro text to
        mention debbugs url.
 
diff --git a/tex-buf.el b/tex-buf.el
index 3810ea9..7b6905b 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1387,6 +1387,10 @@ The hooks are run in the region buffer, you may use the 
variable
 (defvar font-lock-auto-fontify)
 (defvar font-lock-defaults-alist)
 
+(defvar TeX-region-orig-buffer nil
+  "The original buffer in which the TeX-region was created.")
+(make-variable-buffer-local 'TeX-region-orig-buffer)
+
 (defun TeX-region-create (file region original offset)
   "Create a new file named FILE with the string REGION.
 The region is taken from ORIGINAL starting at line OFFSET.
@@ -1490,6 +1494,7 @@ original file."
                                  (1+ (TeX-current-offset))))
                ") }\n"
                trailer)
+       (setq TeX-region-orig-buffer orig-buffer)
        (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 fc74537..ffd0ecf 100644
--- a/tex.el
+++ b/tex.el
@@ -1579,25 +1579,52 @@ or newer."
   ;; FILE may be given as relative path to the TeX-master root document or as
   ;; absolute file:// URL.  In the former case, the tex file has to be already
   ;; opened.
-  (let ((buf (let ((f (condition-case nil
-                         (progn
-                           (require 'url-parse)
-                           (require 'url-util)
-                           (url-unhex-string (aref (url-generic-parse-url 
file) 6)))
-                       ;; For Emacs 21 compatibility, which doesn't have the
-                       ;; url package.
-                       (file-error (replace-regexp-in-string "^file://" "" 
file)))))
-              (if (file-name-absolute-p f)
-                  (find-file f)
-                (get-buffer (file-name-nondirectory file)))))
-       (line (car linecol))
-       (col (cadr linecol)))
+  (let* ((line (car linecol))
+        (col (cadr linecol))
+        (region (string= TeX-region (file-name-sans-extension
+                                     (file-name-nondirectory file))))
+        (region-search-string nil)
+        (buf (let ((f (condition-case nil
+                          (progn
+                            (require 'url-parse)
+                            (require 'url-util)
+                            (url-unhex-string (aref (url-generic-parse-url 
file) 6)))
+                        ;; For Emacs 21 compatibility, which doesn't have the
+                        ;; url package.
+                        (file-error (replace-regexp-in-string "^file://" "" 
file)))))
+               (cond
+                ;; Copy the text referenced by syntex relative in the region
+                ;; file so that we can search it in the original file.
+                (region (let ((region-buf (get-buffer (file-name-nondirectory 
file))))
+                          (when region-buf
+                            (with-current-buffer region-buf
+                              (goto-char (point-min))
+                              (forward-line (1- line))
+                              (let* ((p (point))
+                                     (bound (save-excursion
+                                              (re-search-backward 
"\\\\message{[^}]+}" nil t)
+                                              (end-of-line)
+                                              (point)))
+                                     (start (save-excursion
+                                              (while (< (- p (point)) 250)
+                                                (backward-paragraph))
+                                              (point))))
+                                (setq region-search-string 
(buffer-substring-no-properties
+                                                            (if (< start 
bound) bound start)
+                                                            (point))))
+                              ;; TeX-region-create stores the original buffer
+                              ;; locally as TeX-region-orig-buffer.
+                              (get-buffer TeX-region-orig-buffer)))))
+                ((file-name-absolute-p f) (find-file f))
+                (t (get-buffer (file-name-nondirectory file)))))))
     (if (null buf)
        (message "No buffer for %s." file)
       (switch-to-buffer buf)
       (push-mark (point) 'nomsg)
       (goto-char (point-min))
-      (forward-line (1- line))
+      (if region
+         (search-forward region-search-string nil t)
+       (forward-line (1- line)))
       (unless (= col -1)
        (move-to-column col))
       (raise-frame))))

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

Summary of changes:
 ChangeLog  |    6 ++++++
 tex-buf.el |    5 +++++
 tex.el     |   55 +++++++++++++++++++++++++++++++++++++++++--------------
 3 files changed, 52 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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