Commits

Anonymous committed 25ed259

Update to RefTeX 4.19

  • Participants
  • Parent commits 8891a2a

Comments (0)

Files changed (10)

-This is the CHANGES file of the RefTeX distribution, version VERSIONTAG 
+This is the CHANGES file of the RefTeX distribution, version 4.19 
 
 Here are the more important changes made to RefTeX since initial release.
 Minor bug fixes are not mentioned.
 
+Version 4.19
+   - New command reftex-toc-recenter (C-c -) which shows the current
+     section in the TOC buffer without selecting the TOC window.
+   - recentering happens automatically in idle time when the option
+     `reftex-auto-recenter-toc' is turned on.
+   - Fixed several bugs related to cursor positioning in the TOC
+     buffer.
+   - The highlight in the TOC buffer stays when the focus moves to a
+     different window.
+   - New command `reftex-goto-label'.
+   - Part numbers are no longer included in chapter numbers, and a new
+     part does not reset the chapter counter.  See new option
+     `reftex-part-resets-chapter'.
+
 Version 4.18
    - `reftex-citation' uses the word before the cursor as a default
      search string.
    - simplified several regular expressions for speed.
-   - Better support for chapterbib
+   - Better support for chapterbib.  Different chapters can now use
+     BibTeX or an explicit `thebibliography' environment.
 
 Version 4.17
    - The toc window can be split off horizontally.  See new options
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.27
-AUTHOR_VERSION = 4.18
+AUTHOR_VERSION = 4.19
 MAINTAINER = Carsten Dominik <dominik@science.uva.nl>
 PACKAGE = reftex
 PKG_TYPE = regular

File reftex-index.el

 (require 'reftex)
 ;;;
 
-(defvar mark-active)
-(defvar zmacs-regions)
-(defvar transient-mark-mode)
 (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

File reftex-parse.el

   ;; 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)
                           (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)
                          (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)
   ;; 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 
       (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

File reftex-ref.el

 		   (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) ",")
 (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

File reftex-sel.el

   ;; 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))
 		  (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
 					   '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
       (incf index)
       (setq from (point))
 
-      (if (eq cell here-I-am) (setq offset 'attention))
-
       (cond
 
        ((memq (car cell) '(bib thebib label-numbers appendix
        ((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))
         ;; 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))
 
           ;; 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)))
 	(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)
 	  (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

File reftex-toc.el

 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').
 	 (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)
     (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
     (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)
           (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)
    (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)
       (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)
 	("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)

File reftex-vars.el

   :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
 (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)
 		 (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)
 
   (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 ()
 	  (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)))
 (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))
 
   "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)
 
 
 ;;; =========================================================================
 (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))
 (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)
 ;; 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)
  "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]
     ["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]
      (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]
 		      (list 'quote 'reftex-index-macros-style)))))
        reftex-index-macros-builtin))
    "--"
+    ["Reset RefTeX Mode"       reftex-reset-mode t]
+   "--"
    ("Customize"
     ["Browse RefTeX Group" reftex-customize t]
     "--"
 \input texinfo  @c -*-texinfo-*-
 @c %**start of header
-@setfilename reftex
+/reftex
 @settitle RefTeX User Manual
 @dircategory Emacs
 @direntry
 @synindex ky cp
 @syncodeindex vr cp
 @syncodeindex fn cp
-@set VERSION 4.18
-@set EDITION 4.18
-@set DATE July 2002
+@set VERSION 4.19
+@set EDITION 4.19
+@set DATE August 2002
 @c %**end of header
 @finalout
 
 additional customizations will be necessary.@refill
 
 @item
-@b{Useful Settings}@* To make @b{Ref@TeX{}} faster for large documents,
-try these:@refill
-@lisp
-(setq reftex-enable-partial-scans t)
-(setq reftex-save-parse-info t)
-(setq reftex-use-multiple-selection-buffers t)
-@end lisp
-
-To integrate with AUCTeX, use
+@b{Useful Settings}@*
+To integrate RefTeX with AUCTeX, use
 @lisp
 (setq reftex-plug-into-AUCTeX t)
 @end lisp
 Show calling point in another window.  This is the point from where
 @code{reftex-toc} was last called.
 
+@page
 @tablesubheading{Exiting}
 @item q
 Hide the @file{*toc*} buffer, return to the position where
 package)}), @b{Ref@TeX{}} will switch to one of the external
 documents.@refill
 
+@item a
+Toggle the automatic recentering of the @file{*toc*} buffer.  When this
+option is on, moving around in the document will cause the @file{*toc*}
+to always highlight the current section.  This can be enabled by default
+with the variable @code{reftex-auto-recenter-toc}.
+
 @end table
 
 @vindex reftex-toc-map
 In order to define additional commands for the @file{*toc*} buffer, the
 keymap @code{reftex-toc-map} may be used.@refill
 
+@findex reftex-toc-recenter
+@vindex reftex-auto-recenter-toc
+@vindex reftex-idle-time
+@cindex @file{*toc*} buffer, recentering
+@cindex Table of contents buffer, recentering
+@kindex C-c -
+If you call @code{reftex-toc} while the @file{*toc*} buffer already
+exists, the cursor will immediately jump to the right place, i.e. the
+section from which @code{reftex-toc} was called will be highlighted.
+The command @kbd{C-c -} (@code{reftex-toc-recenter}) will only redisplay
+the @file{*toc*} buffer and highlight the correct line without actually
+selecting the @file{*toc*} window.  This can be useful to quickly find
+out where in the document you currently are.  If you want the TOC buffer
+to show the current section automatically whenever you stop typing, try
+@lisp
+(setq reftex-auto-recenter-toc t)
+@end lisp
+When this is turned on, the toc buffer will be recentered whenever Emacs
+is idle for more than @code{reftex-idle-time} seconds.
+
+
 @cindex Sectioning commands
 @cindex KOMA-Script, LaTeX classes
 @cindex LaTeX classes, KOMA-Script
 @kindex C-c &
 @kindex S-mouse-2
 
-When point is idle on the argument of a @code{\ref} macro, the echo area
-will display some information about the label referenced there.  Note
-that the information is only displayed if the echo area is not occupied
-by a different message.  
+When point is idle for more than @code{reftex-idle-time} seconds on the
+argument of a @code{\ref} macro, the echo area will display some
+information about the label referenced there.  Note that the information
+is only displayed if the echo area is not occupied by a different
+message.
 
 @b{Ref@TeX{}} can also display the label definition corresponding to a
 @code{\ref} macro, or all reference locations corresponding to a
 @findex reftex-view-crossref
 @findex reftex-mouse-view-crossref
 
-When point is idle on the argument of a @code{\cite} macro, the echo area
-will display some information about the article cited there.  Note
-that the information is only displayed if the echo area is not occupied
-by a different message.  
+When point is idle for more than @code{reftex-idle-time} seconds on the
+argument of a @code{\cite} macro, the echo area will display some
+information about the article cited there.  Note that the information is
+only displayed if the echo area is not occupied by a different message.
 
 @b{Ref@TeX{}} can also display the @code{\bibitem} or BibTeX database
 entry corresponding to a @code{\cite} macro, or all citation locations
 Here is a summary of the available key bindings.
 
 @kindex C-c =
+@kindex C-c -
 @kindex C-c (
 @kindex C-c )
 @kindex C-c [
 @kindex C-c >
 @example
 @kbd{C-c =}      @code{reftex-toc}
+@kbd{C-c -}      @code{reftex-toc-recenter}
 @kbd{C-c (}      @code{reftex-label}
 @kbd{C-c )}      @code{reftex-reference}
 @kbd{C-c [}      @code{reftex-citation}
 @section Optimizations
 @cindex Optimizations
 
+@b{Note added 2002.  Computers have gotten a lot faster, so most of the
+optimizations discussed below will not be necessary on new machines.  I
+am leaving this stuff in the manual for people who want to write thick
+books, where some of it still might be useful.}
+
 Implementing the principle of least surprises, the default settings of
 @b{Ref@TeX{}} ensure a safe ride for beginners and casual users.  However,
 when using @b{Ref@TeX{}} for a large project and/or on a small computer,
 developing it with their reports.  In particular thanks to @i{Fran
 Burstall, Alastair Burt, Lars Clausen, Soren Dayton, Stephen Eglen, Karl
 Eichwalder, Erik Frik, Erik Frisk, Peter Galbraith, Kai Grossjohann,
-Frank Harrell, Stephan Heuel, Alan Ho, Dieter Kraft, Adrian Lanz, Rory
-Molinari, Stefan Monnier, Laurent Mugnier, Sudeep Kumar Palat, Daniel
-Polani, Alan Shutko, Robin Socha, Richard Stanton, Allan Strand, Jan
-Vroonhof, Christoph Wedler, Alan Williams, Roland Winkler, Eli
-Zaretskii}.@refill
+Frank Harrell, Stephan Heuel, Alan Ho, Lute Kamstra, Dieter Kraft,
+Adrian Lanz, Rory Molinari, Stefan Monnier, Laurent Mugnier, Sudeep
+Kumar Palat, Daniel Polani, Alan Shutko, Robin Socha, Richard Stanton,
+Allan Strand, Jan Vroonhof, Christoph Wedler, Alan Williams, Roland
+Winkler, Eli Zaretskii}.@refill
 
 The @code{view-crossref} feature was inspired by @i{Peter Galbraith's}
 @file{bib-cite.el}.@refill
 active TAGS table is required.@refill
 @end deffn
 
+@deffn Command reftex-goto-label
+Prompt for a label (with completion) and jump to the location of this
+label.  Optional prefix argument @var{other-window} goes to the label in
+another window.
+@end deffn
+
+
 @deffn Command reftex-change-label
 Query replace @var{from} with @var{to} in all @code{\label} and
 @code{\ref} commands.  Works on the entire multifile document.  No
 changed from within the @file{*toc*} buffer with the @kbd{t} key.@refill
 @end defopt
 
+@defopt reftex-part-resets-chapter
+Non-@code{nil} means, @code{\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 @code{nil} (the default), parts are special, do not reset the
+chapter counter and also do not show up in chapter numbers.
+@end defopt
+
+@defopt reftex-auto-recenter-toc
+Non-@code{nil} means, initially turn automatic recentering of toc on.
+When active, the @file{*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).
+@end defopt
+
 @defopt reftex-toc-split-windows-horizontally
 Non-@code{nil} means, create TOC window by splitting window
 horizontally.  The default is to split vertically.
 @defopt reftex-auto-view-crossref
 Non-@code{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 @code{\ref} or @code{\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 @code{window}.  In this case a small temporary
-window is used for the display.  This feature can be turned on and of
-from the menu (Ref->Options).@refill
+Whenever point is idle for more than @code{reftex-idle-time} seconds on
+the argument of a @code{\ref} or @code{\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
+@code{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).@refill
 @end defopt
 
 @defopt reftex-idle-time
-Time (secs) Emacs has to be idle before automatic crossref display is
-done.@refill
+Time (secs) Emacs has to be idle before automatic crossref display 
+or toc recentering is done.@refill
 @end defopt
 
 @defopt reftex-cite-view-format
 @item
 Reading a parse file now checks consistency.
 @end itemize
-@end ignore
 @noindent @b{Version 4.00}
 @itemize @bullet
 @item
 @item
 Improved interaction with Emacs LaTeX mode.
 @end itemize
+@end ignore
 @noindent @b{Version 4.17}
 @itemize @bullet
 @item 
 @item
 Better support for chapterbib.
 @end itemize
+@noindent @b{Version 4.19}
+@itemize @bullet
+@item
+New command `reftex-toc-recenter' (@kbd{C-c -}) which shows the current
+section in the TOC buffer without selecting the TOC window.
+@item
+Recentering happens automatically in idle time when the option
+@code{reftex-auto-recenter-toc} is turned on.
+@item
+Fixed several bugs related to automatic cursor positioning in the TOC
+buffer.
+@item
+The highlight in the TOC buffer stays when the focus moves to a
+different window.
+@item
+New command `reftex-goto-label'.
+@item
+Part numbers are no longer included in chapter numbers, and a new
+part does not reset the chapter counter.  See new option
+@code{reftex-part-resets-chapter}.
+@end itemize
 
 @node Index,  , , Top
 @unnumbered Index