[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 0cb3759 26/36: Implement inverse/backward search
From: |
Stefan Monnier |
Subject: |
[elpa] externals/auctex 0cb3759 26/36: Implement inverse/backward search for TeX regions. |
Date: |
Fri, 28 Nov 2014 17:25:49 +0000 |
branch: externals/auctex
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.
---
ChangeLog | 6 ++++++
tex-buf.el | 5 +++++
tex.el | 55 +++++++++++++++++++++++++++++++++++++++++--------------
3 files changed, 52 insertions(+), 14 deletions(-)
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))))
- [elpa] externals/auctex 43ff21a 12/36: Fix documentation about changing font attributes of existing text, (continued)
- [elpa] externals/auctex 43ff21a 12/36: Fix documentation about changing font attributes of existing text, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex d8dd53d 14/36: Update manual, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex f9611ad 04/36: Add new styles., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 7f64d6c 15/36: Update the FAQ entry about failing `TeX-next-error' behavior, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex af12165 16/36: Add new `ifluatex.el' style, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex c4feba1 17/36: Add new `luatextra.el' style, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 1997613 11/36: Add copyright notice to style/foils.el, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex deb1a64 24/36: Use more consistent fontification in some styles, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 29724a5 19/36: Add `luatextra.el' to Makefile.in, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 20c7209 27/36: Fix fontification of a couple of fontspec macros., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 0cb3759 26/36: Implement inverse/backward search for TeX regions.,
Stefan Monnier <=
- [elpa] externals/auctex 0bae61a 18/36: Add `ifluatex.el' to Makefile.in, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex daa8a25 20/36: Update windows-package Make rule to new Emacs 24.4 package., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 622c054 22/36: Document presence of bashisms in some Make rules., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 904dfef 21/36: Fix structure of the package for Windows., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 3909e4c 06/36: Several changes suggested by byte-compiler warnings., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex a3f4cac 29/36: Implement forward-search for View command on TeX-region., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 0c2cfc8 09/36: Replace `read-string' with `TeX-read-string', Stefan Monnier, 2014/11/28
- [elpa] externals/auctex acf1c76 31/36: Document LaTeX-command-section., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 15edd9b 23/36: Omit f-f hooks and more with TeX-region-create, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 8f7c399 30/36: Implement LaTeX-command-section., Stefan Monnier, 2014/11/28