summaryrefslogtreecommitdiff
path: root/lisp/textmodes
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
parenta062d73f508e1ae18ae327b3e6957398001ee4b5 (diff)
downloademacs-3b919c9f8c18da98a9e81449cf3afc347ddaf3a5.tar.gz
Update to RefTeX 4.19
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/reftex-index.el2
-rw-r--r--lisp/textmodes/reftex-parse.el85
-rw-r--r--lisp/textmodes/reftex-ref.el34
-rw-r--r--lisp/textmodes/reftex-sel.el57
-rw-r--r--lisp/textmodes/reftex-toc.el73
-rw-r--r--lisp/textmodes/reftex-vars.el35
-rw-r--r--lisp/textmodes/reftex.el36
7 files changed, 261 insertions, 61 deletions
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 8990c15dc7e..802f11b723d 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -30,9 +30,11 @@
(require 'reftex)
;;;
+;; START remove for XEmacs release
(defvar mark-active)
(defvar zmacs-regions)
(defvar transient-mark-mode)
+;; END remove for XEmacs release
(defun reftex-index-selection-or-word (&optional arg phrase)
"Put selection or the word near point into the default index macro.
This uses the information in `reftex-index-default-macro' to make an index
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index c6a950da6d7..74b6c20b927 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -551,7 +551,7 @@ of master file."
;; exact (t) or approximate (nil).
(let ((docstruct (symbol-value reftex-docstruct-symbol))
- (cnt 0) rtn
+ (cnt 0) rtn rtn-if-no-other
found)
(save-excursion
(while (not rtn)
@@ -591,8 +591,8 @@ of master file."
(setq rtn1 (car list) list nil))
((looking-at (reftex-make-regexp-allow-for-ctrl-m
(nth 7 (car list))))
- ;; Same title
- (setq rtn1 (car list) list nil cnt 2))))
+ ;; Same title: remember, but keep looking
+ (setq rtn-if-no-other (car list)))))
(pop list))
rtn1))
((match-end 7)
@@ -637,6 +637,10 @@ of master file."
(symbol-value reftex-docstruct-symbol))))
(t
(error "This should not happen (reftex-where-am-I)"))))))
+ ;; Check if there was only a by-name match for the section.
+ (when (and (not rtn) rtn-if-no-other)
+ (setq rtn rtn-if-no-other
+ cnt 2))
(cons rtn (eq cnt 1))))
(defun reftex-notice-new (&optional n force)
@@ -1002,7 +1006,12 @@ of master file."
;; Return a string with the current section number.
;; When LEVEL is non-nil, increase section numbers on that level.
(let* ((depth (1- (length reftex-section-numbers))) idx n (string "")
- (appendix (get 'reftex-section-numbers 'appendix)))
+ (appendix (get 'reftex-section-numbers 'appendix))
+ (partspecial (and (not reftex-part-resets-chapter)
+ (equal level 0))))
+ ;; partspecial means, this is a part statement.
+ ;; Parts do not reset the chapter counter, and the part number is
+ ;; not included in the numbering of other sectioning levels.
(when level
(when (and (> level -1) (not star))
(aset reftex-section-numbers
@@ -1010,28 +1019,52 @@ of master file."
(setq idx (1+ level))
(when (not star)
(while (<= idx depth)
- (aset reftex-section-numbers idx 0)
+ (if (or (not partspecial)
+ (not (= idx 1)))
+ (aset reftex-section-numbers idx 0))
(incf idx))))
- (setq idx 0)
- (while (<= idx depth)
- (setq n (aref reftex-section-numbers idx))
- (setq string (concat string (if (not (string= string "")) "." "")
- (int-to-string n)))
- (incf idx))
- (save-match-data
- (if (string-match "\\`\\([@0]\\.\\)+" string)
- (setq string (replace-match "" nil nil string)))
- (if (string-match "\\(\\.0\\)+\\'" string)
- (setq string (replace-match "" nil nil string)))
- (if (and appendix
- (string-match "\\`[0-9]+" string))
- (setq string
- (concat
- (char-to-string
- (1- (+ ?A (string-to-int (match-string 0 string)))))
- (substring string (match-end 0))))))
- (if star
- (concat (make-string (1- (length string)) ?\ ) "*")
- string)))
+ (if partspecial
+ (setq string (concat "Part " (reftex-roman-number
+ (aref reftex-section-numbers 0))))
+ (setq idx (if reftex-part-resets-chapter 0 1))
+ (while (<= idx depth)
+ (setq n (aref reftex-section-numbers idx))
+ (if (not (and partspecial (not (equal string ""))))
+ (setq string (concat string (if (not (string= string "")) "." "")
+ (int-to-string n))))
+ (incf idx))
+ (save-match-data
+ (if (string-match "\\`\\([@0]\\.\\)+" string)
+ (setq string (replace-match "" nil nil string)))
+ (if (string-match "\\(\\.0\\)+\\'" string)
+ (setq string (replace-match "" nil nil string)))
+ (if (and appendix
+ (string-match "\\`[0-9]+" string))
+ (setq string
+ (concat
+ (char-to-string
+ (1- (+ ?A (string-to-int (match-string 0 string)))))
+ (substring string (match-end 0))))))
+ (if star
+ (concat (make-string (1- (length string)) ?\ ) "*")
+ string))))
+
+(defun reftex-roman-number (n)
+ ;; Return as a string the roman number equal to N.
+ (let ((nrest n)
+ (string "")
+ (list '((1000 . "M") ( 900 . "CM") ( 500 . "D") ( 400 . "CD")
+ ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
+ ( 10 . "X") ( 9 . "IX") ( 5 . "V") ( 4 . "IV")
+ ( 1 . "I")))
+ listel i s)
+ (while (>= nrest 1)
+ (setq listel (pop list)
+ i (car listel)
+ s (cdr listel))
+ (while (>= nrest i)
+ (setq string (concat string s)
+ nrest (- nrest i))))
+ string))
;;; reftex-parse.el ends here
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index d3aaeb518e3..b5088a34ff4 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -421,7 +421,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
(reftex-offer-label-menu type)))
(reftex-ensure-compiled-variables)
(set-marker reftex-select-return-marker nil)
- ;; If the first entry is the symbol 'concat, concat all all labels.
+ ;; If the first entry is the symbol 'concat, concat all labels.
;; We keep the cdr of the first label for typekey etc information.
(if (eq (car labels) 'concat)
(setq labels (list (list (mapconcat 'car (cdr labels) ",")
@@ -802,4 +802,36 @@ When called with 2 C-u prefix args, disable magic word recognition."
(defun reftex-format-fref (label def-fmt)
(format "\\fref{%s}" label))
+
+;(defun reftex-goto-label ()
+; (interactive)
+; (reftex-access-scan-info)
+; (let* ((docstruct (symbol-value reftex-docstruct-symbol))
+; (label (completing-read "Label: " docstruct
+; (lambda (x) (stringp (car x))) t))
+; (selection (assoc label docstruct)))
+; (reftex-show-label-location selection t nil 'stay)
+; (reftex-unhighlight 0)))
+
+(defun reftex-goto-label (&optional other-window)
+ "Prompt for a label (with completion) and jump to the location of this label.
+Optional prefix argument OTHER-WINDOW goes to the label in another window."
+ (interactive "P")
+ (reftex-access-scan-info)
+ (let* ((wcfg (current-window-configuration))
+ (docstruct (symbol-value reftex-docstruct-symbol))
+ (label (completing-read "Label: " docstruct
+ (lambda (x) (stringp (car x))) t))
+ (selection (assoc label docstruct))
+ (where (progn
+ (reftex-show-label-location selection t nil 'stay)
+ (point-marker))))
+ (unless other-window
+ (set-window-configuration wcfg)
+ (switch-to-buffer (marker-buffer where))
+ (goto-char where))
+ (reftex-unhighlight 0)))
+
+
+
;;; reftex-ref.el ends here
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index f888406c593..039cc34b216 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -89,17 +89,40 @@ During a selection process, these are the local bindings.
;; We do not set a local map - reftex-select-item does this.
(run-hooks 'reftex-select-bib-mode-hook))
+;;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
+;;; ;; Find the correct offset data, like insert-docstruct would, but faster.
+;;; ;; Buffer BUF knows the correct docstruct to use.
+;;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
+;;; ;; is of allowed type. The optional arguments specify what is allowed.
+;;; (catch 'exit
+;;; (save-excursion
+;;; (set-buffer buf)
+;;; (reftex-access-scan-info)
+;;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
+;;; entry)
+;;; (while (setq entry (pop rest))
+;;; (if (or (and typekey
+;;; (stringp (car entry))
+;;; (or (equal typekey " ")
+;;; (equal typekey (nth 1 entry))))
+;;; (and toc (eq (car entry) 'toc))
+;;; (and index (eq (car entry) 'index))
+;;; (and file
+;;; (memq (car entry) '(bof eof file-error))))
+;;; (throw 'exit entry)))
+;;; nil))))
+
(defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
;; Find the correct offset data, like insert-docstruct would, but faster.
;; Buffer BUF knows the correct docstruct to use.
- ;; Basically this finds the first docstruct entry after HERE-I-AM which
+ ;; Basically this finds the first docstruct entry before HERE-I-AM which
;; is of allowed type. The optional arguments specify what is allowed.
(catch 'exit
(save-excursion
(set-buffer buf)
(reftex-access-scan-info)
- (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
- entry)
+ (let* ((rest (symbol-value reftex-docstruct-symbol))
+ lastentry entry)
(while (setq entry (pop rest))
(if (or (and typekey
(stringp (car entry))
@@ -109,7 +132,9 @@ During a selection process, these are the local bindings.
(and index (eq (car entry) 'index))
(and file
(memq (car entry) '(bof eof file-error))))
- (throw 'exit entry)))
+ (setq lastentry entry))
+ (if (eq entry here-am-I)
+ (throw 'exit (or lastentry entry))))
nil))))
(defun reftex-insert-docstruct
@@ -149,7 +174,7 @@ During a selection process, these are the local bindings.
'font-lock-constant-face
'font-lock-reference-face))
all cell text label typekey note comment master-dir-re
- offset from to index-tag docstruct-symbol)
+ prev-inserted offset from to index-tag docstruct-symbol)
;; Pop to buffer buf to get the correct buffer-local variables
(save-excursion
@@ -176,8 +201,6 @@ During a selection process, these are the local bindings.
(incf index)
(setq from (point))
- (if (eq cell here-I-am) (setq offset 'attention))
-
(cond
((memq (car cell) '(bib thebib label-numbers appendix
@@ -187,7 +210,8 @@ During a selection process, these are the local bindings.
((memq (car cell) '(bof eof file-error))
;; Beginning or end of a file
(when files
- (if (eq offset 'attention) (setq offset cell))
+ (setq prev-inserted cell)
+; (if (eq offset 'attention) (setq offset cell))
(insert
" File " (if (string-match master-dir-re (nth 1 cell))
(substring (nth 1 cell) (match-end 0))
@@ -209,7 +233,8 @@ During a selection process, these are the local bindings.
;; a table of contents entry
(when (and toc
(<= (nth 5 cell) reftex-toc-max-level))
- (if (eq offset 'attention) (setq offset cell))
+ (setq prev-inserted cell)
+; (if (eq offset 'attention) (setq offset cell))
(setq reftex-active-toc cell)
(insert (concat toc-indent (nth 2 cell) "\n"))
(setq to (point))
@@ -244,7 +269,8 @@ During a selection process, these are the local bindings.
;; Yes we want this one
(incf cnt)
- (if (eq offset 'attention) (setq offset cell))
+ (setq prev-inserted cell)
+; (if (eq offset 'attention) (setq offset cell))
(setq label (concat xr-prefix label))
(when comment (setq label (concat "% " label)))
@@ -278,7 +304,8 @@ During a selection process, these are the local bindings.
(when (and index-entries
(or (eq t index-entries)
(string= index-entries (nth 1 cell))))
- (if (eq offset 'attention) (setq offset cell))
+ (setq prev-inserted cell)
+; (if (eq offset 'attention) (setq offset cell))
(setq index-tag (format "<%s>" (nth 1 cell)))
(and font
(put-text-property 0 (length index-tag)
@@ -301,7 +328,13 @@ During a selection process, these are the local bindings.
(when mouse-face
(put-text-property from (1- to)
'mouse-face mouse-face))
- (goto-char to)))))
+ (goto-char to))))
+
+ (if (eq cell here-I-am)
+ (setq offset 'attention))
+ (if (and prev-inserted (eq offset 'attention))
+ (setq offset prev-inserted))
+ )
(when (reftex-refontify)
;; we need to fontify the buffer
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)
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index dca2dc95517..f2c94336cff 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -265,6 +265,26 @@ This variable can be changed from within the *toc* buffer with the `t' key."
:group 'reftex-table-of-contents-browser
:type 'integer)
+(defcustom reftex-part-resets-chapter nil
+ "*Non-nil means, \\part is like any other sectioning command.
+This means, part numbers will be included in the numbering of chapters, and
+chapter counters will be reset for each part.
+When nil (the default), parts are special, do not reset the chapter counter
+and also do not show up in chapter numbers."
+ :group 'reftex-table-of-contents-browser
+ :type 'boolean)
+
+
+(defcustom reftex-auto-recenter-toc nil
+ "*Non-nil means, initially turn automatic recentering of toc on.
+When active, the *TOC* buffer will always show the section you
+are currently working in. Recentering happens whenever Emacs is idle for
+more than `reftex-idle-time' seconds.
+This feature can be turned on and off from the menu
+(Ref->Options)."
+ :group 'reftex-table-of-contents-browser
+ :type 'boolean)
+
(defcustom reftex-toc-split-windows-horizontally nil
"*Non-nil means, create TOC window by splitting window horizontally."
:group 'reftex-table-of-contents-browser
@@ -1298,12 +1318,12 @@ which subgroup of the match should be highlighted."
(defcustom reftex-auto-view-crossref t
"*Non-nil means, initially turn automatic viewing of crossref info on.
Automatic viewing of crossref info normally uses the echo area.
-Whenever point is on the argument of a \\ref or \\cite macro, and no
-other message is being displayed, the echo area will display
-information about that cross reference. You can also set the variable
-to the symbol `window'. In this case a small temporary window is
-used for the display.
-This feature can be turned on and of from the menu
+Whenever point is idle for more than `reftex-idle-time' seconds on the
+argument of a \\ref or \\cite macro, and no other message is being
+displayed, the echo area will display information about that cross
+reference. You can also set the variable to the symbol `window'. In
+this case a small temporary window is used for the display.
+This feature can be turned on and off from the menu
(Ref->Options)."
:group 'reftex-viewing-cross-references
:type '(choice (const :tag "off" nil)
@@ -1311,7 +1331,8 @@ This feature can be turned on and of from the menu
(const :tag "in Other Window" window)))
(defcustom reftex-idle-time 1.2
- "*Time (secs) Emacs has to be idle before automatic crossref display is done."
+ "*Time (secs) Emacs has to be idle before automatic crossref display is done.
+Applies also to toc recentering."
:group 'reftex-viewing-cross-references
:type 'number)
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 877352d4f2e..c05230c5dd9 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -327,8 +327,12 @@
(modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
(modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
+;; The following definitions are out of place, but I need them here
+;; to make the compilation of reftex-mode not complain.
(defvar reftex-auto-view-crossref-timer nil
"The timer used for auto-view-crossref.")
+(defvar reftex-toc-auto-recenter-timer nil
+ "The idle timer used to recenter the toc window.")
;;;###autoload
(defun turn-on-reftex ()
@@ -381,6 +385,10 @@ on the menu bar.
(and reftex-auto-view-crossref
(reftex-toggle-auto-view-crossref))
(put 'reftex-auto-view-crossref 'initialized t))
+ (unless (get 'reftex-auto-recenter-toc 'initialized)
+ (and reftex-auto-recenter-toc
+ (reftex-toggle-auto-toc-recenter))
+ (put 'reftex-auto-recenter-toc 'initialized t))
;; Prepare the special syntax tables.
(setq reftex-syntax-table (copy-syntax-table (syntax-table)))
@@ -695,8 +703,6 @@ the label information is recompiled on next use."
(defvar reftex-callback-fwd t)
(defvar reftex-last-toc-master nil
"Stores the name of the tex file that `reftex-toc' was last run on.")
-(defvar reftex-auto-view-crossref-timer nil
- "The timer used for auto-view-crossref.")
;; Marker for return point from recursive edit
(defvar reftex-recursive-edit-marker (make-marker))
@@ -1641,14 +1647,18 @@ When DIE is non-nil, throw an error if file not found."
"Make a fancyref \\Fref reference." t)
(autoload 'reftex-show-label-location "reftex-ref")
(autoload 'reftex-query-label-type "reftex-ref")
-
+(autoload 'reftex-goto-label "reftex-ref"
+ "Prompt for label name and go to that location." t)
;;; =========================================================================
;;;
;;; Table of contents
(autoload 'reftex-toc "reftex-toc"
- "Show the table of contents for the current document." t)
+ "Show the table of contents for the current document." t)
+(autoload 'reftex-toc-recenter "reftex-toc"
+ "Display the TOC window and highlight line corresponding to current position." t)
+(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" t)
;;; =========================================================================
@@ -2313,7 +2323,7 @@ IGNORE-WORDS List of words which should be removed from the string."
(if (featurep 'xemacs) (require 'overlay))
;; We keep a vector with several different overlays to do our highlighting.
-(defvar reftex-highlight-overlays [nil nil])
+(defvar reftex-highlight-overlays [nil nil nil])
;; Initialize the overlays
(aset reftex-highlight-overlays 0 (make-overlay 1 1))
@@ -2322,6 +2332,9 @@ IGNORE-WORDS List of words which should be removed from the string."
(aset reftex-highlight-overlays 1 (make-overlay 1 1))
(overlay-put (aref reftex-highlight-overlays 1)
'face reftex-cursor-selected-face)
+(aset reftex-highlight-overlays 2 (make-overlay 1 1))
+(overlay-put (aref reftex-highlight-overlays 2)
+ 'face reftex-cursor-selected-face)
;; Two functions for activating and deactivation highlight overlays
(defun reftex-highlight (index begin end &optional buffer)
@@ -2344,6 +2357,7 @@ IGNORE-WORDS List of words which should be removed from the string."
;; The default bindings in the mode map.
(loop for x in
'(("\C-c=" . reftex-toc)
+ ("\C-c-" . reftex-toc-recenter)
("\C-c(" . reftex-label)
("\C-c)" . reftex-reference)
("\C-c[" . reftex-citation)
@@ -2393,6 +2407,7 @@ IGNORE-WORDS List of words which should be removed from the string."
"Menu used in RefTeX mode"
`("Ref"
["Table of Contents" reftex-toc t]
+ ["Recenter TOC" reftex-toc-recenter t]
"--"
["\\label" reftex-label t]
["\\ref" reftex-reference t]
@@ -2414,14 +2429,13 @@ IGNORE-WORDS List of words which should be removed from the string."
["Entire Document" reftex-parse-all t]
["Save to File" (reftex-access-parse-file 'write)
(> (length (symbol-value reftex-docstruct-symbol)) 0)]
- ["Restore from File" (reftex-access-parse-file 'restore) t]
- "--"
- ["Reset RefTeX Mode" reftex-reset-mode t])
+ ["Restore from File" (reftex-access-parse-file 'restore) t])
("Global Actions"
["Search Whole Document" reftex-search-document t]
["Replace in Document" reftex-query-replace-document t]
["Grep on Document" reftex-grep-document t]
"--"
+ ["Goto Label" reftex-goto-label t]
["Find Duplicate Labels" reftex-find-duplicate-labels t]
["Change Label and Refs" reftex-change-label t]
["Renumber Simple Labels" reftex-renumber-simple-labels t]
@@ -2439,6 +2453,10 @@ IGNORE-WORDS List of words which should be removed from the string."
(setq reftex-save-parse-info (not reftex-save-parse-info))
:style toggle :selected reftex-save-parse-info]
"--"
+ "TOC RECENTER"
+ ["Automatic Recenter" reftex-toggle-auto-toc-recenter
+ :style toggle :selected reftex-toc-auto-recenter-timer]
+ "--"
"CROSSREF INFO"
["Automatic Info" reftex-toggle-auto-view-crossref
:style toggle :selected reftex-auto-view-crossref-timer]
@@ -2492,6 +2510,8 @@ IGNORE-WORDS List of words which should be removed from the string."
(list 'quote 'reftex-index-macros-style)))))
reftex-index-macros-builtin))
"--"
+ ["Reset RefTeX Mode" reftex-reset-mode t]
+ "--"
("Customize"
["Browse RefTeX Group" reftex-customize t]
"--"