changeset 65548:253cad16882d

Little fixes to remove compiler warnings reftex-index.el (reftex-query-index-phrase): More efficient use of markers.
author Carsten Dominik <dominik@science.uva.nl>
date Fri, 16 Sep 2005 10:01:33 +0000
parents da6fcded2062
children 7b474cdf139d
files lisp/textmodes/reftex-auc.el lisp/textmodes/reftex-cite.el lisp/textmodes/reftex-dcr.el lisp/textmodes/reftex-global.el lisp/textmodes/reftex-index.el lisp/textmodes/reftex-parse.el lisp/textmodes/reftex-ref.el lisp/textmodes/reftex-sel.el lisp/textmodes/reftex-toc.el lisp/textmodes/reftex-vars.el lisp/textmodes/reftex.el
diffstat 11 files changed, 383 insertions(+), 389 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/reftex-auc.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-auc.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-auc.el --- RefTeX's interface to AUCTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -76,7 +75,7 @@
 
 
 (defun reftex-arg-index-tag (optional &optional prompt &rest args)
-  "Prompt for an index tag with completion.
+  "Prompt for an index tag with completion. 
 This is the name of an index, not the entry."
   (let (tag taglist)
     (setq prompt (concat (if optional "(Optional) " "")
@@ -86,8 +85,8 @@
         ;; Use RefTeX completion
         (progn
           (reftex-access-scan-info nil)
-          (setq taglist
-                (cdr (assoc 'index-tags
+          (setq taglist 
+                (cdr (assoc 'index-tags 
                             (symbol-value reftex-docstruct-symbol)))
                 tag (completing-read prompt (mapcar 'list taglist))))
       ;; Just ask like AUCTeX does.
@@ -132,7 +131,7 @@
   ;; Replace AUCTeX functions with RefTeX functions.
   ;; Which functions are replaced is controlled by the variable
   ;; `reftex-plug-into-AUCTeX'.
-
+  
   (if (reftex-plug-flag 0)
       (setq LaTeX-label-function 'reftex-label)
     (setq LaTeX-label-function nil))
@@ -144,11 +143,11 @@
   (and (reftex-plug-flag 3)
        (fboundp 'TeX-arg-cite)
        (fset 'TeX-arg-cite 'reftex-arg-cite))
-
-  (and (reftex-plug-flag 4)
+  
+  (and (reftex-plug-flag 4) 
        (fboundp 'TeX-arg-index-tag)
        (fset 'TeX-arg-index-tag 'reftex-arg-index-tag))
-  (and (reftex-plug-flag 4)
+  (and (reftex-plug-flag 4) 
        (fboundp 'TeX-arg-index)
        (fset 'TeX-arg-index 'reftex-arg-index)))
 
--- a/lisp/textmodes/reftex-cite.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-cite.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-cite.el --- creating citations with RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -70,7 +69,7 @@
   (unless (eq (get 'reftex-default-bibliography :reftex-raw)
               reftex-default-bibliography)
     (put 'reftex-default-bibliography :reftex-expanded
-         (reftex-locate-bibliography-files
+         (reftex-locate-bibliography-files 
           default-directory reftex-default-bibliography))
     (put 'reftex-default-bibliography :reftex-raw
          reftex-default-bibliography))
@@ -129,7 +128,7 @@
   ;; If RETURN is non-nil, just return the entry.
 
   (let* ((re
-          (if item
+          (if item 
               (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
             (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
                     "[, \t\r\n}]")))
@@ -151,7 +150,7 @@
           (when return
             ;; Just return the relevant entry
             (if item (goto-char (match-end 0)))
-            (setq return (buffer-substring
+            (setq return (buffer-substring 
                           (point) (reftex-end-of-bib-entry item)))
             (set-buffer buffer-conf)
             (throw 'exit return))
@@ -167,9 +166,9 @@
         (error "No BibTeX entry with citation key %s" key)))))
 
 (defun reftex-end-of-bib-entry (item)
-  (save-excursion
+  (save-excursion 
     (condition-case nil
-        (if item
+        (if item 
             (progn (end-of-line)
                    (re-search-forward
                     "\\\\bibitem\\|\\end{thebibliography}")
@@ -190,16 +189,16 @@
 
     ;; Read a regexp, completing on known citation keys.
     (setq default (regexp-quote (reftex-get-bibkey-default)))
-    (setq re-list
-          (split-string
-           (completing-read
+    (setq re-list 
+          (split-string 
+           (completing-read 
             (concat
              "Regex { && Regex...}: "
              "[" default "]: ")
             (if reftex-mode
                 (if (fboundp 'LaTeX-bibitem-list)
                     (LaTeX-bibitem-list)
-                  (cdr (assoc 'bibview-cache
+                  (cdr (assoc 'bibview-cache 
                               (symbol-value reftex-docstruct-symbol))))
               nil)
             nil nil nil 'reftex-cite-regexp-hist)
@@ -246,7 +245,7 @@
                    (error (goto-char key-point)
                           (throw 'search-again nil)))
                  (setq end-point (point))
-
+                 
                  ;; Ignore @string, @comment and @c entries or things
                  ;; outside entries
                  (when (or (string= (downcase (match-string 2)) "string")
@@ -255,12 +254,12 @@
                            (< (point) key-point)) ; this means match not in {}
                    (goto-char key-point)
                    (throw 'search-again nil))
-
+                 
                  ;; Well, we have got a match
                  ;;(setq entry (concat
                  ;;             (buffer-substring start-point (point)) "\n"))
                  (setq entry (buffer-substring start-point (point)))
-
+                 
                  ;; Check if other regexp match as well
                  (setq re-list rest-re)
                  (while re-list
@@ -268,24 +267,24 @@
                      ;; nope - move on
                      (throw 'search-again nil))
                    (pop re-list))
-
+                 
                  (setq alist (reftex-parse-bibtex-entry
                               nil start-point end-point))
                  (push (cons "&entry" entry) alist)
-
+                 
                  ;; check for crossref entries
                  (if (assoc "crossref" alist)
                      (setq alist
                            (append
                             alist (reftex-get-crossref-alist alist))))
-
+                 
                  ;; format the entry
                  (push (cons "&formatted" (reftex-format-bib-entry alist))
                        alist)
-
+                 
                  ;; make key the first element
                  (push (reftex-get-bib-field "&key" alist) alist)
-
+                 
                  ;; add it to the list
                  (push alist found-list)))))
           (reftex-kill-temporary-buffers))))
@@ -348,7 +347,7 @@
     (unless files
       (error "Need file name to find thebibliography environment"))
     (while (setq file (pop files))
-      (setq buf (reftex-get-file-buffer-force
+      (setq buf (reftex-get-file-buffer-force 
                  file (not reftex-keep-temporary-buffers)))
       (unless buf
         (error "No such file %s" file))
@@ -359,21 +358,21 @@
         (save-restriction
           (widen)
           (goto-char (point-min))
-          (while (re-search-forward
+          (while (re-search-forward 
                   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
             (beginning-of-line 2)
             (setq start (point))
-            (if (re-search-forward
+            (if (re-search-forward 
                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
                 (progn
                   (beginning-of-line 1)
                   (setq end (point))))
             (when (and start end)
-              (setq entries
+              (setq entries 
                     (append entries
                       (mapcar 'reftex-parse-bibitem
                         (delete ""
-                                (split-string
+                                (split-string 
                                  (buffer-substring-no-properties start end)
                                  "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
             (goto-char end)))))
@@ -382,16 +381,16 @@
 
     ;; Read a regexp, completing on known citation keys.
     (setq default (regexp-quote (reftex-get-bibkey-default)))
-    (setq re-list
-          (split-string
-           (completing-read
+    (setq re-list 
+          (split-string 
+           (completing-read 
             (concat
              "Regex { && Regex...}: "
              "[" default "]: ")
             (if reftex-mode
                 (if (fboundp 'LaTeX-bibitem-list)
                     (LaTeX-bibitem-list)
-                  (cdr (assoc 'bibview-cache
+                  (cdr (assoc 'bibview-cache 
                               (symbol-value reftex-docstruct-symbol))))
               nil)
             nil nil nil 'reftex-cite-regexp-hist)
@@ -404,14 +403,14 @@
         (error "Empty regular expression"))
 
     (while (and (setq re (pop re-list)) entries)
-      (setq entries
+      (setq entries 
             (delq nil (mapcar
                        (lambda (x)
                          (if (string-match re (cdr (assoc "&entry" x)))
                              x nil))
                        entries))))
-    (setq entries
-          (mapcar
+    (setq entries 
+          (mapcar 
             (lambda (x)
               (push (cons "&formatted" (reftex-format-bibitem x)) x)
               (push (reftex-get-bib-field "&key" x) x)
@@ -632,7 +631,6 @@
   ;; This really does the work of reftex-citation.
 
   (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
-         (start 0)
          (docstruct-symbol reftex-docstruct-symbol)
          (selected-entries (reftex-offer-bib-menu))
          (insert-entries selected-entries)
@@ -655,9 +653,9 @@
       ;; FIXME: Unfortunately, this meens that commenting does not work right.
       (pop selected-entries)
       (let ((concat-keys (mapconcat 'car selected-entries ",")))
-        (setq insert-entries
+        (setq insert-entries 
               (list (list concat-keys (cons "&key" concat-keys))))))
-
+    
     (unless no-insert
 
       ;; We shall insert this into the buffer...
@@ -684,7 +682,7 @@
         ;; it has to go.  If there is only a single arg and empty, it can go
         ;; as well.
         (when reftex-cite-cleanup-optional-args
-          (cond
+          (cond 
            ((string-match "\\([a-zA-Z0-9]\\)\\[\\]{" string)
             (setq string (replace-match "\\1{" nil nil string)))
            ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string)
@@ -699,14 +697,14 @@
         (delete-char 1))
 
       ;; Tell AUCTeX
-      (when (and reftex-mode
+      (when (and reftex-mode 
                  (fboundp 'LaTeX-add-bibitems)
                  reftex-plug-into-AUCTeX)
         (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
-
+      
       ;; Produce the cite-view strings
       (when (and reftex-mode reftex-cache-cite-echo cite-view)
-        (mapcar (lambda (entry)
+        (mapcar (lambda (entry) 
                   (reftex-make-cite-echo-string entry docstruct-symbol))
                 selected-entries))
 
@@ -714,16 +712,16 @@
 
     (set-marker reftex-select-return-marker nil)
     (reftex-kill-buffer "*RefTeX Select*")
-
+    
     ;; Check if the prefix arg was numeric, and call recursively
     (when (integerp arg)
       (if (> arg 1)
-          (progn
+          (progn      
             (skip-chars-backward "}")
             (decf arg)
             (reftex-do-citation arg))
         (forward-char 1)))
-
+    
     ;; Return the citation key
     (car (car selected-entries))))
 
@@ -737,7 +735,7 @@
      (no-insert
       ;; Format does not really matter because nothing will be inserted.
       (setq format "%l"))
-
+     
      ((and (stringp macro)
            (string-match "\\`\\\\cite\\|cite\\'" macro))
       ;; We are already inside a cite macro
@@ -758,7 +756,7 @@
       (when (listp format)
         (setq key
               (or format-key
-                  (reftex-select-with-char
+                  (reftex-select-with-char 
                    "" (concat "SELECT A CITATION FORMAT\n\n"
                               (mapconcat
                                (lambda (x)
@@ -787,8 +785,8 @@
 
   (let ((bibtype (reftex-bib-or-thebib))
         found-list rtn key data selected-entries)
-    (while
-        (not
+    (while 
+        (not 
          (catch 'done
            ;; Scan bibtex files
            (setq found-list
@@ -803,20 +801,20 @@
                 (reftex-extract-bib-entries-from-thebibliography
                  (reftex-uniquify
                   (mapcar 'cdr
-                          (reftex-all-assq
+                          (reftex-all-assq 
                            'thebib (symbol-value reftex-docstruct-symbol))))))
                (reftex-default-bibliography
                 (message "Using default bibliography")
                 (reftex-extract-bib-entries (reftex-default-bibliography)))
                (t (error "No valid bibliography in this document, and no default available"))))
-
+           
            (unless found-list
              (error "Sorry, no matches found"))
-
+    
           ;; Remember where we came from
           (setq reftex-call-back-to-this-buffer (current-buffer))
           (set-marker reftex-select-return-marker (point))
-
+    
           ;; Offer selection
           (save-window-excursion
             (delete-other-windows)
@@ -857,15 +855,15 @@
                 (goto-char 1))
                ((eq key ?A)
                 ;; Take all (marked)
-                (setq selected-entries
+                (setq selected-entries 
                       (if reftex-select-marked
                           (mapcar 'car (nreverse reftex-select-marked))
                         found-list))
                 (throw 'done t))
                ((eq key ?a)
                 ;; Take all (marked), and push the symbol 'concat
-                (setq selected-entries
-                      (cons 'concat
+                (setq selected-entries 
+                      (cons 'concat 
                             (if reftex-select-marked
                                 (mapcar 'car (nreverse reftex-select-marked))
                               found-list)))
@@ -884,9 +882,9 @@
                ((or (eq key ?\C-m)
                     (eq key 'return))
                 ;; Take selected
-                (setq selected-entries
+                (setq selected-entries 
                       (if reftex-select-marked
-                          (cons 'concat
+                          (cons 'concat 
                                 (mapcar 'car (nreverse reftex-select-marked)))
                         (if data (list data) nil)))
                 (throw 'done t))
@@ -926,7 +924,7 @@
   (let ((file (read-file-name "File to create: ")))
     (find-file-other-window file)
     (if (> (buffer-size) 0)
-        (unless (yes-or-no-p
+        (unless (yes-or-no-p 
                  (format "Overwrite non-empty file %s? " file))
           (error "Abort")))
     (erase-buffer)
@@ -951,7 +949,7 @@
              reftex-mouse-selected-face
            nil))
         tmp len)
-    (mapcar
+    (mapcar 
      (lambda (x)
        (setq tmp (cdr (assoc "&formatted" x))
              len (length tmp))
@@ -1046,7 +1044,7 @@
 (defun reftex-make-cite-echo-string (entry docstruct-symbol)
   ;; Format a bibtex entry for the echo area and cache the result.
   (let* ((key (reftex-get-bib-field "&key" entry))
-         (string
+         (string 
           (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
             (reftex-format-citation entry reftex-cite-view-format)))
          (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
@@ -1088,7 +1086,7 @@
           (setq bibfile-list
                 (reftex-uniquify
                  (mapcar 'cdr
-                         (reftex-all-assq
+                         (reftex-all-assq 
                           'thebib (symbol-value reftex-docstruct-symbol))))
                 item t))
          (reftex-default-bibliography
@@ -1099,16 +1097,16 @@
         (setq bibfile-list (reftex-visited-files bibfile-list)))
 
       (condition-case nil
-          (reftex-pop-to-bibtex-entry
+          (reftex-pop-to-bibtex-entry 
            key bibfile-list (not reftex-keep-temporary-buffers) t item)
         (error (ding))))
-
+      
     (select-window win)))
 
 ;;; Global BibTeX file
 (defun reftex-all-used-citation-keys ()
   (reftex-access-scan-info)
-  (let ((files (reftex-all-document-files)) file keys kkk kk k)
+  (let ((files (reftex-all-document-files)) file keys kk k)
     (save-excursion
       (while (setq file (pop files))
         (set-buffer (reftex-get-file-buffer-force file 'mark))
@@ -1131,7 +1129,7 @@
   "Create a new BibTeX database file with all entries referenced in document.
 The command prompts for a filename and writes the collected entries to
 that file.  Only entries referenced in the current document with
-any \\cite-like macros are used.
+any \\cite-like macros are used. 
 The sequence in the new file is the same as it was in the old database."
   (interactive "FNew BibTeX file: ")
   (let ((keys (reftex-all-used-citation-keys))
@@ -1145,7 +1143,7 @@
            (save-restriction
              (widen)
              (goto-char (point-min))
-             (while (re-search-forward
+             (while (re-search-forward 
                      "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
                      nil t)
                (setq key (match-string 1)
@@ -1162,7 +1160,7 @@
                        keys (delete key keys)))))))))
     (find-file-other-window bibfile)
     (if (> (buffer-size) 0)
-        (unless (yes-or-no-p
+        (unless (yes-or-no-p 
                  (format "Overwrite non-empty file %s? " bibfile))
           (error "Abort")))
     (erase-buffer)
--- a/lisp/textmodes/reftex-dcr.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-dcr.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 ;;
 
 ;; This file is part of GNU Emacs.
@@ -21,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
--- a/lisp/textmodes/reftex-global.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-global.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-global.el --- operations on entire documents with RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -32,9 +31,6 @@
 (require 'reftex)
 ;;;
 
-(defvar isearch-next-buffer-function)
-(defvar TeX-master)
-
 (defun reftex-create-tags-file ()
   "Create TAGS file by running `etags' on the current document.
 The TAGS file is also immediately visited with `visit-tags-table'."
@@ -103,6 +99,10 @@
     (tags-query-replace from to (or delimited current-prefix-arg)
                         (list 'reftex-all-document-files))))
 
+(eval-when-compile
+  (defvar TeX-master)
+  (defvar isearch-next-buffer-function))
+
 (defun reftex-find-duplicate-labels ()
   "Produce a list of all duplicate labels in the document."
 
@@ -140,7 +140,7 @@
     (set (make-local-variable 'TeX-master) master)
     (erase-buffer)
     (insert "                MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
-    (insert
+    (insert 
      " Move point to label and type `r' to run a query-replace on the label\n"
      " and its references.  Type `q' to exit this buffer.\n\n")
     (insert " LABEL               FILE\n")
@@ -198,8 +198,8 @@
            (not (yes-or-no-p "Replacing all simple labels in multiple files is risky.  Continue? ")))
       (error "Abort"))
   ;; Make the translation list
-  (let* ((re-core (concat "\\("
-                          (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|")
+  (let* ((re-core (concat "\\(" 
+                          (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|") 
                           "\\)"))
          (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
          (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]"))
@@ -232,11 +232,11 @@
     (reftex-save-all-document-buffers)
 
     ;; First test to check for erros
-    (setq n (reftex-translate
+    (setq n (reftex-translate 
              files search-re translate-alist error-fmt 'test))
 
     ;; Now the real thing.
-    (if (yes-or-no-p
+    (if (yes-or-no-p 
          (format "Replace %d items at %d places in %d files? "
                  (length translate-alist) n (length files)))
         (progn
@@ -254,9 +254,9 @@
 
 (defun reftex-translate (files search-re translate-alist error-fmt test)
   ;; In FILES, look for SEARCH-RE and replace match 1 of it with
-  ;; its association in TRANSLATE-ALSIT.
+  ;; its association in TRANSLATE-ALSIT.  
   ;; If we do not find an association and TEST is non-nil, query
-  ;; to ignore the problematic string.
+  ;; to ignore the problematic string.  
   ;; If TEST is nil, it is ignored without query.
   ;; Return the number of replacements.
   (let ((n 0) file label match-data buf macro pos cell)
@@ -282,7 +282,7 @@
                          (or (looking-at "\\\\ref")
                              (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]")
                              (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]")
-                             (looking-at (format
+                             (looking-at (format 
                                           reftex-find-label-regexp-format
                                           (regexp-quote label)))))
                 ;; OK, we should replace it.
@@ -345,7 +345,7 @@
 
 (defun reftex-isearch-wrap-function ()
   (if (not isearch-word)
-      (switch-to-buffer
+      (switch-to-buffer 
        (funcall isearch-next-buffer-function (current-buffer) t)))
   (goto-char (if isearch-forward (point-min) (point-max))))
 
@@ -431,7 +431,7 @@
 `reftex-isearch-minor-mode' on iff ARG is positive."
   (interactive "P")
   (let ((old-reftex-isearch-minor-mode reftex-isearch-minor-mode))
-    (setq reftex-isearch-minor-mode
+    (setq reftex-isearch-minor-mode 
 	  (not (or (and (null arg) reftex-isearch-minor-mode)
 		   (<= (prefix-numeric-value arg) 0))))
     (unless (eq reftex-isearch-minor-mode old-reftex-isearch-minor-mode)
@@ -462,7 +462,7 @@
     ;; Force modeline redisplay.
     (set-buffer-modified-p (buffer-modified-p))))
 
-(add-minor-mode 'reftex-isearch-minor-mode "/I" nil nil
+(add-minor-mode 'reftex-isearch-minor-mode "/I" nil nil 
 		'reftex-isearch-minor-mode)
 
 ;;; arch-tag: 2dbf7633-92c8-4340-8656-7aa019d0f80d
--- a/lisp/textmodes/reftex-index.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-index.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-index.el --- index support with RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -32,13 +31,11 @@
 (require 'reftex)
 ;;;
 
-(defvar reftex-index-phrases-marker)
-(defvar TeX-master)
-
 ;; START remove for XEmacs release
 (defvar mark-active)
 (defvar zmacs-regions)
 (defvar transient-mark-mode)
+(defvar TeX-master)
 ;; 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.
@@ -56,13 +53,13 @@
          (active (if (boundp 'zmacs-regions)
                      (and zmacs-regions (region-exists-p))  ; XEmacs
                    (and transient-mark-mode mark-active)))  ; Emacs
-         (beg (if active
+         (beg (if active 
                   (region-beginning)
-                (save-excursion
+                (save-excursion 
                   (skip-syntax-backward "w\\") (point))))
          (end (if active
                   (region-end)
-                (save-excursion
+                (save-excursion 
                   (skip-syntax-forward "w\\") (point))))
          (sel (buffer-substring beg end))
          (mathp (condition-case nil (texmathp) (error nil)))
@@ -93,7 +90,7 @@
         ;; Delete what is in the buffer and make the index entry
         (delete-region beg end)
         (reftex-index def-char full-entry def-tag sel)))))
-
+  
 (defun reftex-index (&optional char key tag sel no-insert)
   "Query for an index macro and insert it along with its argments.
 The index macros available are those defined in `reftex-index-macro' or
@@ -169,7 +166,7 @@
   ;; OPT-ARGS is a list of optional argument indices, as given by
   ;; `reftex-parse-args'.
   (let* ((opt (and (integerp itag) (member itag opt-args)))
-         (index-tags (cdr (assq 'index-tags
+         (index-tags (cdr (assq 'index-tags 
                                 (symbol-value reftex-docstruct-symbol))))
          (default (reftex-default-index))
          (prompt (concat "Index tag"
@@ -183,17 +180,17 @@
 (defun reftex-index-select-tag ()
   ;; Have the user select an index tag.
   ;; FIXME: should we cache tag-alist, prompt and help?
-  (let* ((index-tags (cdr (assoc 'index-tags
+  (let* ((index-tags (cdr (assoc 'index-tags 
                                  (symbol-value reftex-docstruct-symbol))))
          (default (reftex-default-index)))
-    (cond
+    (cond 
      ((null index-tags)
       (error "No index tags available"))
 
      ((= (length index-tags) 1)
       ;; Just one index, use it
       (car index-tags))
-
+          
      ((> (length index-tags) 1)
       ;; Several indices, ask.
       (let* ((tags (copy-sequence index-tags))
@@ -214,12 +211,12 @@
               (unless (assq (aref tag i) tag-alist)
                 (push (list (aref tag i)
                             tag
-                            (concat (substring tag 0 i)
+                            (concat (substring tag 0 i) 
                                     "[" (substring tag i (incf i)) "]"
                                     (substring tag i)))
                       tag-alist)
                 (throw 'exit t)))
-            (push (list (+ ?0 (incf cnt)) tag
+            (push (list (+ ?0 (incf cnt)) tag 
                         (concat "[" (int-to-string cnt) "]:" tag))
                   tag-alist)))
         (setq tag-alist (nreverse tag-alist))
@@ -234,7 +231,7 @@
                       (if default
                           (format "[^M]  %s (the default)\n" default)
                         "")
-                      (mapconcat (lambda(x)
+                      (mapconcat (lambda(x) 
                                    (apply 'format "[%c]   %s" x))
                                  tag-alist "\n")))
         ;; Query the user for an index-tag
@@ -263,7 +260,7 @@
     key))
 
 (defun reftex-index-update-taglist (newtag)
-  ;; add NEWTAG to the list of available index tags.
+  ;; add NEWTAG to the list of available index tags. 
   (let ((cell (assoc 'index-tags (symbol-value reftex-docstruct-symbol))))
     (and newtag (cdr cell) (not (member newtag (cdr cell)))
          (push newtag (cdr cell)))))
@@ -314,7 +311,7 @@
   (easy-menu-add reftex-index-menu reftex-index-map)
   (add-hook 'post-command-hook 'reftex-index-post-command-hook nil t)
   (add-hook 'pre-command-hook  'reftex-index-pre-command-hook nil t)
-  (run-mode-hooks 'reftex-index-mode-hook))
+  (run-hooks 'reftex-index-mode-hook))
 
 (defconst reftex-index-help
 "                      AVAILABLE KEYS IN INDEX BUFFER
@@ -344,7 +341,7 @@
   ;; Note:  This function just looks for the nearest match of the
   ;; context string and may fail if the entry moved and an identical
   ;; entry is close to the old position.  Frequent rescans make this
-  ;; safer.
+  ;; safer. 
   (let* ((file (nth 3 data))
          (literal (nth 2 data))
          (pos (nth 4 data))
@@ -392,7 +389,7 @@
          (calling-file (buffer-file-name))
          (restriction
           (or overriding-restriction
-              (and (not redo)
+              (and (not redo) 
                    (reftex-get-restriction current-prefix-arg docstruct))))
          (locations
           ;; See if we are on an index macro as initial position
@@ -401,7 +398,7 @@
                      (macro (car what-macro))
                      (here-I-am (when (member macro reftex-macros-with-index)
                                   (save-excursion
-                                    (goto-char (+ (cdr what-macro)
+                                    (goto-char (+ (cdr what-macro) 
                                                   (length macro)))
                                     (reftex-move-over-touching-args)
                                     (reftex-where-am-I)))))
@@ -412,7 +409,7 @@
     (setq buffer-name (reftex-make-index-buffer-name index-tag))
 
     ;; Goto the buffer and put it into the correct mode
-
+                      
     (when (or restriction current-prefix-arg)
          (reftex-kill-buffer buffer-name))
 
@@ -505,7 +502,7 @@
       ;; Delete the entry at place
       (and (bolp) (forward-char 1))
       (delete-region (previous-single-property-change (1+ (point)) :data)
-                     (or (next-single-property-change (point) :data)
+                     (or (next-single-property-change (point) :data) 
                          (point-max))))
 
     ;; Walk through the list and insert all entries
@@ -526,7 +523,7 @@
       (insert indent (nth 7 cell))
       (when font
         (setq to (point))
-        (put-text-property
+        (put-text-property 
          (- (point) (length (nth 7 cell))) to
          'face index-face)
         (goto-char to))
@@ -554,7 +551,7 @@
 (defun reftex-index-insert-new-letter (letter &optional font)
   ;; Start a new section in the index
   (let ((from (point)))
-    (insert "\n" letter letter letter
+    (insert "\n" letter letter letter 
             "-----------------------------------------------------------------")
     (when font
       (put-text-property from (point) 'face reftex-index-section-face))
@@ -631,10 +628,10 @@
   (interactive "p")
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
-  (goto-char (or (next-single-property-change (point) :data)
+  (goto-char (or (next-single-property-change (point) :data) 
                  (point)))
   (unless (get-text-property (point) :data)
-    (goto-char (or (next-single-property-change (point) :data)
+    (goto-char (or (next-single-property-change (point) :data) 
                    (point)))))
 (defun reftex-index-previous (&optional arg)
   "Move to previous selectable item."
@@ -777,7 +774,7 @@
         (reftex-index-restrict-to-section t)
       (setq reftex-index-restriction-indicator (nth 6 bor)
             reftex-index-restriction-data
-            (list bor
+            (list bor 
                   (car (memq (assq 'toc (cdr (memq bor docstruct)))
                              docstruct))))
       (reftex-index-revert))))
@@ -809,7 +806,7 @@
          show-window show-buffer match)
 
     (unless data (error "Don't know which index entry to visit"))
-
+    
     (if (eq (car data) 'index)
         (setq match (reftex-index-show-entry data no-revisit)))
 
@@ -880,7 +877,7 @@
           attr (nth 2 analyze))
     (setf (nth 2 analyze) (if (string= attr bor) "" bor))
     (setq new (apply 'concat analyze))
-    (reftex-index-change-entry
+    (reftex-index-change-entry 
      new (if (string= (nth 2 analyze) bor)
              "Entry is now START-OF-PAGE-RANGE"
            "START-OF-PAGE-RANGE canceled"))))
@@ -938,7 +935,7 @@
           (t (setf (nth n analyze) (concat initial npart))))
     (setq new (apply 'concat analyze))
     ;; Change the entry and insert the changed version into the index.
-    (reftex-index-change-entry
+    (reftex-index-change-entry 
      new (if (string= npart "")
              (format "Deleted: %s" opart)
            (format "New value is: %s" npart)))))
@@ -952,14 +949,14 @@
     (unless data (error "Don't know which index entry to change"))
     (setq old (nth 2 data)
           key (nth 6 data)
-          prefix (completing-read
-                  "Prefix: "
-                  (reftex-sublist-nth
+          prefix (completing-read 
+                  "Prefix: " 
+                  (reftex-sublist-nth 
                    docstruct 6
                    (lambda (x)
                      (and (eq (car x) 'index)
                           (string= (nth 1 x) reftex-index-tag))) t)))
-    (unless (string-match
+    (unless (string-match 
              (concat (regexp-quote (car reftex-index-special-chars)) "\\'")
              prefix)
       (setq prefix (concat prefix (car reftex-index-special-chars))))
@@ -999,7 +996,7 @@
 (defun reftex-index-change-entry (new &optional message)
   ;; Change the full context string of the index entry at point to
   ;; NEW.  This actually edits the buffer where the entry is defined.
-
+  
   (let* ((data (get-text-property (point) :data))
          old beg end info)
     (unless data (error "Cannot change entry"))
@@ -1091,14 +1088,14 @@
       (if (eq char ?!)
           (error "This <%s> index does not contain entries sorted before the letters"
                  reftex-index-tag)
-        (error "This <%s> index does not contain entries starting with `%c'"
+        (error "This <%s> index does not contain entries starting with `%c'" 
                reftex-index-tag char)))))
 
-(easy-menu-define
+(easy-menu-define 
  reftex-index-menu reftex-index-map
  "Menu for Index buffer"
  `("Index"
-   ["Goto section A-Z"
+   ["Goto section A-Z" 
     (message "To go to a section, just press any of: !%s"
              reftex-index-section-letters) t]
    ["Show Entry" reftex-index-view-entry t]
@@ -1138,7 +1135,7 @@
     ["Context" reftex-index-toggle-context :style toggle
      :selected reftex-index-include-context]
     "--"
-    ["Follow Mode" reftex-index-toggle-follow :style toggle
+    ["Follow Mode" reftex-index-toggle-follow :style toggle 
      :selected reftex-index-follow-mode])
    "--"
    ["Help" reftex-index-show-help t]))
@@ -1190,7 +1187,7 @@
   (set-marker reftex-index-return-marker (point))
   (reftex-index-selection-or-word arg 'phrase)
   (if (eq major-mode 'reftex-index-phrases-mode)
-      (message
+      (message 
        (substitute-command-keys
         "Return to LaTeX with \\[reftex-index-phrases-save-and-return]"))))
 
@@ -1219,7 +1216,7 @@
           (sort (copy-sequence reftex-index-macro-alist)
                 (lambda (a b) (equal (car a) default-macro))))
          macro entry key repeat)
-
+    
     (if master (set (make-local-variable 'TeX-master)
                     (file-name-nondirectory master)))
 
@@ -1232,7 +1229,7 @@
       (if (looking-at reftex-index-phrases-comment-regexp)
           (beginning-of-line 2))
       (while (looking-at "^[ \t]*$")
-          (beginning-of-line 2))
+          (beginning-of-line 2))          
       (cond ((fboundp 'zmacs-activate-region) (zmacs-activate-region))
             ((boundp 'make-active) (setq mark-active t)))
       (if (yes-or-no-p "Delete and rebuilt header ")
@@ -1277,6 +1274,7 @@
 
 
 (defvar reftex-index-phrases-menu)
+(defvar reftex-index-phrases-marker)
 (defvar reftex-index-phrases-restrict-file nil)
 ;;;###autoload
 (defun reftex-index-phrases-mode ()
@@ -1308,17 +1306,17 @@
   (setq major-mode 'reftex-index-phrases-mode
         mode-name "Phrases")
   (use-local-map reftex-index-phrases-map)
-  (set (make-local-variable 'font-lock-defaults)
+  (set (make-local-variable 'font-lock-defaults) 
        reftex-index-phrases-font-lock-defaults)
   (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-map)
   (set (make-local-variable 'reftex-index-phrases-marker) (make-marker))
-  (run-mode-hooks 'reftex-index-phrases-mode-hook))
+  (run-hooks 'reftex-index-phrases-mode-hook))
 (add-hook 'reftex-index-phrases-mode-hook 'turn-on-font-lock)
 
 ;; Font Locking stuff
 (let ((ss (if (featurep 'xemacs) 'secondary-selection ''secondary-selection)))
   (setq reftex-index-phrases-font-lock-keywords
-        (list
+        (list 
          (cons reftex-index-phrases-comment-regexp 'font-lock-comment-face)
          (list reftex-index-phrases-macrodef-regexp
                '(1 font-lock-type-face)
@@ -1342,7 +1340,7 @@
   (setq reftex-index-phrases-font-lock-defaults
         '((reftex-index-phrases-font-lock-keywords)
           nil t nil beginning-of-line))
-  (put 'reftex-index-phrases-mode 'font-lock-defaults
+  (put 'reftex-index-phrases-mode 'font-lock-defaults 
        reftex-index-phrases-font-lock-defaults) ; XEmacs
   )
 
@@ -1404,10 +1402,10 @@
                    (move-marker reftex-index-phrases-marker
                                 (match-beginning 0) (current-buffer))
                    ;; Start the query-replace
-                   (reftex-query-index-phrase-globally
-                    files phrase macro-fmt
+                   (reftex-query-index-phrase-globally 
+                    files phrase macro-fmt 
                     index-key repeat as-words)
-                   (message "%s replaced"
+                   (message "%s replaced" 
                             (reftex-number replace-count "occurrence"))))))
           (t (error "Cannot parse this line")))))
 
@@ -1450,7 +1448,7 @@
           (unless buf (error "Master file %s not found" master))
           (set-buffer buf)
           (reftex-access-scan-info)
-          (setq reftex-index-phrases-files
+          (setq reftex-index-phrases-files 
                 (reftex-all-document-files))))
     ;; Parse the files header for macro definitions
     (setq reftex-index-phrases-macro-data nil)
@@ -1465,7 +1463,7 @@
       ;; Reverse the list, so that the first macro is first
       (if (null reftex-index-phrases-macro-data)
           (error "No valid MACRO DEFINITION line in %s file (make sure to use TAB separators)" reftex-index-phrase-file-extension))
-      (setq reftex-index-phrases-macro-data
+      (setq reftex-index-phrases-macro-data 
             (nreverse reftex-index-phrases-macro-data))
       (goto-char (point-min)))))
 
@@ -1477,7 +1475,7 @@
 index the new part without having to go over the unchanged parts again."
   (interactive "r")
   (let ((win-conf (current-window-configuration))
-        (reftex-index-phrases-restrict-file (buffer-file-name)))
+        (reftex-index-phrases-restrict-file (buffer-file-name)))        
   (save-excursion
     (save-restriction
       (narrow-to-region beg end)
@@ -1500,7 +1498,7 @@
         (setq text (reftex-index-simplify-phrase text))
         (goto-char (point-min))
         (if (re-search-forward
-             (concat "^\\(\\S-*\\)\t\\(" (regexp-quote text)
+             (concat "^\\(\\S-*\\)\t\\(" (regexp-quote text) 
                      "\\) *[\t\n]") nil t)
             (progn
               (goto-char (match-end 2))
@@ -1530,7 +1528,7 @@
           (let* ((phrase (match-string 3))
                  (case-fold-search reftex-index-phrases-case-fold-search)
                  (re (reftex-index-phrases-find-dup-re phrase t)))
-            (if (save-excursion
+            (if (save-excursion 
                   (goto-char (point-min))
                   (and (re-search-forward re nil t)
                        (re-search-forward re nil t)))
@@ -1623,7 +1621,7 @@
             (progn
               (princ (format " Superphrases:  Phrase matches the following %s in the phrase buffer:\n"
                              (reftex-number ntimes2 "line")))
-              (mapcar (lambda(x)
+              (mapcar (lambda(x) 
                         (princ (format "                Line %4d:  %s\n" (car x) (cdr x))))
                       (nreverse superphrases))))))))
 
@@ -1676,7 +1674,7 @@
         beg end)
     (goto-char (point-min))
     ;; Find first and last phrase line in buffer
-    (setq beg
+    (setq beg 
           (and (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
                (match-beginning 0)))
     (goto-char (point-max))
@@ -1703,15 +1701,15 @@
     (if (string-match reftex-index-phrases-phrase-regexp12 a)
         (progn
           ;; Extract macro char and phrase-or-key for a
-          (setq ca (match-string 1 a)
-                pa (downcase
+          (setq ca (match-string 1 a) 
+                pa (downcase 
                     (or (and reftex-index-phrases-sort-prefers-entry
                              (match-string 6 a))
                         (match-string 3 a))))
           (if (string-match reftex-index-phrases-phrase-regexp12 b)
               (progn
                 ;; Extract macro char and phrase-or-key for b
-                (setq cb (match-string 1 b)
+                (setq cb (match-string 1 b) 
                       pb (downcase
                           (or (and reftex-index-phrases-sort-prefers-entry
                                    (match-string 6 b))
@@ -1719,7 +1717,7 @@
                 (setq c-p (string< ca cb)
                       p-p (string< pa pb))
                 ;; Do the right comparison, based on the value of `chars-first'
-                ;; `chars-first' is bound locally in the calling function
+                ;; `chars-first' is bound locally in the calling function               
                 (if chars-first
                     (if (string= ca cb) p-p c-p)
                   (if (string= pa pb) c-p p-p)))))
@@ -1730,7 +1728,7 @@
       (not reftex-index-phrases-sort-in-blocks))))
 
 (defvar reftex-index-phrases-menu)
-(defun reftex-index-make-phrase-regexp (phrase &optional
+(defun reftex-index-make-phrase-regexp (phrase &optional 
                                                as-words allow-newline)
   "Return a regexp matching PHRASE, even if distributed over lines.
 With optional arg AS-WORDS, require word boundary at beginning and end.
@@ -1741,12 +1739,12 @@
                      "\\([ \t]+\\)")))
     (concat (if (and as-words (string-match "\\`\\w" (car words)))
                 "\\(\\<\\|[`']\\)" "")
-            (mapconcat (lambda (w) (regexp-quote
+            (mapconcat (lambda (w) (regexp-quote 
                                     (if reftex-index-phrases-case-fold-search
                                         (downcase w)
                                       w)))
                        words space-re)
-            (if (and as-words
+            (if (and as-words 
                      (string-match "\\w\\'" (nth (1- (length words)) words)))
                 "\\(\\>\\|'\\)" ""))))
 
@@ -1769,8 +1767,8 @@
   (let ((index-keys (split-string (or index-key match)
                                   reftex-index-phrases-logical-and-regexp)))
     (concat
-     (mapconcat (lambda (x)
-                  (format macro-fmt
+     (mapconcat (lambda (x) 
+                  (format macro-fmt 
                           (format (if mathp reftex-index-math-format "%s") x)))
                 index-keys "")
    (if repeat (reftex-index-simplify-phrase match) ""))))
@@ -1782,7 +1780,7 @@
     (unless files (error "No files"))
     (unwind-protect
         (progn
-          (switch-to-buffer-other-window (reftex-get-file-buffer-force
+          (switch-to-buffer-other-window (reftex-get-file-buffer-force 
                                           (car files)))
           (catch 'no-more-files
             (while (setq file (pop files))
@@ -1822,13 +1820,15 @@
 both ends."
   (let* ((re (reftex-index-make-phrase-regexp phrase as-words 'allow-newline))
          (case-fold-search reftex-index-phrases-case-fold-search)
-         (index-keys (split-string
+         (index-keys (split-string 
                       (or index-key phrase)
                       reftex-index-phrases-logical-or-regexp))
          (nkeys (length index-keys))
          (ckey (nth 0 index-keys))
-         (all-yes nil)
-         match rpl char beg end mathp)
+         (all-yes nil) 
+         match rpl char (beg (make-marker)) (end (make-marker)) mathp)
+    (move-marker beg 1)
+    (move-marker end 1)
     (unwind-protect
         (while (re-search-forward re nil t)
           (catch 'next-match
@@ -1841,24 +1841,24 @@
             (setq mathp
                   (save-match-data
                     (condition-case nil (texmathp) (error nil))))
-            (setq beg (car (match-data))
-                  end (nth 1 (match-data)))
+            (setq beg (move-marker beg (match-beginning 0))
+                  end (move-marker end (match-end 0)))
             (if (and reftex-index-phrases-skip-indexed-matches
                      (save-match-data
                        (reftex-index-phrase-match-is-indexed beg
                                                              end)))
                 (throw 'next-match nil))
             (reftex-highlight 0 (match-beginning 0) (match-end 0))
-            (setq rpl
+            (setq rpl 
                   (save-match-data
                     (reftex-index-make-replace-string
                      macro-fmt (match-string 0) ckey repeat mathp)))
-            (while
+            (while 
                 (not
                  (catch 'loop
                    (message "REPLACE: %s?   (yn!qoe%s?)"
                             rpl
-                            (if (> nkeys 1)
+                            (if (> nkeys 1) 
                                 (concat "1-" (int-to-string nkeys))
                               ""))
                    (setq char (if all-yes ?y (read-char-exclusive)))
@@ -1892,7 +1892,7 @@
                          ((member char '(?o ?O))
                           ;; Select a differnt macro
                           (let* ((nc (reftex-index-select-phrases-macro 2))
-                                 (macro-data
+                                 (macro-data 
                                   (cdr (assoc nc reftex-index-phrases-macro-data)))
                                  (macro-fmt (car macro-data))
                                  (repeat (nth 1 macro-data)))
@@ -1910,7 +1910,7 @@
                           ;; Recursive edit
                           (save-match-data
                             (save-excursion
-                              (message
+                              (message 
                                (substitute-command-keys
                                 "Recursive edit.  Resume with \\[exit-recursive-edit]"))
                               (recursive-edit))))
@@ -1930,6 +1930,8 @@
                          (t (ding)))
                    nil)))))
       (message "")
+      (move-marker beg nil)
+      (move-marker end nil)
       (setq all-yes nil)
       (reftex-unhighlight 0))))
 
@@ -1939,7 +1941,7 @@
   (save-excursion
     (goto-char end)
     (let* ((all-macros (reftex-what-macro t))
-           (this-macro (car (car all-macros)))
+;           (this-macro (car (car all-macros)))
            (before-macro
             (and (> beg 2)
                  (goto-char (1- beg))
@@ -2043,7 +2045,7 @@
         ("\C-i"     . self-insert-command))
       do (define-key reftex-index-phrases-map (car x) (cdr x)))
 
-(easy-menu-define
+(easy-menu-define 
  reftex-index-phrases-menu reftex-index-phrases-map
  "Menu for Phrases buffer"
  '("Phrases"
--- a/lisp/textmodes/reftex-parse.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-parse.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-parse.el --- parser functions for RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 ;;
 
 ;; This file is part of GNU Emacs.
@@ -21,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
--- a/lisp/textmodes/reftex-ref.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-ref.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-ref.el --- code to create labels and references with RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
--- a/lisp/textmodes/reftex-sel.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-sel.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-sel.el --- the selection modes for RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2440, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -61,7 +60,7 @@
   (when (syntax-table-p reftex-latex-syntax-table)
     (set-syntax-table reftex-latex-syntax-table))
   ;; We do not set a local map - reftex-select-item does this.
-  (run-mode-hooks 'reftex-select-label-mode-hook))
+  (run-hooks 'reftex-select-label-mode-hook))
 
 (defvar reftex-select-bib-map nil
   "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
@@ -89,7 +88,7 @@
         mode-name "BSelect")
   (set (make-local-variable 'reftex-select-marked) nil)
   ;; We do not set a local map - reftex-select-item does this.
-  (run-mode-hooks 'reftex-select-bib-mode-hook))
+  (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.
--- a/lisp/textmodes/reftex-toc.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-toc.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-toc.el --- RefTeX's table of contents mode
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -36,8 +35,9 @@
   "Keymap used for *toc* buffer.")
 
 (defvar reftex-toc-menu)
-(defvar zmacs-regions)
-
+(eval-when-compile (defvar zmacs-regions))
+(defvar reftex-last-window-height nil)
+(defvar reftex-last-window-width nil)
 (defvar reftex-toc-include-labels-indicator nil)
 (defvar reftex-toc-include-index-indicator nil)
 (defvar reftex-toc-max-level-indicator nil)
@@ -79,13 +79,11 @@
   (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
   (add-hook 'pre-command-hook  'reftex-toc-pre-command-hook nil t)
   (easy-menu-add reftex-toc-menu reftex-toc-map)
-  (run-mode-hooks 'reftex-toc-mode-hook))
+  (run-hooks 'reftex-toc-mode-hook))
 
 (defvar reftex-last-toc-file nil
   "Stores the file name from which `reftex-toc' was called.  For redo command.")
 
-(defvar reftex-last-window-height nil)
-(defvar reftex-last-window-width nil)
 
 (defvar reftex-toc-return-marker (make-marker)
   "Marker which makes it possible to return from toc to old position.")
@@ -152,7 +150,7 @@
                          (frame-parameter (selected-frame) 'unsplittable)))
          offset toc-window)
 
-    (if (setq toc-window (get-buffer-window
+    (if (setq toc-window (get-buffer-window 
                           "*toc*"
                           (if reuse 'visible)))
         (select-window toc-window)
@@ -168,7 +166,7 @@
             (split-window-horizontally
              (floor (* (window-width)
                        reftex-toc-split-windows-fraction)))
-          (split-window-vertically
+          (split-window-vertically 
            (floor (* (window-height)
                      reftex-toc-split-windows-fraction)))))
 
@@ -213,11 +211,11 @@
              reftex-toc-include-context
              nil ; counter
              nil ; commented
-             here-I-am
+             here-I-am 
              ""     ; xr-prefix
              t      ; a toc buffer
              ))
-
+       
       (run-hooks 'reftex-display-copied-context-hook)
       (message "Building *toc* buffer...done.")
       (setq buffer-read-only t))
@@ -229,7 +227,7 @@
                                    t
                                    reftex-toc-include-index-entries
                                    reftex-toc-include-file-boundaries)
-                (reftex-last-assoc-before-elt
+                (reftex-last-assoc-before-elt 
                  'toc here-I-am
                  (symbol-value reftex-docstruct-symbol))))
       (put 'reftex-toc :reftex-line 3)
@@ -254,7 +252,7 @@
          (not (get-text-property (point) 'intangible))
          (memq reftex-highlight-selection '(cursor both))
          (reftex-highlight 2
-                           (or (previous-single-property-change
+                           (or (previous-single-property-change 
                                 (min (point-max) (1+ (point))) :data)
                                (point-min))
                            (or (next-single-property-change (point) :data)
@@ -301,10 +299,10 @@
                (window-height))))))
 
 (defun reftex-toc-dframe-p (&optional frame error)
-  ;; Check if FRAME is the dedicated TOC frame.
+  ;; Check if FRAME is the dedicated TOC frame.  
   ;; If yes, and ERROR is non-nil, throw an error.
   (setq frame (or frame (selected-frame)))
-  (let ((res (equal
+  (let ((res (equal 
               (if (fboundp 'frame-property)
                   (frame-property frame 'name)
                 (frame-parameter  frame 'name))
@@ -330,7 +328,7 @@
   (if (boundp 'zmacs-region-stays) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
-  (goto-char (or (next-single-property-change (point) :data)
+  (goto-char (or (next-single-property-change (point) :data) 
                  (point))))
 (defun reftex-toc-previous (&optional arg)
   "Move to previous selectable item."
@@ -367,7 +365,7 @@
 With prefix ARG, prompt for a label type and include only labels of
 that specific type."
   (interactive "P")
-  (setq reftex-toc-include-labels
+  (setq reftex-toc-include-labels 
         (if arg (reftex-query-label-type)
           (not reftex-toc-include-labels)))
   (reftex-toc-revert))
@@ -471,7 +469,7 @@
 (defun reftex-toc-rescan (&rest ignore)
   "Regenerate the *toc* buffer by reparsing file of section at point."
   (interactive)
-  (if (and reftex-enable-partial-scans
+  (if (and reftex-enable-partial-scans 
            (null current-prefix-arg))
       (let* ((data (get-text-property (point) :data))
              (what (car data))
@@ -505,7 +503,7 @@
 (defun reftex-toc-revert (&rest ignore)
   "Regenerate the *toc* from the internal lists."
   (interactive)
-  (let ((unsplittable
+  (let ((unsplittable 
          (if (fboundp 'frame-property)
              (frame-property (selected-frame) 'unsplittable)
            (frame-parameter (selected-frame) 'unsplittable)))
@@ -547,6 +545,13 @@
 
 ;; Promotion/Demotion stuff
 
+(defvar delta)
+(defvar mpos)
+(defvar pro-or-de)
+(defvar start-pos)
+(defvar start-line)
+(defvar mark-line)
+
 (defun reftex-toc-demote (&optional arg)
   "Demote section at point.  If region is active, apply to all in region."
   (interactive "p")
@@ -592,7 +597,7 @@
             (goto-char start-pos)
             (setq sections (reftex-toc-extract-section-number (car entries)))
             (if (> (setq nsec (length entries)) 1)
-                (setq sections
+                (setq sections 
                       (concat sections "-"
                               (reftex-toc-extract-section-number
                                (nth (1- nsec) entries)))))
@@ -617,17 +622,11 @@
             (save-window-excursion
               (reftex-toc-Rescan))
             (reftex-toc-restore-region start-line mark-line)
-            (message "%d section%s %smoted"
+            (message "%d section%s %smoted" 
                      nsec (if (= 1 nsec) "" "s") pro-or-de)
             nil))
     (if msg (progn (ding) (message msg)))))
 
-(defvar delta)
-(defvar mpos)
-(defvar pro-or-de)
-(defvar start-pos)
-(defvar start-line)
-(defvar mark-line)
 
 (defun reftex-toc-restore-region (point-line &optional mark-line)
   (if mark-line
@@ -642,6 +641,10 @@
           (setq mark-active t
                 deactivate-mark nil)))))
 
+(defvar name1)
+(defvar dummy)
+(defvar dummy2)
+
 (defun reftex-toc-promote-prepare (x)
   "Look at a toc entry and see if we could pro/demote it.
 Expects the level change DELTA to be dynamically scoped into this function.
@@ -670,7 +673,7 @@
                         (beginning-of-line 1)
                         (if (looking-at reftex-section-regexp)
                             (setq name (reftex-match-string 2))
-                          (error "Something is wrong!  Contact maintainer!")))
+                          (error "Something is wrong! Contact maintainer!")))
                     ;; Section has changed, request scan and loading
                     ;; We use a variable to delay until after the safe-exc.
                     ;; because otherwise we loose the region.
@@ -779,7 +782,7 @@
         (error "This is not a label entry."))
     (setq newlabel (read-string (format "Rename label \"%s\" to:" label)))
     (if (assoc newlabel (symbol-value reftex-docstruct-symbol))
-        (if (not (y-or-n-p
+        (if (not (y-or-n-p 
                   (format "Label '%s' exists. Use anyway? " label)))
             (error "Abort")))
     (save-excursion
@@ -789,7 +792,7 @@
             (reftex-query-replace-document
              (concat "{" (regexp-quote label) "}")
              (format "{%s}" newlabel))
-          (error t))))
+          (error t))))        
     (reftex-toc-rescan)))
 
 
@@ -808,9 +811,9 @@
          show-window show-buffer match)
 
     (unless toc (error "Don't know which toc line to visit"))
-
+    
     (cond
-
+  
      ((eq (car toc) 'toc)
       ;; a toc entry
       (setq match (reftex-toc-find-section toc no-revisit)))
@@ -826,7 +829,7 @@
                   (file (nth 1 toc)))
               (if (or (not no-revisit) (reftex-get-buffer-visiting file))
                   (progn
-                    (switch-to-buffer-other-window
+                    (switch-to-buffer-other-window 
                      (reftex-get-file-buffer-force file nil))
                     (goto-char (if (eq where 'bof) (point-min) (point-max))))
                 (message reftex-no-follow-message) nil))))
@@ -879,8 +882,8 @@
                 (looking-at (reftex-make-desperate-section-regexp literal))
                 (looking-at (concat "\\\\"
                                     (regexp-quote
-                                     (car
-                                      (rassq level
+                                     (car 
+                                      (rassq level 
                                              reftex-section-levels-all)))
                                     "[[{]?"))))
            ((or (not no-revisit)
@@ -1050,7 +1053,7 @@
       (define-key reftex-toc-map (vector (list key)) 'digit-argument))
 (define-key reftex-toc-map "-" 'negative-argument)
 
-(easy-menu-define
+(easy-menu-define 
  reftex-toc-menu reftex-toc-map
  "Menu for Table of Contents buffer"
  '("TOC"
@@ -1083,7 +1086,7 @@
     ["Context" reftex-toc-toggle-context :style toggle
      :selected reftex-toc-include-context]
     "--"
-    ["Follow Mode" reftex-toc-toggle-follow :style toggle
+    ["Follow Mode" reftex-toc-toggle-follow :style toggle 
      :selected reftex-toc-follow-mode]
     ["Auto Recenter" reftex-toggle-auto-toc-recenter :style toggle
      :selected reftex-toc-auto-recenter-timer]
--- a/lisp/textmodes/reftex-vars.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex-vars.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex-vars.el --- configuration variables for RefTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 
 ;; This file is part of GNU Emacs.
 
@@ -20,16 +19,15 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
 ;;; Code:
-
+(eval-when-compile (defvar reftex-tables-dirty))
 (eval-when-compile (require 'cl))
 (eval-and-compile
-  (defvar reftex-tables-dirty)
   (defun reftex-set-dirty (symbol value)
     (setq reftex-tables-dirty t)
     (set symbol value)))
@@ -102,22 +100,22 @@
 
       ("enumerate" ?i "item:" "~\\ref{%s}" item
        (regexp "items?" "Punkte?"))
-
+      
       ("equation"  ?e "eq:" "~(\\ref{%s})" t
        (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?"  "Gl\\."))
       ("eqnarray"  ?e "eq:" nil eqnarray-like)
-
+      
       ("figure"    ?f "fig:" "~\\ref{%s}" caption
        (regexp "figure?[sn]?" "figs?\\." "Abbildung\\(en\\)?" "Abb\\."))
       ("figure*"   ?f nil nil caption)
-
+      
       ("table"     ?t "tab:" "~\\ref{%s}" caption
        (regexp "tables?" "tab\\." "Tabellen?"))
       ("table*"    ?t nil nil caption)
-
+      
       ("\\footnote[]{}" ?n "fn:" "~\\ref{%s}" 2
        (regexp "footnotes?" "Fussnoten?"))
-
+      
       ("any"       ?\  " "   "~\\ref{%s}" nil)
 
       ;; The label macro is hard coded, but it *could* be defined like this:
@@ -209,7 +207,7 @@
 `?t'    should point to a textual citation (citation as a noun).
 `?p'    should point to a parenthetical citation.")
 
-(defconst reftex-index-macros-builtin
+(defconst reftex-index-macros-builtin 
   '((default "Default \\index and \\glossary macros"
       (("\\index{*}" "idx" ?i "" nil t)
        ("\\glossary{*}" "glo" ?g "" nil t)))
@@ -221,7 +219,7 @@
     (Index-Shortcut "index.sty with \\shortindexingon"
        (("\\index[]{*}" 1 ?i "" nil t)
         ("\\index*[]{*}" 1 ?I "" nil nil)
-        ("^[]{*}" 1 ?^ "" texmathp t)
+        ("^[]{*}" 1 ?^ "" texmathp t)   
         ("_[]{*}" 1 ?_ "" texmathp nil))))
   "Builtin stuff for reftex-index-macros.
 Lower-case symbols correspond to a style file of the same name in the LaTeX
@@ -233,7 +231,7 @@
 (defgroup reftex nil
   "LaTeX label and citation support."
   :tag "RefTeX"
-  :link '(url-link :tag "Home Page"
+  :link '(url-link :tag "Home Page" 
                    "http://zon.astro.uva.nl/~dominik/Tools/")
   :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el")
   :link '(custom-manual "(reftex)Top")
@@ -328,14 +326,14 @@
 automatic recentering is turned on.  When the frame gets destroyed, automatic
 recentering is turned off again.
 
-This feature can be turned on and off from the menu
+This feature can be turned on and off from the menu 
 \(Ref->Options)."
   :group 'reftex-table-of-contents-browser
   :type '(choice
           (const :tag "never" nil)
           (const :tag "always" t)
           (const :tag "in dedicated frame only" frame)))
-
+ 
 (defcustom reftex-toc-split-windows-horizontally nil
   "*Non-nil means, create TOC window by splitting window horizontally."
   :group 'reftex-table-of-contents-browser
@@ -427,7 +425,7 @@
   '(amsmath endnotes fancybox floatfig longtable picinpar
             rotating sidecap subfigure supertab wrapfig LaTeX)
   "Default label alist specifications.  LaTeX should always be the last entry.
-The value of this variable is a list of symbols with associations in the
+The value of this variable is a list of symbols with associations in the 
 constant `reftex-label-alist-builtin'.  Check that constant for a full list
 of options."
   :group 'reftex-defining-label-environments
@@ -626,7 +624,7 @@
 (defcustom reftex-section-prefixes '((0 . "part:") (1 . "cha:") (t . "sec:"))
   "Prefixes for section labels.
 When the label prefix given in an entry in `reftex-label-alist' contains `%S',
-this list is used to determine the correct prefix string depending on the
+this list is used to determine the correct prefix string depending on the 
 current section level.
 The list is an alist, with each entry of the form (KEY . PREFIX)
 Possible keys are sectioning macro names like `chapter', section levels
@@ -688,7 +686,7 @@
           (regexp)
           (repeat :tag "List"
                   (string :tag "prefix (with colon)"))))
-
+  
 (defcustom reftex-special-environment-functions nil
   "List of functions to be called when trying to figure out current environment.
 These are special functions to detect \"environments\" which do not
@@ -734,7 +732,7 @@
      (let ((pos (point)) p1)
        (save-excursion
          ;; Search for any of the linguex item macros at the beginning of a line
-         (if (re-search-backward
+         (if (re-search-backward 
               \"^[ \\t]*\\\\(\\\\\\\\\\\\(ex\\\\|a\\\\|b\\\\|c\\\\|d\\\\|e\\\\|f\\\\)g?\\\\.\\\\)\" bound t)
              (progn
                (setq p1 (match-beginning 1))
@@ -744,7 +742,7 @@
                    nil
                  ;; OK, we got it
                  (cons \"linguex\" p1)))
-           ;; Return nil for not found
+           ;; Return nil for not found 
            nil))))
 
 3. Tell RefTeX to use this function
@@ -943,7 +941,7 @@
 
 (defcustom reftex-vref-is-default nil
   "*Non-nil means, the varioref macro \\vref is used as default.
-In the selection buffer, the `v' key toggles the reference macro between
+In the selection buffer, the `v' key toggles the reference macro between 
 `\\ref' and `\\vref'.  The value of this variable determines the default
 which is active when entering the selection process.
 Instead of nil or t, this may also be a string of type letters indicating
@@ -953,7 +951,7 @@
 
 (defcustom reftex-fref-is-default nil
   "*Non-nil means, the fancyref macro \\fref is used as default.
-In the selection buffer, the `V' key toggles the reference macro between
+In the selection buffer, the `V' key toggles the reference macro between 
 `\\ref', `\\fref' and `\\Fref'.  The value of this variable determines
 the default which is active when entering the selection process.
 Instead of nil or t, this may also be a string of type letters indicating
@@ -977,7 +975,7 @@
 
 (defcustom reftex-format-ref-function nil
   "Function which produces the string to insert as a reference.
-Normally should be nil, because the format to insert a reference can
+Normally should be nil, because the format to insert a reference can 
 already be specified in `reftex-label-alist'.
 This hook also is used by the special commands to insert `\\vref' and `\\fref'
 references, so even if you set this, your setting will be ignored by
@@ -1058,13 +1056,13 @@
 %i institution   %j journal        %k key        %m month
 %n number        %o organization   %p pages      %P first page
 %r address       %s school         %u publisher  %t title
-%v volume        %y year
+%v volume        %y year          
 %B booktitle, abbreviated          %T title, abbreviated
 
 Usually, only %l is needed.  The other stuff is mainly for the echo area
 display, and for (setq reftex-comment-citations t).
 
-%< as a special operator kills punctuation and space around it after the
+%< as a special operator kills punctuation and space around it after the 
 string has been formatted.
 
 A pair of square brackets indicates an optional argument, and RefTeX
@@ -1079,7 +1077,7 @@
 strings.
   In order to configure this variable, you can either set
 `reftex-cite-format' directly yourself or set it to the SYMBOL of one of
-the predefined styles.  The predefined symbols are those which have an
+the predefined styles.  The predefined symbols are those which have an 
 association in the constant `reftex-cite-format-builtin'.
 E.g.: (setq reftex-cite-format 'natbib)"
   :group 'reftex-citation-support
@@ -1173,7 +1171,7 @@
 
 (defcustom reftex-format-cite-function nil
   "Function which produces the string to insert as a citation.
-Normally should be nil, because the format to insert a reference can
+Normally should be nil, because the format to insert a reference can 
 already be specified in `reftex-cite-format'.
 The function will be called with two arguments, the CITATION KEY and the
 DEFAULT FORMAT, which is taken from `reftex-cite-format'.  The function
@@ -1256,7 +1254,7 @@
   :group 'reftex-index-support
   :set 'reftex-set-dirty
   :type `(list
-          (repeat
+          (repeat 
            :inline t
            (list :value ("" "idx" ?a "" nil)
                  (string  :tag "Macro with args")
@@ -1283,7 +1281,7 @@
 This is a list with (MACRO-KEY DEFAULT-TAG).
 
 MACRO-KEY:   Character identifying an index macro - see `reftex-index-macros'.
-DEFAULT-TAG: This is the tag to be used if the macro requires a TAG argument.
+DEFAULT-TAG: This is the tag to be used if the macro requires a TAG argument.  
              When this is nil and a TAG is needed, RefTeX will ask for it.
              When this is the empty string and the TAG argument of the index
              macro is optional, the TAG argument will be omitted."
@@ -1424,7 +1422,7 @@
 
 (defcustom reftex-index-include-context nil
   "*Non-nil means, display the index definition context in the index buffer.
-This flag may also be toggled from the index buffer with the `c' key."
+This flag may also be toggled from the index buffer with the `c' key." 
   :group 'reftex-index-support
   :type 'boolean)
 
@@ -1447,7 +1445,7 @@
 argument of a macro.  Note that crossref viewing for citations,
 references (both ways) and index entries is hard-coded.  This variable
 is only to configure additional structures for which crossreference
-viewing can be useful.  Each entry has the structure
+viewing can be useful.  Each entry has the structure 
 
 \(MACRO-RE SEARCH-RE HIGHLIGHT).
 
@@ -1468,7 +1466,7 @@
 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
+This feature can be turned on and off from the menu 
 \(Ref->Options)."
   :group 'reftex-viewing-cross-references
   :type '(choice (const :tag "off" nil)
@@ -1514,7 +1512,7 @@
 - If an element is the name of an environment variable, its content is used.
 - If an element starts with an exclamation mark, it is used as a command
   to retrieve the path.  A typical command with the kpathsearch library would
-  be `!kpsewhich -show-path=.tex'.
+  be `!kpsewhich -show-path=.tex'. 
 - Otherwise the element itself is interpreted as a path.
 Multiple directories can be separated by the system dependent `path-separator'.
 Directories ending in `//' or `!!' will be expanded recursively.
@@ -1529,7 +1527,7 @@
 - If an element is the name of an environment variable, its content is used.
 - If an element starts with an exclamation mark, it is used as a command
   to retrieve the path.  A typical command with the kpathsearch library would
-  be `!kpsewhich -show-path=.bib'.
+  be `!kpsewhich -show-path=.bib'. 
 - Otherwise the element itself is interpreted as a path.
 Multiple directories can be separated by the system dependent `path-separator'.
 Directories ending in `//' or `!!' will be expanded recursively.
@@ -1574,7 +1572,7 @@
 TEXINPUTS and BIBINPUTS to find TeX files and BibTeX database files.
 With this option turned on, it calls an external program specified in the
 option `reftex-external-file-finders' instead.  As a side effect,
-the variables `reftex-texpath-environment-variables' and
+the variables `reftex-texpath-environment-variables' and 
 `reftex-bibpath-environment-variables' will be ignored."
   :group 'reftex-finding-files
   :type 'boolean)
@@ -1665,7 +1663,7 @@
 (defcustom reftex-save-parse-info nil
   "*Non-nil means, save information gathered with parsing in a file.
 The file MASTER.rel in the same directory as MASTER.tex is used to save the
-information.  When this variable is t,
+information.  When this variable is t, 
 - accessing the parsing information for the first time in an editing session
   will read that file (if available) instead of parsing the document.
 - exiting Emacs or killing a buffer in reftex-mode will cause a new version
@@ -1858,7 +1856,7 @@
 may require a restart of Emacs in order to become effective."
   :group 'reftex-miscellaneous-configurations
   :group 'LaTeX
-  :type '(choice
+  :type '(choice 
           (const :tag "No plug-ins" nil)
           (const :tag "All possible plug-ins" t)
           (list
--- a/lisp/textmodes/reftex.el	Fri Sep 16 06:50:06 2005 +0000
+++ b/lisp/textmodes/reftex.el	Fri Sep 16 10:01:33 2005 +0000
@@ -1,10 +1,9 @@
 ;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
-
-;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
+;;  Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.28
+;; Version: VERSIONTAG
 ;; Keywords: tex
 
 ;; This file is part of GNU Emacs.
@@ -21,13 +20,13 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;---------------------------------------------------------------------------
 ;;
 ;;; Commentary:
-;;
+;; 
 ;; RefTeX is a minor mode with distinct support for \ref, \label, \cite,
 ;; and \index commands in (multi-file) LaTeX documents.
 ;; - A table of contents provides easy access to any part of a document.
@@ -72,7 +71,7 @@
 ;;
 ;; Introduction
 ;; ************
-;;
+;; 
 ;; RefTeX is a specialized package for support of labels, references,
 ;; citations, and the index in LaTeX.  RefTeX wraps itself round 4 LaTeX
 ;; macros: `\label', `\ref', `\cite', and `\index'.  Using these macros
@@ -81,13 +80,13 @@
 ;; time-consuming tasks almost entirely.  It also provides functions to
 ;; display the structure of a document and to move around in this
 ;; structure quickly.
-;;
+;; 
 ;;    *Note Imprint::, for information about who to contact for help, bug
 ;; reports or suggestions.
-;;
+;; 
 ;; Environment
 ;; ===========
-;;
+;; 
 ;; RefTeX needs to access all files which are part of a multifile
 ;; document, and the BibTeX database files requested by the
 ;; `\bibliography' command.  To find these files, RefTeX will require a
@@ -96,26 +95,26 @@
 ;; which are also used by RefTeX.  However, on some systems these
 ;; variables do not contain the full search path.  If RefTeX does not work
 ;; for you because it cannot find some files, read *Note Finding Files::.
-;;
+;; 
 ;; Entering RefTeX Mode
 ;; ====================
-;;
+;; 
 ;; To turn RefTeX Mode on and off in a particular buffer, use `M-x
 ;; reftex-mode'.  To turn on RefTeX Mode for all LaTeX files, add the
 ;; following lines to your `.emacs' file:
-;;
+;; 
 ;;      (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
 ;;      (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
-;;
+;; 
 ;; RefTeX in a Nutshell
 ;; ====================
-;;
+;; 
 ;;   1. Table of Contents
 ;;      Typing `C-c =' (`reftex-toc') will show a table of contents of the
 ;;      document.  This buffer can display sections, labels and index
 ;;      entries defined in the document.  From the buffer, you can jump
 ;;      quickly to every part of your document.  Press `?' to get help.
-;;
+;; 
 ;;   2. Labels and References
 ;;      RefTeX helps to create unique labels and to find the correct key
 ;;      for references quickly.  It distinguishes labels for different
@@ -123,7 +122,7 @@
 ;;      others), and can be configured to recognize any additional labeled
 ;;      environments you have defined yourself (variable
 ;;      `reftex-label-alist').
-;;
+;; 
 ;;         * Creating Labels
 ;;           Type `C-c (' (`reftex-label') to insert a label at point.
 ;;           RefTeX will either
@@ -132,17 +131,17 @@
 ;;                tables) or
 ;;              - insert a simple label made of a prefix and a number (all
 ;;                other environments)
-;;
+;; 
 ;;           Which labels are created how is configurable with the variable
 ;;           `reftex-insert-label-flags'.
-;;
+;; 
 ;;         * Referencing Labels
 ;;           To make a reference, type `C-c )' (`reftex-reference').  This
 ;;           shows an outline of the document with all labels of a certain
 ;;           type (figure, equation,...) and some label context.
 ;;           Selecting a label inserts a `\ref{LABEL}' macro into the
 ;;           original buffer.
-;;
+;; 
 ;;   3. Citations
 ;;      Typing `C-c [' (`reftex-citation') will let you specify a regular
 ;;      expression to search in current BibTeX database files (as
@@ -151,7 +150,7 @@
 ;;      sorted.  The selected article is referenced as `\cite{KEY}' (see
 ;;      the variable `reftex-cite-format' if you want to insert different
 ;;      macros).
-;;
+;; 
 ;;   4. Index Support
 ;;      RefTeX helps to enter index entries.  It also compiles all entries
 ;;      into an alphabetically sorted `*Index*' buffer which you can use
@@ -159,25 +158,25 @@
 ;;      index macros and can be configured to recognize any additional
 ;;      macros you have defined (`reftex-index-macros').  Multiple indices
 ;;      are supported.
-;;
+;; 
 ;;         * Creating Index Entries
 ;;           To index the current selection or the word at point, type
 ;;           `C-c /' (`reftex-index-selection-or-word').  The default macro
 ;;           `reftex-index-default-macro' will be used.  For a more
 ;;           complex entry type `C-c <' (`reftex-index'), select any of
 ;;           the index macros and enter the arguments with completion.
-;;
+;; 
 ;;         * The Index Phrases File (Delayed Indexing)
 ;;           Type `C-c \' (`reftex-index-phrase-selection-or-word') to add
 ;;           the current word or selection to a special _index phrase
 ;;           file_.  RefTeX can later search the document for occurrences
 ;;           of these phrases and let you interactively index the matches.
-;;
+;; 
 ;;         * Displaying and Editing the Index
 ;;           To display the compiled index in a special buffer, type `C-c
 ;;           >' (`reftex-display-index').  From that buffer you can check
 ;;           and edit all entries.
-;;
+;; 
 ;;   5. Viewing Cross-References
 ;;      When point is on the KEY argument of a cross-referencing macro
 ;;      (`\label', `\ref', `\cite', `\bibitem', `\index', and variations)
@@ -187,14 +186,14 @@
 ;;      When the enclosing macro is `\cite' or `\ref' and no other message
 ;;      occupies the echo area, information about the citation or label
 ;;      will automatically be displayed in the echo area.
-;;
+;; 
 ;;   6. Multifile Documents
 ;;      Multifile Documents are fully supported.  The included files must
 ;;      have a file variable `TeX-master' or `tex-main-file' pointing to
 ;;      the master file.  RefTeX provides cross-referencing information
 ;;      from all parts of the document, and across document borders
 ;;      (`xr.sty').
-;;
+;; 
 ;;   7. Document Parsing
 ;;      RefTeX needs to parse the document in order to find labels and
 ;;      other information.  It does it automatically once and updates its
@@ -203,23 +202,23 @@
 ;;      with a raw `C-u' prefix, or press the `r' key in the label
 ;;      selection buffer, the table of contents buffer, or the index
 ;;      buffer.
-;;
+;; 
 ;;   8. AUCTeX
 ;;      If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it
 ;;      (see variable `reftex-plug-into-AUCTeX').  AUCTeX contains style
 ;;      files which trigger appropriate settings in RefTeX, so that for
 ;;      many of the popular LaTeX packages no additional customizations
 ;;      will be necessary.
-;;
+;; 
 ;;   9. Useful Settings
 ;;      To make RefTeX faster for large documents, try these:
 ;;           (setq reftex-enable-partial-scans t)
 ;;           (setq reftex-save-parse-info t)
 ;;           (setq reftex-use-multiple-selection-buffers t)
-;;
+;; 
 ;;      To integrate with AUCTeX, use
 ;;           (setq reftex-plug-into-AUCTeX t)
-;;
+;; 
 ;;      To make your own LaTeX macro definitions known to RefTeX,
 ;;      customize the variables
 ;;           `reftex-label-alist'          (for label macros/environments)
@@ -229,7 +228,7 @@
 ;;           `reftex-index-default-macro'  (to set the default macro)
 ;;      If you have a large number of macros defined, you may want to write
 ;;      an AUCTeX style file to support them with both AUCTeX and RefTeX.
-;;
+;; 
 ;;  10. Where Next?
 ;;      Go ahead and use RefTeX.  Use its menus until you have picked up
 ;;      the key bindings.  For an overview of what you can do in each of
@@ -238,7 +237,7 @@
 ;;      The first part of the manual explains in a tutorial way how to use
 ;;      and customize RefTeX.  The second part is a command and variable
 ;;      reference.
-;;
+;; 
 ;;---------------------------------------------------------------------------
 ;;
 ;; AUTHOR
@@ -289,8 +288,6 @@
     (setq reftex-tables-dirty t)
     (set symbol value)))
 
-(defvar font-lock-keywords)
-
 
 ;;; =========================================================================
 ;;;
@@ -304,7 +301,7 @@
 ;;; Define the formal stuff for a minor mode named RefTeX.
 ;;;
 
-(defconst reftex-version "RefTeX version 4.28"
+(defconst reftex-version "RefTeX version VERSIONTAG"
   "Version string for RefTeX.")
 
 (defvar reftex-mode nil
@@ -322,7 +319,7 @@
   (setq reftex-syntax-table (copy-syntax-table))
   (modify-syntax-entry ?\( "." reftex-syntax-table)
   (modify-syntax-entry ?\) "." reftex-syntax-table))
-
+        
 (unless reftex-syntax-table-for-bib
   (setq reftex-syntax-table-for-bib
         (copy-syntax-table reftex-syntax-table))
@@ -398,7 +395,7 @@
         (setq reftex-syntax-table (copy-syntax-table (syntax-table)))
         (modify-syntax-entry ?\( "." reftex-syntax-table)
         (modify-syntax-entry ?\) "." reftex-syntax-table)
-
+        
         (setq reftex-syntax-table-for-bib
               (copy-syntax-table reftex-syntax-table))
         (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
@@ -457,6 +454,7 @@
   (defvar tex-main-file)
   (defvar outline-minor-mode)
   (defvar font-lock-mode)
+  (defvar font-lock-keywords)
   (defvar font-lock-fontify-region-function)
   (defvar font-lock-syntactic-keywords))
 
@@ -539,7 +537,7 @@
       ((master
         (cond
          ((fboundp 'TeX-master-file) ; AUCTeX is loaded.  Use its mechanism.
-          (condition-case nil
+          (condition-case nil 
               (TeX-master-file t)
             (error (buffer-file-name))))
          ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode
@@ -579,7 +577,7 @@
       )
      (t
       ;; Use buffer file name.
-      (buffer-file-name)))
+      (setq master (buffer-file-name))))
     (expand-file-name master)))
 
 (defun reftex-is-multi ()
@@ -740,14 +738,14 @@
 
 ;; A list of all variables in the cache.
 ;; The cache is used to save the compiled versions of some variables.
-(defconst reftex-cache-variables
+(defconst reftex-cache-variables 
   '(reftex-memory ;; This MUST ALWAYS be the first!
-
+    
     ;; Outline
     reftex-section-levels-all
 
     ;; Labels
-    reftex-env-or-mac-alist
+    reftex-env-or-mac-alist 
     reftex-special-env-parsers
     reftex-macros-with-labels
     reftex-label-mac-list
@@ -764,7 +762,7 @@
     reftex-index-macro-alist
     reftex-macros-with-index
     reftex-query-index-macro-prompt
-    reftex-query-index-macro-help
+    reftex-query-index-macro-help 
     reftex-key-to-index-macro-alist
 
     ;; Regular expressions
@@ -809,7 +807,7 @@
      (t (reftex-compile-variables)))))
 
 (defun reftex-reset-mode ()
-  "Reset RefTeX Mode.
+  "Reset RefTeX Mode.  
 This will re-compile the configuration information and remove all
 current scanning information and the parse file to enforce a rescan
 on next use."
@@ -860,12 +858,12 @@
 
 (defun reftex-erase-all-selection-and-index-buffers ()
   ;; Remove all selection buffers associated with current document.
-  (mapcar
+  (mapcar 
    (lambda (type)
      (reftex-erase-buffer (reftex-make-selection-buffer-name type)))
    reftex-typekey-list)
   ;; Kill all index buffers
-  (mapcar
+  (mapcar 
    (lambda (tag)
      (reftex-kill-buffer (reftex-make-index-buffer-name tag)))
    (cdr (assoc 'index-tags (symbol-value reftex-docstruct-symbol)))))
@@ -881,7 +879,7 @@
 
   ;; Record that we have done this, and what we have used.
   (setq reftex-tables-dirty nil)
-  (setq reftex-memory
+  (setq reftex-memory 
         (list reftex-label-alist
               (get reftex-docstruct-symbol 'reftex-section-levels)
               (get reftex-docstruct-symbol 'reftex-label-alist-style)
@@ -900,7 +898,7 @@
               '(nil)))
         (all-index (reftex-uniquify-by-car
                     (reftex-splice-symbols-into-list
-                     (append reftex-index-macros
+                     (append reftex-index-macros 
                              (get reftex-docstruct-symbol
                                   'reftex-index-macros-style)
                              '(default))
@@ -911,7 +909,7 @@
         macro verify repeat nindex tag key toc-level toc-levels)
 
     (setq reftex-words-to-typekey-alist nil
-          reftex-prefix-to-typekey-alist
+          reftex-prefix-to-typekey-alist 
           '(("sec:" . "s") ("cha:" . "s") ("chap:" . "s"))
           reftex-typekey-list nil
           reftex-typekey-to-format-alist nil
@@ -967,7 +965,7 @@
          ((symbolp env-or-mac)
           ;; A special parser function
           (unless (fboundp env-or-mac)
-            (message "Warning: %s does not seem to be a valid function"
+            (message "Warning: %s does not seem to be a valid function" 
                      env-or-mac))
           (setq nargs nil nlabel nil opt-args nil)
           (add-to-list 'reftex-special-env-parsers env-or-mac)
@@ -995,8 +993,8 @@
                            (push (cons string toc-level) toc-levels))))))))
         ;; Translate some special context cases
         (when (assq context reftex-default-context-regexps)
-          (setq context
-                (format
+          (setq context 
+                (format 
                  (cdr (assq context reftex-default-context-regexps))
                  (regexp-quote env-or-mac))))
         ;; See if this is the first format for this typekey
@@ -1029,7 +1027,7 @@
           (nreverse reftex-typekey-to-prefix-alist))
 
     ;; Prepare the typekey query prompt and help string.
-    (setq qh-list
+    (setq qh-list 
           (sort qh-list
                 (lambda (x1 x2)
                   (string< (downcase (car x1)) (downcase (car x2))))))
@@ -1040,7 +1038,7 @@
                   "]"))
     ;; In the help string, we need to wrap lines...
     (setq reftex-type-query-help
-          (concat
+          (concat 
            "SELECT A LABEL TYPE:\n--------------------\n"
            (mapconcat
             (lambda(x)
@@ -1060,7 +1058,7 @@
     ;; which allow for some chars from the ref format to be in the buffer.
     ;; These characters will be seen and removed.
     (setq reftex-words-to-typekey-alist
-          (mapcar
+          (mapcar 
            (lambda (x)
              (setq word (car x)
                    typekey (cdr x)
@@ -1113,18 +1111,18 @@
     (setq reftex-key-to-index-macro-alist
           (sort reftex-key-to-index-macro-alist
                 (lambda (a b) (< (downcase (car a)) (downcase (car b))))))
-    (setq reftex-query-index-macro-prompt
+    (setq reftex-query-index-macro-prompt 
           (concat "Index macro: ["
                   (mapconcat (lambda (x) (char-to-string (car x)))
                              reftex-key-to-index-macro-alist "")
                   "]"))
     (setq i 0
           reftex-query-index-macro-help
-          (concat
+          (concat 
            "SELECT A MACRO:\n---------------\n"
            (mapconcat
             (lambda(x)
-              (format "[%c] %-20.20s%s" (car x) (nth 1 x)
+              (format "[%c] %-20.20s%s" (car x) (nth 1 x) 
                       (if (= 0 (mod (incf i) 3)) "\n" "")))
             reftex-key-to-index-macro-alist "")))
 
@@ -1138,11 +1136,11 @@
     (let* (
 ;          (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
            (wbol "\\(^\\)[ \t]*")  ; Need to keep the empty group because
-                                  ;;; because match number are hard coded
+                                  ;;; because match number are hard coded  
            (label-re "\\\\label{\\([^}]*\\)}")
-           (include-re (concat wbol
+           (include-re (concat wbol 
                                "\\\\\\("
-                               (mapconcat 'identity
+                               (mapconcat 'identity 
                                           reftex-include-file-commands "\\|")
                                "\\)[{ \t]+\\([^} \t\n\r]+\\)"))
            (section-re
@@ -1196,7 +1194,7 @@
             reftex-macros-with-labels macros-with-labels
             reftex-find-index-entry-regexp-format find-index-re-format
             reftex-find-label-regexp-format find-label-re-format
-            reftex-find-label-regexp-format2
+            reftex-find-label-regexp-format2 
             "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]")
       (message "Compiling label environment definitions...done")))
   (put reftex-docstruct-symbol 'reftex-cache
@@ -1273,7 +1271,7 @@
   (and (symbolp reftex-docstruct-symbol)
        (symbol-value reftex-docstruct-symbol)
        t))
-
+  
 (defun reftex-silence-toc-markers (list n)
   ;; Set all toc markers in the first N entries in list to nil
   (while (and list (> (decf n) -1))
@@ -1290,7 +1288,7 @@
          (master (reftex-TeX-master-file))
          (enable-local-variables nil)
          (file (if (string-match "\\.[a-zA-Z]+\\'" master)
-                   (concat (substring master 0 (match-beginning 0))
+                   (concat (substring master 0 (match-beginning 0)) 
                            reftex-parse-file-extension)
                  (concat master reftex-parse-file-extension))))
     (cond
@@ -1369,7 +1367,7 @@
 
   ;; Check if the master is the same: when moving a document, this will see it.
   (let* ((real-master (reftex-TeX-master-file))
-         (parsed-master
+         (parsed-master 
           (nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol)))))
     (unless (string= (file-truename real-master) (file-truename parsed-master))
       (message "Master file name in load file is different: %s versus %s"
@@ -1389,7 +1387,7 @@
 (defun reftex-select-external-document (xr-alist xr-index)
   ;; Return index of an external document.
   (let* ((len (length xr-alist)) (highest (1- (+ ?0 len)))
-         (prompt (format "[%c-%c] Select    TAB: Read prefix with completion"
+         (prompt (format "[%c-%c] Select    TAB: Read prefix with completion" 
                          ?0 highest))
          key prefix)
     (cond
@@ -1400,7 +1398,7 @@
       (- 1 xr-index))
      (t
       (save-excursion
-        (let* ((length (apply 'max (mapcar
+        (let* ((length (apply 'max (mapcar 
                                     (lambda(x) (length (car x))) xr-alist)))
                (fmt (format " [%%c]  %%-%ds  %%s\n" length))
                (n (1- ?0)))
@@ -1410,7 +1408,7 @@
                  (concat
                   "SELECT EXTERNAL DOCUMENT\n------------------------\n"
                   (mapconcat
-                   (lambda (x)
+                   (lambda (x) 
                      (format fmt (incf n) (or (car x) "")
                              (abbreviate-file-name (cdr x))))
                    xr-alist ""))
@@ -1434,7 +1432,7 @@
   (let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t)))
          (extensions (cdr (assoc type reftex-file-extensions)))
          (def-ext (car extensions))
-         (ext-re (concat "\\("
+         (ext-re (concat "\\(" 
                          (mapconcat 'regexp-quote extensions "\\|")
                          "\\)\\'"))
          (files (if (string-match ext-re file)
@@ -1443,8 +1441,8 @@
          path old-path file1)
     (cond
      ((file-name-absolute-p file)
-      (setq file1
-            (or
+      (setq file1 
+            (or 
              (and (car files) (file-regular-p (car files)) (car files))
              (and (cdr files) (file-regular-p (cdr files)) (cdr files)))))
      ((and reftex-use-external-file-finders
@@ -1459,10 +1457,10 @@
             (setq old-path path
                   path (cons master-dir path)
                   file1 (or (and (car files)
-                                 (reftex-find-file-on-path
+                                 (reftex-find-file-on-path 
                                   (car files) path master-dir))
                             (and (cdr files)
-                                 (reftex-find-file-on-path
+                                 (reftex-find-file-on-path 
                                   (cdr files) path master-dir))))))))
     (cond (file1 file1)
           (die (error "No such file: %s" file) nil)
@@ -1507,7 +1505,7 @@
            (reftex-uniquify
             (reftex-parse-colon-path
              (mapconcat
-              (lambda(x)
+              (lambda(x) 
                 (if (string-match "^!" x)
                     (apply 'reftex-process-string
                            (split-string (substring x 1)))
@@ -1516,7 +1514,7 @@
               ;;  (cdr (assoc type reftex-path-environment))
               ;; However, historically we have separate options for the
               ;; environment variables, so we have to do this:
-              (symbol-value (intern (concat "reftex-" type
+              (symbol-value (intern (concat "reftex-" type 
                                             "path-environment-variables")))
               path-separator))))
       (put pathvar 'status 'split)
@@ -1542,11 +1540,11 @@
           ;; or:     Relative recursive path elements need to be expanded
           ;;         relative to new default directory
           (message "Expanding search path to find %s file: %s ..." type file)
-          (put pathvar 'recursive-path
+          (put pathvar 'recursive-path 
                (reftex-expand-path (symbol-value pathvar) master-dir))
           (put pathvar 'master-dir master-dir)
           (get pathvar 'recursive-path))
-         (t
+         (t 
           ;; Recursive path computed earlier is still OK.
           (get pathvar 'recursive-path)))
       ;; The simple path was requested
@@ -1575,7 +1573,7 @@
   ;; Trailing ! or !! will be converted into `//' (emTeX convention)
   (mapcar
    (lambda (dir)
-     (if (string-match "\\(//+\\|/*!+\\)\\'" dir)
+     (if (string-match "\\(//+\\|/*!+\\)\\'" dir) 
          (setq dir (replace-match "//" t t dir)))
      (file-name-as-directory dir))
    (delete "" (split-string path (concat path-separator "+")))))
@@ -1604,7 +1602,7 @@
       (when (file-directory-p dir)
         (setq files (nreverse (directory-files dir t "[^.]")))
         (while (setq file (pop files))
-          (if (file-directory-p file)
+          (if (file-directory-p file) 
               (push (file-name-as-directory file) path)))
         (push dir path1)))
     path1))
@@ -1667,7 +1665,7 @@
   "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"
+(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" 
   "Toggle automatic recentering of TOC window." t)
 
 ;;; =========================================================================
@@ -1886,7 +1884,7 @@
     (while list
       (if (funcall predicate (car list))
           (push (if completion
-                    (list (nth nth (car list)))
+                    (list (nth nth (car list))) 
                   (nth nth (car list)))
                 rtn))
       (setq list (cdr list)))
@@ -1922,7 +1920,7 @@
   ;; If POS is given, calculate distances relative to it.
   ;; Return nil if there is no match.
   (let ((pos (point))
-        (dist (or max-length (length regexp)))
+        (dist (or max-length (length regexp)))  
         match1 match2 match)
     (goto-char (min (+ pos dist) (point-max)))
     (when (re-search-backward regexp nil t)
@@ -2008,10 +2006,10 @@
                 ((and scroll (equal char ?\C-? ))
                  (condition-case nil (scroll-down) (error nil))
                  (message prompt))
-                (t (message "")
+                (t (message "") 
                    (throw 'exit char)))
           (setq char (read-char-exclusive)))))))
-
+      
 
 (defun reftex-make-regexp-allow-for-ctrl-m (string)
   ;; convert STRING into a regexp, allowing ^M for \n and vice versa
@@ -2209,10 +2207,10 @@
     ;; Restrict number of words
     (if (> (length words) nwords)
         (setcdr (nthcdr (1- nwords) words) nil))
-
+    
     ;; First, try to use all words
     (setq string (mapconcat 'identity words sep))
-
+  
     ;; Abbreviate words if enforced by user settings or string length
     (if (or (eq t abbrev)
             (and abbrev
@@ -2304,7 +2302,7 @@
               (font-lock-set-defaults-1)
               (reftex-select-font-lock-fontify-region (point-min) (point-max))))
            (t
-            ;; Oops?
+            ;; Oops? 
             (message "Sorry: cannot refontify RefTeX Select buffer."))))
       (rename-buffer oldname))))
 
@@ -2353,7 +2351,7 @@
 
 ;; Initialize the overlays
 (aset reftex-highlight-overlays 0 (reftex-make-overlay 1 1))
-(reftex-overlay-put (aref reftex-highlight-overlays 0)
+(reftex-overlay-put (aref reftex-highlight-overlays 0) 
              'face 'highlight)
 (aset reftex-highlight-overlays 1 (reftex-make-overlay 1 1))
 (reftex-overlay-put (aref reftex-highlight-overlays 1)
@@ -2378,7 +2376,7 @@
 
 ;;; =========================================================================
 ;;;
-;;; Keybindings
+;;; Keybindings 
 
 ;; The default bindings in the mode map.
 (loop for x in
@@ -2398,10 +2396,10 @@
 ;; Bind `reftex-mouse-view-crossref' only when the key is still free
 (if (featurep 'xemacs)
     (unless (key-binding [(shift button2)])
-      (define-key reftex-mode-map [(shift button2)]
+      (define-key reftex-mode-map [(shift button2)] 
         'reftex-mouse-view-crossref))
   (unless (key-binding [(shift mouse-2)])
-    (define-key reftex-mode-map [(shift mouse-2)]
+    (define-key reftex-mode-map [(shift mouse-2)] 
       'reftex-mouse-view-crossref)))
 
 ;; Bind `reftex-view-crossref-from-bibtex' in BibTeX mode map
@@ -2505,7 +2503,7 @@
    ("Reference Style"
     ["Default" (setq reftex-vref-is-default nil
                      reftex-fref-is-default nil)
-     :style radio :selected (not (or reftex-vref-is-default
+     :style radio :selected (not (or reftex-vref-is-default 
                                      reftex-fref-is-default))]
     ["Varioref" (setq reftex-vref-is-default t
                       reftex-fref-is-default nil)
@@ -2540,7 +2538,7 @@
           (list 'reftex-add-index-macros (list 'list (list 'quote (car x))))
           :style 'radio :selected
           (list 'memq (list 'quote (car x))
-                (list 'get 'reftex-docstruct-symbol
+                (list 'get 'reftex-docstruct-symbol 
                       (list 'quote 'reftex-index-macros-style)))))
        reftex-index-macros-builtin))
    "--"
@@ -2549,7 +2547,7 @@
    ("Customize"
     ["Browse RefTeX Group" reftex-customize t]
     "--"
-    ["Build Full Customize Menu" reftex-create-customize-menu
+    ["Build Full Customize Menu" reftex-create-customize-menu 
      (fboundp 'customize-menu-create)])
    ("Documentation"
     ["Info" reftex-info t]
@@ -2565,7 +2563,7 @@
   (interactive)
   (if (fboundp 'customize-menu-create)
       (progn
-        (easy-menu-change
+        (easy-menu-change 
          '("Ref") "Customize"
          `(["Browse RefTeX group" reftex-customize t]
            "--"
@@ -2603,7 +2601,7 @@
 ;;; That's it! ----------------------------------------------------------------
 
 (setq reftex-tables-dirty t)  ; in case this file is evaluated by hand
-(provide 'reftex)
+(provide 'reftex) 
 
 ;;;============================================================================