[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] elpa ccfe316 42/51: Make TeX-view work better with regions
From: |
Tassilo Horn |
Subject: |
[elpa] elpa ccfe316 42/51: Make TeX-view work better with regions |
Date: |
Sun, 22 May 2016 07:22:50 +0000 (UTC) |
branch: elpa
commit ccfe3167c40a4b4c241bbc4f3b0445381f6ace8d
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
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 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))))
- [elpa] elpa bc8d07f 27/51: Temporarily bind `TeX-insert-macro-default-style' to 'show-optional-args', (continued)
- [elpa] elpa bc8d07f 27/51: Temporarily bind `TeX-insert-macro-default-style' to 'show-optional-args', Tassilo Horn, 2016/05/22
- [elpa] elpa 88fbf80 20/51: Fix in TeX sentinels, Tassilo Horn, 2016/05/22
- [elpa] elpa 693eee6 11/51: TikZ: Remove unneeded function., Tassilo Horn, 2016/05/22
- [elpa] elpa b20cd68 16/51: Fix a documentation type., Tassilo Horn, 2016/05/22
- [elpa] elpa 71349ec 23/51: Use `deactivate-input-method' if defined, Tassilo Horn, 2016/05/22
- [elpa] elpa d4d2ab5 31/51: Enable directory local variables in japanese-{latex, plain-tex}-mode, Tassilo Horn, 2016/05/22
- [elpa] elpa 63a83c3 30/51: Make unloading of tex-site work on Emacs 24, Tassilo Horn, 2016/05/22
- [elpa] elpa 5886c49 41/51: Improve the insertation of "macro" environment, Tassilo Horn, 2016/05/22
- [elpa] elpa e19f8bd 37/51: Do not check TeX engine with ifluatex package, Tassilo Horn, 2016/05/22
- [elpa] elpa 79a8643 47/51: Respect both "xcolor" and "color" for command queries, Tassilo Horn, 2016/05/22
- [elpa] elpa ccfe316 42/51: Make TeX-view work better with regions,
Tassilo Horn <=
- [elpa] elpa d418e9a 15/51: Prevent infinite loop in TeX-command-expand, Tassilo Horn, 2016/05/22
- [elpa] elpa 4f9666b 24/51: Use customize option `TeX-region' instead of "_region_", Tassilo Horn, 2016/05/22
- [elpa] elpa a83c4d0 02/51: Fix compatibility with older Emacs versions, Tassilo Horn, 2016/05/22
- [elpa] elpa 13153ba 40/51: Use commit date for package date also in configure, Tassilo Horn, 2016/05/22
- [elpa] elpa 7fc63f1 39/51: Tweak mode name only when file local variable is enabled., Tassilo Horn, 2016/05/22
- [elpa] elpa 7e3bec8 44/51: Run `TeX-add-symbols' if "xcolor" is not an active style, Tassilo Horn, 2016/05/22
- [elpa] elpa f0849b4 10/51: TikZ: Add the 'sin' and 'cos' connectors., Tassilo Horn, 2016/05/22
- [elpa] elpa 7ea1aa3 18/51: TikZ: Don't allow relative points with \coordinate., Tassilo Horn, 2016/05/22
- [elpa] elpa c032063 19/51: Auto save `TeX-command-extra-options'., Tassilo Horn, 2016/05/22
- [elpa] elpa 56c1afd 28/51: Call TeX-newline-function interactively, Tassilo Horn, 2016/05/22