summaryrefslogtreecommitdiff
path: root/lisp/textmodes/reftex-toc.el
diff options
context:
space:
mode:
authorCarsten Dominik <dominik@science.uva.nl>2002-08-27 09:58:05 +0000
committerCarsten Dominik <dominik@science.uva.nl>2002-08-27 09:58:05 +0000
commit3b919c9f8c18da98a9e81449cf3afc347ddaf3a5 (patch)
treeccd5b8c0e2953f5426d679973eeb283aaf9b794f /lisp/textmodes/reftex-toc.el
parenta062d73f508e1ae18ae327b3e6957398001ee4b5 (diff)
downloademacs-3b919c9f8c18da98a9e81449cf3afc347ddaf3a5.tar.gz
Update to RefTeX 4.19
Diffstat (limited to 'lisp/textmodes/reftex-toc.el')
-rw-r--r--lisp/textmodes/reftex-toc.el73
1 files changed, 66 insertions, 7 deletions
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index c769758430c..d1b8fee760a 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -95,7 +95,7 @@ C-c > Display Index. With prefix arg, restrict index to current section.
q / k Hide/Kill *toc* buffer, return to position of reftex-toc command.
l i c F Toggle display of [l]abels, [i]ndex, [c]ontext, [F]ile borders.
t Change maximum toc depth (e.g. `3 t' hides levels greater than 3).
-f / g Toggle follow mode on and off / Refresh *toc* buffer.
+f / a / g Toggle follow mode / toggle auto recenter / Refresh *toc* buffer.
r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document.
. In other window, show position from where `reftex-toc' was called.
x Switch to TOC of external document (with LaTeX package `xr').
@@ -132,7 +132,7 @@ When called with a raw C-u prefix, rescan the document first."
(docstruct-symbol reftex-docstruct-symbol)
(xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
(xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
- (here-I-am (if rebuild
+ (here-I-am (if (boundp 'reftex-rebuilding-toc)
(get 'reftex-toc :reftex-data)
(car (reftex-where-am-I))))
offset)
@@ -218,10 +218,31 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line))
(setq reftex-last-follow-point (point))))
+(defun reftex-toc-recenter (&optional arg)
+ "Display the TOC window and highlight line corresponding to current position."
+ (interactive "P")
+ (let ((buf (current-buffer)))
+ (reftex-toc arg)
+ (if (= (count-lines 1 (point)) 2)
+ (let ((current-prefix-arg nil))
+ (select-window (get-buffer-window buf))
+ (reftex-toc nil)))
+ (and (> (point) 1)
+ (not (get-text-property (point) 'intangible))
+ (memq reftex-highlight-selection '(cursor both))
+ (reftex-highlight 2
+ (or (previous-single-property-change
+ (min (point-max) (1+ (point))) :data)
+ (point-min))
+ (or (next-single-property-change (point) :data)
+ (point-max))))
+ (select-window (get-buffer-window buf))))
+
(defun reftex-toc-pre-command-hook ()
;; used as pre command hook in *toc* buffer
(reftex-unhighlight 0)
- (reftex-unhighlight 1))
+;; (reftex-unhighlight 1) ;; remove highlight on leaving buffer.
+ )
(defun reftex-toc-post-command-hook ()
;; used in the post-command-hook for the *toc* buffer
@@ -230,7 +251,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(and (> (point) 1)
(not (get-text-property (point) 'intangible))
(memq reftex-highlight-selection '(cursor both))
- (reftex-highlight 1
+ (reftex-highlight 2
(or (previous-single-property-change (1+ (point)) :data)
(point-min))
(or (next-single-property-change (point) :data)
@@ -410,16 +431,20 @@ With prefix arg 1, restrict index to the section at point."
(switch-to-buffer-other-window
(reftex-get-file-buffer-force file))
(setq current-prefix-arg '(4))
- (reftex-toc t)))
+ (let ((reftex-rebuilding-toc t))
+ (reftex-toc))))
(reftex-toc-Rescan))
(reftex-kill-temporary-buffers))
(defun reftex-toc-Rescan (&rest ignore)
"Regenerate the *toc* buffer by reparsing the entire document."
(interactive)
+ (let* ((line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
+ (put 'reftex-toc :reftex-line line))
(switch-to-buffer-other-window
(reftex-get-file-buffer-force reftex-last-toc-file))
(setq current-prefix-arg '(16))
- (reftex-toc t))
+ (let ((reftex-rebuilding-toc t))
+ (reftex-toc)))
(defun reftex-toc-revert (&rest ignore)
"Regenerate the *toc* from the internal lists."
(interactive)
@@ -427,7 +452,8 @@ With prefix arg 1, restrict index to the section at point."
(reftex-get-file-buffer-force reftex-last-toc-file))
(reftex-erase-buffer "*toc*")
(setq current-prefix-arg nil)
- (reftex-toc t))
+ (let ((reftex-rebuilding-toc t))
+ (reftex-toc t)))
(defun reftex-toc-external (&rest ignore)
"Switch to table of contents of an external document."
(interactive)
@@ -573,6 +599,38 @@ Useful for large TOC's."
(setq old (substring old (match-end 0))))
new))
+
+(defun reftex-recenter-toc-when-idle ()
+ (and (> (buffer-size) 5)
+ reftex-mode
+ (not (active-minibuffer-window))
+ (fboundp 'reftex-toc-mode)
+ (get-buffer-window "*toc*")
+ (string= reftex-last-toc-master (reftex-TeX-master-file))
+ (reftex-toc-recenter)))
+
+(defun reftex-toggle-auto-toc-recenter ()
+ "Toggle the automatic recentering of the toc window.
+When active, leaving point idle will make the toc window jump to the correct
+section."
+ (interactive)
+ (if reftex-toc-auto-recenter-timer
+ (progn
+ (if (featurep 'xemacs)
+ (delete-itimer reftex-toc-auto-recenter-timer)
+ (cancel-timer reftex-toc-auto-recenter-timer))
+ (setq reftex-toc-auto-recenter-timer nil)
+ (message "Automatic recentering of toc buffer was turned off"))
+ (setq reftex-toc-auto-recenter-timer
+ (if (featurep 'xemacs)
+ (start-itimer "RefTeX Idle Timer for recenter"
+ 'reftex-recenter-toc-when-idle
+ reftex-idle-time reftex-idle-time t)
+ (run-with-idle-timer
+ reftex-idle-time t 'reftex-recenter-toc-when-idle)))
+ (message "Automatic recentering of toc window was turned on")))
+
+
;; Table of Contents map
(define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
'reftex-toc-mouse-goto-line-and-hide)
@@ -596,6 +654,7 @@ Useful for large TOC's."
("q" . reftex-toc-quit)
("k" . reftex-toc-quit-and-kill)
("f" . reftex-toc-toggle-follow)
+ ("a" . reftex-toggle-auto-toc-recenter)
("F" . reftex-toc-toggle-file-boundary)
("i" . reftex-toc-toggle-index)
("l" . reftex-toc-toggle-labels)