Commits

Anonymous committed 9f29fa4

version 4.21

Comments (0)

Files changed (13)

+2002-08-17  Carsten Dominik  <dominik@astro.uva.nl>
+
+	Upgrade to version 4.21.
+
 2003-03-09  Ben Wing  <ben@xemacs.org>
 
 	* Makefile:
 ;;; reftex-auc.el --- RefTeX's interface to AUC TeX
-;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.18
+;; Version: 4.21
 
 ;; This file is part of GNU Emacs.
 
   ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX
   (or (eq t reftex-plug-into-AUCTeX)
       (and (listp reftex-plug-into-AUCTeX)
-	   (nth which reftex-plug-into-AUCTeX))))
+           (nth which reftex-plug-into-AUCTeX))))
 
 (defun reftex-arg-label (optional &optional prompt definition)
   "Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
      ((and definition (reftex-plug-flag 1))
       ;; Create a new label, with a temporary brace for `reftex-what-macro'
       (unwind-protect
-	  (progn (insert "{") (setq label (or (reftex-label nil t) "")))
-	(delete-backward-char 1)))
+          (progn (insert "{") (setq label (or (reftex-label nil t) "")))
+        (delete-backward-char 1)))
      ((and (not definition) (reftex-plug-flag 2))
       ;; Reference a label with RefTeX
       (setq label (reftex-reference nil t)))
      (t
       ;; AUCTeX's default mechanism
       (setq label (completing-read (TeX-argument-prompt optional prompt "Key")
-				   (LaTeX-label-list)))))
+                                   (LaTeX-label-list)))))
     (if (and definition (not (string-equal "" label)))
-	(LaTeX-add-labels label))
+        (LaTeX-add-labels label))
     (TeX-argument-insert label optional)))
 
 (defun reftex-arg-cite (optional &optional prompt definition)
       (setq items (list (or (reftex-citation t) ""))))
      (t
       (setq prompt (concat (if optional "(Optional) " "")
-			   (if prompt prompt "Add key")
-			   ": (default none) "))
+                           (if prompt prompt "Add key")
+                           ": (default none) "))
       (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list)))))
     (apply 'LaTeX-add-bibitems items)
     (TeX-argument-insert (mapconcat 'identity items ",") optional)))
 This is the name of an index, not the entry."
   (let (tag taglist)
     (setq prompt (concat (if optional "(Optional) " "")
-			 (if prompt prompt "Index tag")
-			 ": (default none) "))
+                         (if prompt prompt "Index tag")
+                         ": (default none) "))
     (if (and reftex-support-index (reftex-plug-flag 4))
-	;; Use RefTeX completion
-	(progn
-	  (reftex-access-scan-info nil)
-	  (setq taglist 
-		(cdr (assoc 'index-tags 
-			    (symbol-value reftex-docstruct-symbol)))
-		tag (completing-read prompt (mapcar 'list taglist))))
+        ;; Use RefTeX completion
+        (progn
+          (reftex-access-scan-info nil)
+          (setq taglist 
+                (cdr (assoc 'index-tags 
+                            (symbol-value reftex-docstruct-symbol)))
+                tag (completing-read prompt (mapcar 'list taglist))))
       ;; Just ask like AUCTeX does.
       (setq tag (read-string prompt)))
     (TeX-argument-insert tag optional)))
 argument identify one of multiple indices."
   (let* (tag key)
     (if (and reftex-support-index (reftex-plug-flag 4))
-	(progn
-	  (reftex-access-scan-info nil)
-	  (setq tag (reftex-what-index-tag)
-		key (reftex-index-complete-key (or tag "idx"))))
+        (progn
+          (reftex-access-scan-info nil)
+          (setq tag (reftex-what-index-tag)
+                key (reftex-index-complete-key (or tag "idx"))))
       (setq key (completing-read (TeX-argument-prompt optional prompt "Key")
-				 (LaTeX-index-entry-list))))
+                                 (LaTeX-index-entry-list))))
     (unless (string-equal "" key)
       (LaTeX-add-index-entries key))
     (TeX-argument-insert key optional)))
 (defun reftex-what-index-tag ()
   ;; Look backward to find out what index the macro at point belongs to
   (let ((macro (save-excursion
-		 (and (re-search-backward "\\\\[a-zA-Z*]+" nil t)
-		      (match-string 0))))
-	tag entry)
+                 (and (re-search-backward "\\\\[a-zA-Z*]+" nil t)
+                      (match-string 0))))
+        tag entry)
     (when (and macro
-	       (setq entry (assoc macro reftex-index-macro-alist)))
+               (setq entry (assoc macro reftex-index-macro-alist)))
       (setq tag (nth 1 entry))
       (cond
        ((stringp tag) tag)
        ((integerp tag)
-	(save-excursion
-	  (goto-char (match-end 1))
-	  (or (reftex-nth-arg tag (nth 6 entry)) "idx")))
+        (save-excursion
+          (goto-char (match-end 1))
+          (or (reftex-nth-arg tag (nth 6 entry)) "idx")))
        (t "idx")))))
 
 (defvar LaTeX-label-function)
   (unless reftex-docstruct-symbol
     (reftex-tie-multifile-symbols))
   (when (and reftex-docstruct-symbol
-	     (symbolp reftex-docstruct-symbol))
+             (symbolp reftex-docstruct-symbol))
     (let ((list (get reftex-docstruct-symbol 'reftex-label-alist-style))
-	  entry changed)
+          entry changed)
       (while entry-list
-	(setq entry (pop entry-list))
-	(unless (member entry list)
-	  (setq reftex-tables-dirty t
-		changed t)
-	  (push entry list)))
+        (setq entry (pop entry-list))
+        (unless (member entry list)
+          (setq reftex-tables-dirty t
+                changed t)
+          (push entry list)))
       (when changed
-	(put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
+        (put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
 (defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
 
 (defun reftex-add-section-levels (entry-list)
   (unless reftex-docstruct-symbol
     (reftex-tie-multifile-symbols))
   (when (and reftex-docstruct-symbol
-	     (symbolp reftex-docstruct-symbol))
+             (symbolp reftex-docstruct-symbol))
     (let ((list (get reftex-docstruct-symbol 'reftex-section-levels))
-	  entry changed)
+          entry changed)
       (while entry-list
-	(setq entry (pop entry-list))
-	(unless (member entry list)
-	  (setq reftex-tables-dirty t
-		changed t)
-	  (push entry list)))
+        (setq entry (pop entry-list))
+        (unless (member entry list)
+          (setq reftex-tables-dirty t
+                changed t)
+          (push entry list)))
       (when changed
-	(put reftex-docstruct-symbol 'reftex-section-levels list)))))
+        (put reftex-docstruct-symbol 'reftex-section-levels list)))))
 
 (defun reftex-notice-new-section ()
   (reftex-notice-new 1 'force))
 ;;; reftex-cite.el --- creating citations with RefTeX
-;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.18
+;; Version: 4.21
 
 ;; This file is part of GNU Emacs.
 
 (defmacro reftex-with-special-syntax-for-bib (&rest body)
   `(let ((saved-syntax (syntax-table)))
      (unwind-protect
-	 (progn
-	   (set-syntax-table reftex-syntax-table-for-bib)
-	   ,@body)
+         (progn
+           (set-syntax-table reftex-syntax-table-for-bib)
+           ,@body)
        (set-syntax-table saved-syntax))))
 
 (defun reftex-default-bibliography ()
   ;; Return the expanded value of `reftex-default-bibliography'.
   ;; The expanded value is cached.
   (unless (eq (get 'reftex-default-bibliography :reftex-raw)
-	      reftex-default-bibliography)
+              reftex-default-bibliography)
     (put 'reftex-default-bibliography :reftex-expanded
-	 (reftex-locate-bibliography-files 
-	  default-directory reftex-default-bibliography))
+         (reftex-locate-bibliography-files 
+          default-directory reftex-default-bibliography))
     (put 'reftex-default-bibliography :reftex-raw
-	 reftex-default-bibliography))
+         reftex-default-bibliography))
   (get 'reftex-default-bibliography :reftex-expanded))
 
 (defun reftex-bib-or-thebib ()
   ;; citation
   ;; Find the bof of the current file
   (let* ((docstruct (symbol-value reftex-docstruct-symbol))
-	 (rest (or (member (list 'bof (buffer-file-name)) docstruct)
-		   docstruct))
-	 (bib (assq 'bib rest))
-	 (thebib (assq 'thebib rest))
-	 (bibmem (memq bib rest))
-	 (thebibmem (memq thebib rest)))
+         (rest (or (member (list 'bof (buffer-file-name)) docstruct)
+                   docstruct))
+         (bib (assq 'bib rest))
+         (thebib (assq 'thebib rest))
+         (bibmem (memq bib rest))
+         (thebibmem (memq thebib rest)))
     (when (not (or thebib bib))
       (setq bib (assq 'bib docstruct)
-	    thebib (assq 'thebib docstruct)
-	    bibmem (memq bib docstruct)
-	    thebibmem (memq thebib docstruct)))
+            thebib (assq 'thebib docstruct)
+            bibmem (memq bib docstruct)
+            thebibmem (memq thebib docstruct)))
     (if (> (length bibmem) (length thebibmem))
-	(if bib 'bib nil)
+        (if bib 'bib nil)
       (if thebib 'thebib nil))))
 
 (defun reftex-get-bibfile-list ()
 ;; Find a certain reference in any of the BibTeX files.
 
 (defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill
-				       highlight item return)
+                                       highlight item return)
   ;; Find BibTeX KEY in any file in FILE-LIST in another window.
   ;; If MARK-TO-KILL is non-nil, mark new buffer to kill.
   ;; If HIGHLIGHT is non-nil, highlight the match.
   ;; If RETURN is non-nil, just return the entry.
 
   (let* ((re
-	  (if item 
-	      (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
-	    (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
-		    "[, \t\r\n}]")))
-	 (buffer-conf (current-buffer))
+          (if item 
+              (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
+            (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
+                    "[, \t\r\n}]")))
+         (buffer-conf (current-buffer))
          file buf pos)
 
     (catch 'exit
         (goto-char (point-min))
         (when (re-search-forward re nil t)
           (goto-char (match-beginning 0))
-	  (setq pos (point))
-	  (when return
-	    ;; Just return the relevant entry
-	    (if item (goto-char (match-end 0)))
-	    (setq return (buffer-substring 
-			  (point) (reftex-end-of-bib-entry item)))
-	    (set-buffer buffer-conf)
-	    (throw 'exit return))
-	  (switch-to-buffer-other-window buf)
-	  (goto-char pos)
+          (setq pos (point))
+          (when return
+            ;; Just return the relevant entry
+            (if item (goto-char (match-end 0)))
+            (setq return (buffer-substring 
+                          (point) (reftex-end-of-bib-entry item)))
+            (set-buffer buffer-conf)
+            (throw 'exit return))
+          (switch-to-buffer-other-window buf)
+          (goto-char pos)
           (recenter 0)
           (if highlight
               (reftex-highlight 0 (match-beginning 0) (match-end 0)))
           (throw 'exit (selected-window))))
       (set-buffer buffer-conf)
       (if item
-	  (error "No \\bibitem with citation key %s" key)
-	(error "No BibTeX entry with citation key %s" key)))))
+          (error "No \\bibitem with citation key %s" key)
+        (error "No BibTeX entry with citation key %s" key)))))
 
 (defun reftex-end-of-bib-entry (item)
   (save-excursion 
     (condition-case nil
-	(if item 
-	    (progn (end-of-line)
-		   (re-search-forward
-		    "\\\\bibitem\\|\\end{thebibliography}")
-		   (1- (match-beginning 0)))
-	  (progn (forward-list 1) (point)))
+        (if item 
+            (progn (end-of-line)
+                   (re-search-forward
+                    "\\\\bibitem\\|\\end{thebibliography}")
+                   (1- (match-beginning 0)))
+          (progn (forward-list 1) (point)))
       (error (min (point-max) (+ 300 (point)))))))
 
 ;; Parse bibtex buffers
     ;; Read a regexp, completing on known citation keys.
     (setq default (regexp-quote (reftex-get-bibkey-default)))
     (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 
-			      (symbol-value reftex-docstruct-symbol))))
-	      nil)
-	    nil nil nil 'reftex-cite-regexp-hist)
-	   "[ \t]*&&[ \t]*"))
+          (split-string 
+           (completing-read 
+            (concat
+             "Regex { && Regex...}: "
+             "[" default "]: ")
+            (if reftex-mode
+                (if (fboundp 'LaTeX-bibitem-list)
+                    (LaTeX-bibitem-list)
+                  (cdr (assoc 'bibview-cache 
+                              (symbol-value reftex-docstruct-symbol))))
+              nil)
+            nil nil nil 'reftex-cite-regexp-hist)
+           "[ \t]*&&[ \t]*"))
 
     (if (or (null re-list ) (equal re-list '("")))
-	(setq re-list (list default)))
+        (setq re-list (list default)))
 
     (setq first-re (car re-list)    ; We'll use the first re to find things,
           rest-re  (cdr re-list))   ; the others to narrow down.
             (message "Scanning bibliography database %s" buffer1))
 
           (set-buffer buffer1)
-	  (reftex-with-special-syntax-for-bib
-	   (save-excursion
-	     (goto-char (point-min))
-	     (while (re-search-forward first-re nil t)
-	       (catch 'search-again
-		 (setq key-point (point))
-		 (unless (re-search-backward
-			  "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t)
-		   (throw 'search-again nil))
-		 (setq start-point (point))
-		 (goto-char (match-end 0))
-		 (condition-case nil
-		     (up-list 1)
-		   (error (goto-char key-point)
+          (reftex-with-special-syntax-for-bib
+           (save-excursion
+             (goto-char (point-min))
+             (while (re-search-forward first-re nil t)
+               (catch 'search-again
+                 (setq key-point (point))
+                 (unless (re-search-backward
+                          "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t)
+                   (throw 'search-again nil))
+                 (setq start-point (point))
+                 (goto-char (match-end 0))
+                 (condition-case nil
+                     (up-list 1)
+                   (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")
-			   (string= (downcase (match-string 2)) "comment")
-			   (string= (downcase (match-string 2)) "c")
-			   (< (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"))
-		 
-		 ;; Check if other regexp match as well
-		 (setq re-list rest-re)
-		 (while re-list
-		   (unless (string-match (car re-list) entry)
-		     ;; 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))))
+                 (setq end-point (point))
+                 
+                 ;; Ignore @string, @comment and @c entries or things
+                 ;; outside entries
+                 (when (or (string= (downcase (match-string 2)) "string")
+                           (string= (downcase (match-string 2)) "comment")
+                           (string= (downcase (match-string 2)) "c")
+                           (< (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
+                   (unless (string-match (car re-list) entry)
+                     ;; 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))))
     (setq found-list (nreverse found-list))
 
     ;; Sorting
       (error "Need file name to find thebibliography environment"))
     (while (setq file (pop files))
       (setq buf (reftex-get-file-buffer-force 
-		 file (not reftex-keep-temporary-buffers)))
+                 file (not reftex-keep-temporary-buffers)))
       (unless buf
-	(error "No such file %s" file))
+        (error "No such file %s" file))
       (message "Scanning thebibliography environment in %s" file)
 
       (save-excursion
-	(set-buffer buf)
-	(save-restriction
-	  (widen)
-	  (goto-char (point-min))
-	  (while (re-search-forward 
-		  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
-	    (beginning-of-line 2)
-	    (setq start (point))
-	    (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 
-		    (append entries
+        (set-buffer buf)
+        (save-restriction
+          (widen)
+          (goto-char (point-min))
+          (while (re-search-forward 
+                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
+            (beginning-of-line 2)
+            (setq start (point))
+            (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 
+                    (append entries
                       (mapcar 'reftex-parse-bibitem
-			(delete ""
-				(split-string 
-				 (buffer-substring-no-properties start end)
-				 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
-	    (goto-char end)))))
+                        (delete ""
+                                (split-string 
+                                 (buffer-substring-no-properties start end)
+                                 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
+            (goto-char end)))))
     (unless entries
       (error "No bibitems found"))
 
     ;; Read a regexp, completing on known citation keys.
     (setq default (regexp-quote (reftex-get-bibkey-default)))
     (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 
-			      (symbol-value reftex-docstruct-symbol))))
-	      nil)
-	    nil nil nil 'reftex-cite-regexp-hist)
-	   "[ \t]*&&[ \t]*"))
+          (split-string 
+           (completing-read 
+            (concat
+             "Regex { && Regex...}: "
+             "[" default "]: ")
+            (if reftex-mode
+                (if (fboundp 'LaTeX-bibitem-list)
+                    (LaTeX-bibitem-list)
+                  (cdr (assoc 'bibview-cache 
+                              (symbol-value reftex-docstruct-symbol))))
+              nil)
+            nil nil nil 'reftex-cite-regexp-hist)
+           "[ \t]*&&[ \t]*"))
 
     (if (or (null re-list ) (equal re-list '("")))
-	(setq re-list (list default)))
+        (setq re-list (list default)))
 
     (if (string-match "\\`[ \t]*\\'" (car re-list))
         (error "Empty regular expression"))
 
     (while (and (setq re (pop re-list)) entries)
       (setq entries 
-	    (delq nil (mapcar
-		       (lambda (x)
-			 (if (string-match re (cdr (assoc "&entry" x)))
-			     x nil))
-		       entries))))
+            (delq nil (mapcar
+                       (lambda (x)
+                         (if (string-match re (cdr (assoc "&entry" x)))
+                             x nil))
+                       entries))))
     (setq entries 
-	  (mapcar 
-	    (lambda (x)
-	      (push (cons "&formatted" (reftex-format-bibitem x)) x)
-	      (push (reftex-get-bib-field "&key" x) x)
-	      x)
-	   entries))
+          (mapcar 
+            (lambda (x)
+              (push (cons "&formatted" (reftex-format-bibitem x)) x)
+              (push (reftex-get-bib-field "&key" x) x)
+              x)
+           entries))
 
     entries))
 
   (let* ((macro (reftex-what-macro 1)))
     (save-excursion
       (if (and macro (string-match "cite" (car macro)))
-	  (goto-char (cdr macro)))
+          (goto-char (cdr macro)))
       (skip-chars-backward "^a-zA-Z0-9")
       (reftex-this-word))))
 
             (progn
               (set-buffer (get-buffer-create " *RefTeX-scratch*"))
               (fundamental-mode)
-	      (set-syntax-table reftex-syntax-table-for-bib)
+              (set-syntax-table reftex-syntax-table-for-bib)
               (erase-buffer)
               (insert entry))
           (widen)
   ;; Extract the field FIELDNAME from an ENTRY
   (let ((cell (assoc fieldname entry)))
     (if cell
-	(if format
-	    (format format (cdr cell))
-	  (cdr cell))
+        (if format
+            (format format (cdr cell))
+          (cdr cell))
       "")))
 
 (defun reftex-format-bib-entry (entry)
     (setq authors (reftex-truncate authors 30 t t))
     (when (reftex-use-fonts)
       (put-text-property 0 (length key)     'face
-			 (reftex-verified-face reftex-label-face
-					       'font-lock-constant-face
-					       'font-lock-reference-face)
+                         (reftex-verified-face reftex-label-face
+                                               'font-lock-constant-face
+                                               'font-lock-reference-face)
                          key)
       (put-text-property 0 (length authors) 'face reftex-bib-author-face
                          authors)
   (let ((key "") (text ""))
     (when (string-match "\\`{\\([^}]+\\)}\\([^\000]*\\)" item)
       (setq key (match-string 1 item)
-	    text (match-string 2 item)))
+            text (match-string 2 item)))
     ;; Clean up the text a little bit
     (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
       (setq text (replace-match " " nil t text)))
     (if (string-match "\\`[ \t]+" text)
-	(setq text (replace-match "" nil t text)))
+        (setq text (replace-match "" nil t text)))
     (list
      (cons "&key" key)
      (cons "&text" text)
 (defun reftex-format-bibitem (item)
   ;; Format a \bibitem entry so that it is (relatively) nice to look at.
   (let ((text (reftex-get-bib-field "&text" item))
-	(key  (reftex-get-bib-field "&key" item))
-	(lines nil))
+        (key  (reftex-get-bib-field "&key" item))
+        (lines nil))
 
     ;; Wrap the text into several lines.
     (while (and (> (length text) 70)
-		(string-match " " (substring text 60)))
-	(push (substring text 0 (+ 60 (match-beginning 0))) lines)
-	(setq text (substring text (+ 61 (match-beginning 0)))))
+                (string-match " " (substring text 60)))
+        (push (substring text 0 (+ 60 (match-beginning 0))) lines)
+        (setq text (substring text (+ 61 (match-beginning 0)))))
     (push text lines)
     (setq text (mapconcat 'identity (nreverse lines) "\n     "))
 
   ;; This really does the work of reftex-citation.
 
   (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
-	 (docstruct-symbol reftex-docstruct-symbol)
-	 (selected-entries (reftex-offer-bib-menu))
-	 (insert-entries selected-entries)
-	 entry string cite-view)
+         (docstruct-symbol reftex-docstruct-symbol)
+         (selected-entries (reftex-offer-bib-menu))
+         (insert-entries selected-entries)
+         entry string cite-view)
 
     (unless selected-entries (error "Quit"))
 
     (if (stringp selected-entries)
-	;; Nonexistent entry
-	(setq selected-entries nil
-	      insert-entries (list (list selected-entries
-					 (cons "&key" selected-entries))))
+        ;; Nonexistent entry
+        (setq selected-entries nil
+              insert-entries (list (list selected-entries
+                                         (cons "&key" selected-entries))))
       ;; It makes sense to compute the cite-view strings.
       (setq cite-view t))
 
       ;; All keys go into a single command - we need to trick a little
       (pop selected-entries)
       (let ((concat-keys (mapconcat 'car selected-entries ",")))
-	(setq insert-entries 
-	      (list (list concat-keys (cons "&key" concat-keys))))))
+        (setq insert-entries 
+              (list (list concat-keys (cons "&key" concat-keys))))))
     
     (unless no-insert
 
       (message "Formatting...")
 
       (while (setq entry (pop insert-entries))
-	;; Format the citation and insert it
-	(setq string (if reftex-format-cite-function
-			 (funcall reftex-format-cite-function
-				  (reftex-get-bib-field "&key" entry)
-				  format)
-		       (reftex-format-citation entry format)))
-	(insert string))
+        ;; Format the citation and insert it
+        (setq string (if reftex-format-cite-function
+                         (funcall reftex-format-cite-function
+                                  (reftex-get-bib-field "&key" entry)
+                                  format)
+                       (reftex-format-citation entry format)))
+        (insert string))
 
       ;; Reposition cursor?
       (when (string-match "\\?" string)
-	(search-backward "?")
-	(delete-char 1))
+        (search-backward "?")
+        (delete-char 1))
 
       ;; Tell AUCTeX
       (when (and reftex-mode 
-		 (fboundp 'LaTeX-add-bibitems)
-		 reftex-plug-into-AUCTeX)
-	(apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
+                 (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) 
-		  (reftex-make-cite-echo-string entry docstruct-symbol))
-		selected-entries))
+        (mapcar (lambda (entry) 
+                  (reftex-make-cite-echo-string entry docstruct-symbol))
+                selected-entries))
 
       (message ""))
 
     ;; Check if the prefix arg was numeric, and call recursively
     (when (integerp arg)
       (if (> arg 1)
-	  (progn      
-	    (skip-chars-backward "}")
-	    (decf arg)
-	    (reftex-do-citation arg))
-	(forward-char 1)))
+          (progn      
+            (skip-chars-backward "}")
+            (decf arg)
+            (reftex-do-citation arg))
+        (forward-char 1)))
     
     ;; Return the citation key
     (car (car selected-entries))))
   ;; Check if there is already a cite command at point and change cite format
   ;; in order to only add another reference in the same cite command.
   (let ((macro (car (reftex-what-macro 1)))
-	(cite-format-value (reftex-get-cite-format))
-	key format)
+        (cite-format-value (reftex-get-cite-format))
+        key format)
     (cond
      (no-insert
       ;; Format does not really matter because nothing will be inserted.
       (setq format "%l"))
      
      ((and (stringp macro)
-	   (string-match "\\`\\\\cite\\|cite\\'" macro))
+           (string-match "\\`\\\\cite\\|cite\\'" macro))
       ;; We are already inside a cite macro
       (if (or (not arg) (not (listp arg)))
-	  (setq format
-		(concat
-		 (if (member (preceding-char) '(?\{ ?,)) "" ",")
-		 "%l"
-		 (if (member (following-char) '(?\} ?,)) "" ",")))
-	(setq format "%l")))
+          (setq format
+                (concat
+                 (if (member (preceding-char) '(?\{ ?,)) "" ",")
+                 "%l"
+                 (if (member (following-char) '(?\} ?,)) "" ",")))
+        (setq format "%l")))
      (t
       ;; Figure out the correct format
       (setq format
             (if (and (symbolp cite-format-value)
-		     (assq cite-format-value reftex-cite-format-builtin))
-		(nth 2 (assq cite-format-value reftex-cite-format-builtin))
-	      cite-format-value))
+                     (assq cite-format-value reftex-cite-format-builtin))
+                (nth 2 (assq cite-format-value reftex-cite-format-builtin))
+              cite-format-value))
       (when (listp format)
-	(setq key
-	      (or format-key
-		  (reftex-select-with-char 
-		   "" (concat "SELECT A CITATION FORMAT\n\n"
-			      (mapconcat
-			       (lambda (x)
-				 (format "[%c] %s  %s" (car x)
-					 (if (> (car x) 31) " " "")
-					 (cdr x)))
-			       format "\n")))))
-	(if (assq key format)
-	    (setq format (cdr (assq key format)))
-	  (error "No citation format associated with key `%c'" key)))))
+        (setq key
+              (or format-key
+                  (reftex-select-with-char 
+                   "" (concat "SELECT A CITATION FORMAT\n\n"
+                              (mapconcat
+                               (lambda (x)
+                                 (format "[%c] %s  %s" (car x)
+                                         (if (> (car x) 31) " " "")
+                                         (cdr x)))
+                               format "\n")))))
+        (if (assq key format)
+            (setq format (cdr (assq key format)))
+          (error "No citation format associated with key `%c'" key)))))
     format))
 
 (defun reftex-citep ()
   ;; Offer bib menu and return list of selected items
 
   (let ((bibtype (reftex-bib-or-thebib))
-	found-list rtn key data selected-entries)
+        found-list rtn key data selected-entries)
     (while 
-	(not 
-	 (catch 'done
-	   ;; Scan bibtex files
-	   (setq found-list
-	      (cond
-	       ((eq bibtype 'bib)
-;	       ((assq 'bib (symbol-value reftex-docstruct-symbol))
-		;; using BibTeX database files.
-		(reftex-extract-bib-entries (reftex-get-bibfile-list)))
-	       ((eq bibtype 'thebib)
-;	       ((assq 'thebib (symbol-value reftex-docstruct-symbol))
-		;; using thebibliography environment.
-		(reftex-extract-bib-entries-from-thebibliography
-		 (reftex-uniquify
-		  (mapcar 'cdr
-			  (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"))
+        (not 
+         (catch 'done
+           ;; Scan bibtex files
+           (setq found-list
+              (cond
+               ((eq bibtype 'bib)
+;              ((assq 'bib (symbol-value reftex-docstruct-symbol))
+                ;; using BibTeX database files.
+                (reftex-extract-bib-entries (reftex-get-bibfile-list)))
+               ((eq bibtype 'thebib)
+;              ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+                ;; using thebibliography environment.
+                (reftex-extract-bib-entries-from-thebibliography
+                 (reftex-uniquify
+                  (mapcar 'cdr
+                          (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))
+          ;; 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)
-	    (let ((default-major-mode 'reftex-select-bib-mode))
-	      (reftex-kill-buffer "*RefTeX Select*")
-	      (switch-to-buffer-other-window "*RefTeX Select*")
-	      (unless (eq major-mode 'reftex-select-bib-mode)
-		(reftex-select-bib-mode))
-	      (let ((buffer-read-only nil))
-		(erase-buffer)
-		(reftex-insert-bib-matches found-list)))
-	    (setq buffer-read-only t)
-	    (if (= 0 (buffer-size))
-		(error "No matches found"))
-	    (setq truncate-lines t)
-	    (goto-char 1)
-	    (while t
-	      (setq rtn
-		    (reftex-select-item
-		     reftex-citation-prompt
-		     reftex-citation-help
-		     reftex-select-bib-map
-		     nil
-		     'reftex-bibtex-selection-callback nil))
-	      (setq key (car rtn)
-		    data (nth 1 rtn))
-	      (unless key (throw 'done t))
-	      (cond
-	       ((eq key ?g)
-		;; Start over
-		(throw 'done nil))
-	       ((eq key ?r)
-		;; Restrict with new regular expression
-		(setq found-list (reftex-restrict-bib-matches found-list))
-		(let ((buffer-read-only nil))
-		  (erase-buffer)
-		  (reftex-insert-bib-matches found-list))
-		(goto-char 1))
-	       ((eq key ?A)
-		;; Take all (marked)
-		(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 
-			    (if reftex-select-marked
-				(mapcar 'car (nreverse reftex-select-marked))
-			      found-list)))
-		(throw 'done t))
-	       ((or (eq key ?\C-m)
-		    (eq key 'return))
-		;; Take selected
-		(setq selected-entries 
-		      (if reftex-select-marked
-			  (cons 'concat 
-				(mapcar 'car (nreverse reftex-select-marked)))
-			(if data (list data) nil)))
-		(throw 'done t))
-	       ((stringp key)
-		;; Got this one with completion
-		(setq selected-entries key)
-		(throw 'done t))
-	       (t
-		(ding))))))))
+          ;; Offer selection
+          (save-window-excursion
+            (delete-other-windows)
+            (let ((default-major-mode 'reftex-select-bib-mode))
+              (reftex-kill-buffer "*RefTeX Select*")
+              (switch-to-buffer-other-window "*RefTeX Select*")
+              (unless (eq major-mode 'reftex-select-bib-mode)
+                (reftex-select-bib-mode))
+              (let ((buffer-read-only nil))
+                (erase-buffer)
+                (reftex-insert-bib-matches found-list)))
+            (setq buffer-read-only t)
+            (if (= 0 (buffer-size))
+                (error "No matches found"))
+            (setq truncate-lines t)
+            (goto-char 1)
+            (while t
+              (setq rtn
+                    (reftex-select-item
+                     reftex-citation-prompt
+                     reftex-citation-help
+                     reftex-select-bib-map
+                     nil
+                     'reftex-bibtex-selection-callback nil))
+              (setq key (car rtn)
+                    data (nth 1 rtn))
+              (unless key (throw 'done t))
+              (cond
+               ((eq key ?g)
+                ;; Start over
+                (throw 'done nil))
+               ((eq key ?r)
+                ;; Restrict with new regular expression
+                (setq found-list (reftex-restrict-bib-matches found-list))
+                (let ((buffer-read-only nil))
+                  (erase-buffer)
+                  (reftex-insert-bib-matches found-list))
+                (goto-char 1))
+               ((eq key ?A)
+                ;; Take all (marked)
+                (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 
+                            (if reftex-select-marked
+                                (mapcar 'car (nreverse reftex-select-marked))
+                              found-list)))
+                (throw 'done t))
+               ((or (eq key ?\C-m)
+                    (eq key 'return))
+                ;; Take selected
+                (setq selected-entries 
+                      (if reftex-select-marked
+                          (cons 'concat 
+                                (mapcar 'car (nreverse reftex-select-marked)))
+                        (if data (list data) nil)))
+                (throw 'done t))
+               ((stringp key)
+                ;; Got this one with completion
+                (setq selected-entries key)
+                (throw 'done t))
+               (t
+                (ding))))))))
     selected-entries))
 
 (defun reftex-restrict-bib-matches (found-list)
   ;; Limit FOUND-LIST with more regular expressions
   (let ((re-list (split-string (read-string
-				"RegExp [ && RegExp...]: "
-				nil 'reftex-cite-regexp-hist)
-			       "[ \t]*&&[ \t]*"))
-	(found-list-r found-list)
-	re)
+                                "RegExp [ && RegExp...]: "
+                                nil 'reftex-cite-regexp-hist)
+                               "[ \t]*&&[ \t]*"))
+        (found-list-r found-list)
+        re)
     (while (setq re (pop re-list))
       (setq found-list-r
-	    (delq nil
-		  (mapcar
-		   (lambda (x)
-		     (if (string-match
-			  re (cdr (assoc "&entry" x)))
-			 x
-		       nil))
-		   found-list-r))))
+            (delq nil
+                  (mapcar
+                   (lambda (x)
+                     (if (string-match
+                          re (cdr (assoc "&entry" x)))
+                         x
+                       nil))
+                   found-list-r))))
     (if found-list-r
-	found-list-r
+        found-list-r
       (ding)
       found-list)))
 
 (defun reftex-insert-bib-matches (list)
   ;; Insert the bib matches and number them correctly
   (let ((mouse-face
-	 (if (memq reftex-highlight-selection '(mouse both))
-	     reftex-mouse-selected-face
-	   nil))
-	tmp len)
+         (if (memq reftex-highlight-selection '(mouse both))
+             reftex-mouse-selected-face
+           nil))
+        tmp len)
     (mapcar 
      (lambda (x)
        (setq tmp (cdr (assoc "&formatted" x))
-	     len (length tmp))
+             len (length tmp))
        (put-text-property 0 len :data x tmp)
        (put-text-property 0 (1- len) 'mouse-face mouse-face tmp)
        (insert tmp))
                ((= l ?A) (car (reftex-get-bib-names "author" entry)))
                ((= l ?b) (reftex-get-bib-field "booktitle" entry "in: %s"))
                ((= l ?B) (reftex-abbreviate-title
-			  (reftex-get-bib-field "booktitle" entry "in: %s")))
+                          (reftex-get-bib-field "booktitle" entry "in: %s")))
                ((= l ?c) (reftex-get-bib-field "chapter" entry))
                ((= l ?d) (reftex-get-bib-field "edition" entry))
                ((= l ?e) (reftex-format-names
                ((= l ?r) (reftex-get-bib-field "address" entry))
                ((= l ?t) (reftex-get-bib-field "title" entry))
                ((= l ?T) (reftex-abbreviate-title
-			  (reftex-get-bib-field "title" entry)))
+                          (reftex-get-bib-field "title" entry)))
                ((= l ?v) (reftex-get-bib-field "volume" entry))
                ((= l ?y) (reftex-get-bib-field "year" entry)))))
 
 (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 
-	  (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
-	    (reftex-format-citation entry reftex-cite-view-format)))
-	 (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
-	 (cache-entry (assoc key (cdr cache))))
+         (string 
+          (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
+            (reftex-format-citation entry reftex-cite-view-format)))
+         (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
+         (cache-entry (assoc key (cdr cache))))
     (unless cache
       ;; This docstruct has no cache - make one.
       (set docstruct-symbol (cons (cons 'bibview-cache nil)
-				  (symbol-value docstruct-symbol))))
+                                  (symbol-value docstruct-symbol))))
     (when reftex-cache-cite-echo
       (setq key (copy-sequence key))
       (set-text-properties 0 (length key) nil key)
       (set-text-properties 0 (length string) nil string)
       (if cache-entry
-	  (unless (string= (cdr cache-entry) string)
-	    (setcdr cache-entry string)
-	    (put reftex-docstruct-symbol 'modified t))
-	(push (cons key string) (cdr cache))
-	(put reftex-docstruct-symbol 'modified t)))
+          (unless (string= (cdr cache-entry) string)
+            (setcdr cache-entry string)
+            (put reftex-docstruct-symbol 'modified t))
+        (push (cons key string) (cdr cache))
+        (put reftex-docstruct-symbol 'modified t)))
     string))
 
 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
 
     (catch 'exit
       (save-excursion
-	(set-buffer reftex-call-back-to-this-buffer)
-	(setq bibtype (reftex-bib-or-thebib))
-	(cond
-	 ((eq bibtype 'bib)
-;	 ((assq 'bib (symbol-value reftex-docstruct-symbol))
-	  (setq bibfile-list (reftex-get-bibfile-list)))
-	 ((eq bibtype 'thebib)
-;	 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
-	  (setq bibfile-list
-		(reftex-uniquify
-		 (mapcar 'cdr
-			 (reftex-all-assq 
-			  'thebib (symbol-value reftex-docstruct-symbol))))
-		item t))
-	 (reftex-default-bibliography
-	  (setq bibfile-list (reftex-default-bibliography)))
-	 (t (ding) (throw 'exit nil))))
+        (set-buffer reftex-call-back-to-this-buffer)
+        (setq bibtype (reftex-bib-or-thebib))
+        (cond
+         ((eq bibtype 'bib)
+;        ((assq 'bib (symbol-value reftex-docstruct-symbol))
+          (setq bibfile-list (reftex-get-bibfile-list)))
+         ((eq bibtype 'thebib)
+;        ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+          (setq bibfile-list
+                (reftex-uniquify
+                 (mapcar 'cdr
+                         (reftex-all-assq 
+                          'thebib (symbol-value reftex-docstruct-symbol))))
+                item t))
+         (reftex-default-bibliography
+          (setq bibfile-list (reftex-default-bibliography)))
+         (t (ding) (throw 'exit nil))))
 
       (when no-revisit
-	(setq bibfile-list (reftex-visited-files bibfile-list)))
+        (setq bibfile-list (reftex-visited-files bibfile-list)))
 
       (condition-case nil
-	  (reftex-pop-to-bibtex-entry 
-	   key bibfile-list (not reftex-keep-temporary-buffers) t item)
-	(error (ding))))
+          (reftex-pop-to-bibtex-entry 
+           key bibfile-list (not reftex-keep-temporary-buffers) t item)
+        (error (ding))))
       
     (select-window win)))
 
 ;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
-;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.18
+;; Version: 4.21
 ;;
 
 ;; This file is part of GNU Emacs.
   ;; See where we are.
   (let* ((macro (car (reftex-what-macro-safe 1)))
          (key (reftex-this-word "^{}%\n\r, \t"))
-	 dw)
+         dw)
 
     (if (or (null macro) (reftex-in-comment))
-	(error "Not on a crossref macro argument"))
+        (error "Not on a crossref macro argument"))
 
     (setq reftex-call-back-to-this-buffer (current-buffer))
 
       (setq dw (reftex-view-cr-ref arg key auto-how)))
      (auto-how nil)  ;; No further action for automatic display (speed)
      ((or (equal macro "\\label")
-	  (member macro reftex-macros-with-labels))
+          (member macro reftex-macros-with-labels))
       ;; A label macro: search for reference macros
       (reftex-access-scan-info arg)
       (setq dw (reftex-view-regexp-match
-		(format reftex-find-reference-format (regexp-quote key))
-		4 nil nil)))
+                (format reftex-find-reference-format (regexp-quote key))
+                4 nil nil)))
      ((equal macro "\\bibitem")
       ;; A bibitem macro: search for citations
       (reftex-access-scan-info arg)
       (setq dw (reftex-view-regexp-match
-		(format reftex-find-citation-regexp-format (regexp-quote key))
-		4 nil nil)))
+                (format reftex-find-citation-regexp-format (regexp-quote key))
+                4 nil nil)))
      ((member macro reftex-macros-with-index)
       (reftex-access-scan-info arg)
       (setq dw (reftex-view-regexp-match
-		(format reftex-find-index-entry-regexp-format
-			(regexp-quote key))
-		3 nil nil)))
+                (format reftex-find-index-entry-regexp-format
+                        (regexp-quote key))
+                3 nil nil)))
      (t 
       (reftex-access-scan-info arg)
       (catch 'exit
-	(let ((list reftex-view-crossref-extra)
-	      entry mre action group)
-	  (while (setq entry (pop list))
-	    (setq mre (car entry)
-		  action (nth 1 entry)
-		  group (nth 2 entry))
-	    (when (string-match mre macro)
-	      (setq dw (reftex-view-regexp-match 
-			(format action key) group nil nil))
-	      (throw 'exit t))))
-	(error "Not on a crossref macro argument"))))
+        (let ((list reftex-view-crossref-extra)
+              entry mre action group)
+          (while (setq entry (pop list))
+            (setq mre (car entry)
+                  action (nth 1 entry)
+                  group (nth 2 entry))
+            (when (string-match mre macro)
+              (setq dw (reftex-view-regexp-match 
+                        (format action key) group nil nil))
+              (throw 'exit t))))
+        (error "Not on a crossref macro argument"))))
     (if (and (eq arg 2) (windowp dw)) (select-window dw))))
      
 (defun reftex-view-cr-cite (arg key how)
   (if (eq how 'tmp-window)
       ;; Remember the window configuration
       (put 'reftex-auto-view-crossref 'last-window-conf 
-	   (current-window-configuration)))
+           (current-window-configuration)))
 
   (let (files size item (pos (point)) (win (selected-window)) pop-win
-	      (bibtype (reftex-bib-or-thebib)))
+              (bibtype (reftex-bib-or-thebib)))
     ;; Find the citation mode and the file list
     (cond
 ;     ((assq 'bib (symbol-value reftex-docstruct-symbol))
      ((eq bibtype 'bib)
       (setq item nil
-	    files (reftex-get-bibfile-list)))
+            files (reftex-get-bibfile-list)))
 ;     ((assq 'thebib (symbol-value reftex-docstruct-symbol))
      ((eq bibtype 'thebib)
       (setq item t
-	    files (reftex-uniquify
-		   (mapcar 'cdr
-			   (reftex-all-assq 
-			    'thebib (symbol-value reftex-docstruct-symbol))))))
+            files (reftex-uniquify
+                   (mapcar 'cdr
+                           (reftex-all-assq 
+                            'thebib (symbol-value reftex-docstruct-symbol))))))
      (reftex-default-bibliography
       (setq item nil
-	    files (reftex-default-bibliography)))
+            files (reftex-default-bibliography)))
      (how)  ;; don't throw for special display
      (t (error "Cannot display crossref")))
 
     (if (eq how 'echo)
-	;; Display in Echo area
-	(reftex-echo-cite key files item)
+        ;; Display in Echo area
+        (reftex-echo-cite key files item)
       ;; Display in a window
       (if (not (eq how 'tmp-window))
-	  ;; Normal display
-	  (reftex-pop-to-bibtex-entry key files nil t item)
-	;; A temporary window
-	(condition-case nil
-	    (reftex-pop-to-bibtex-entry key files nil t item)
-	  (error (goto-char pos)
-		 (message "cite: no such citation key %s" key)
-		 (error "")))
-	;; Resize the window
-	(setq size (max 1 (count-lines (point)
-				       (reftex-end-of-bib-entry item))))
-	(let ((window-min-height 2))
-	  (shrink-window (1- (- (window-height) size)))
-	  (recenter 0))
-	;; Arrange restoration
-	(add-hook 'pre-command-hook 'reftex-restore-window-conf))
+          ;; Normal display
+          (reftex-pop-to-bibtex-entry key files nil t item)
+        ;; A temporary window
+        (condition-case nil
+            (reftex-pop-to-bibtex-entry key files nil t item)
+          (error (goto-char pos)
+                 (message "cite: no such citation key %s" key)
+                 (error "")))
+        ;; Resize the window
+        (setq size (max 1 (count-lines (point)
+                                       (reftex-end-of-bib-entry item))))
+        (let ((window-min-height 2))
+          (shrink-window (1- (- (window-height) size)))
+          (recenter 0))
+        ;; Arrange restoration
+        (add-hook 'pre-command-hook 'reftex-restore-window-conf))
 
-	;; Normal display in other window
+        ;; Normal display in other window
       (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
       (setq pop-win (selected-window))
       (select-window win)
       (goto-char pos)
       (when (equal arg 2)
-	(select-window pop-win)))))
+        (select-window pop-win)))))
 
 (defun reftex-view-cr-ref (arg label how)
   ;; View crossreference of a ref macro.  HOW can have the values 
   (if (eq how 'tmp-window)
       ;; Remember the window configuration
       (put 'reftex-auto-view-crossref 'last-window-conf 
-	   (current-window-configuration)))
+           (current-window-configuration)))
 
   (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol)))
-	 (xr-re (nth 2 xr-data))
-	 (entry (assoc label (symbol-value reftex-docstruct-symbol)))
-	 (win (selected-window)) pop-win (pos (point)))
+         (xr-re (nth 2 xr-data))
+         (entry (assoc label (symbol-value reftex-docstruct-symbol)))
+         (win (selected-window)) pop-win (pos (point)))
 
     (if (and (not entry) (stringp label) xr-re (string-match xr-re label))
-	;; Label is defined in external document
-	(save-excursion
-	  (save-match-data
-	    (set-buffer 
-	     (or (reftex-get-file-buffer-force
-		  (cdr (assoc (match-string 1 label) (nth 1
-							  xr-data))))
-		 (error "Problem with external label %s" label))))
-	  (setq label (substring label (match-end 1)))
-	  (reftex-access-scan-info)
-	  (setq entry 
-		(assoc label (symbol-value reftex-docstruct-symbol)))))
+        ;; Label is defined in external document
+        (save-excursion
+          (save-match-data
+            (set-buffer 
+             (or (reftex-get-file-buffer-force
+                  (cdr (assoc (match-string 1 label) (nth 1
+                                                          xr-data))))
+                 (error "Problem with external label %s" label))))
+          (setq label (substring label (match-end 1)))
+          (reftex-access-scan-info)
+          (setq entry 
+                (assoc label (symbol-value reftex-docstruct-symbol)))))
     (if (eq how 'echo)
-	;; Display in echo area
-	(reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol))
+        ;; Display in echo area
+        (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol))
       (let ((window-conf (current-window-configuration)))
-	(condition-case nil
-	    (reftex-show-label-location entry t nil t t)
-	  (error (set-window-configuration window-conf)
-		 (message "ref: Label %s not found" label)
-		 (error "ref: Label %s not found" label)))) ;; 2nd is line OK
+        (condition-case nil
+            (reftex-show-label-location entry t nil t t)
+          (error (set-window-configuration window-conf)
+                 (message "ref: Label %s not found" label)
+                 (error "ref: Label %s not found" label)))) ;; 2nd is line OK
       (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
 
       (when (eq how 'tmp-window)
-	;; Resize window and arrange restauration
-	(shrink-window (1- (- (window-height) 9)))
-	(recenter '(4))
-	(add-hook 'pre-command-hook 'reftex-restore-window-conf))
+        ;; Resize window and arrange restauration
+        (shrink-window (1- (- (window-height) 9)))
+        (recenter '(4))
+        (add-hook 'pre-command-hook 'reftex-restore-window-conf))
       (setq pop-win (selected-window))
       (select-window win)
       (goto-char pos)
       (when (equal arg 2)
-	(select-window pop-win)))))
+        (select-window pop-win)))))
 
 (defun reftex-mouse-view-crossref (ev)
   "View cross reference of \\ref or \\cite macro where you click.
        (or (eq reftex-auto-view-crossref 'window) (not (current-message)))
        ;; Make sure we are not already displaying this one
        (not (memq last-command '(reftex-view-crossref
-				 reftex-mouse-view-crossref)))
+                                 reftex-mouse-view-crossref)))
        ;; Quick precheck if this might be a relevant spot
        ;; FIXME: Can fail with backslash in comment
        (save-excursion  
-	 (search-backward "\\" nil t)
-	 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))
+         (search-backward "\\" nil t)
+         (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))
 
        (condition-case nil
-	   (let ((current-prefix-arg nil))
-	     (cond
-	      ((eq reftex-auto-view-crossref t)
-	       (reftex-view-crossref -1 'echo))
-	      ((eq reftex-auto-view-crossref 'window)
-	       (reftex-view-crossref -1 'tmp-window))
-	      (t nil)))
-	 (error nil))))
+           (let ((current-prefix-arg nil))
+             (cond
+              ((eq reftex-auto-view-crossref t)
+               (reftex-view-crossref -1 'echo))
+              ((eq reftex-auto-view-crossref 'window)
+               (reftex-view-crossref -1 'tmp-window))
+              (t nil)))
+         (error nil))))
 
 (defun reftex-restore-window-conf ()
   (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf))
   (put 'reftex-auto-view-crossref 'last-window-conf nil)
   (remove-hook 'pre-command-hook 'reftex-restore-window-conf))
-		  
+                  
 (defun reftex-echo-ref (label entry docstruct)
   ;; Display crossref info in echo area.
   (cond
       (message "ref(%s): %s" (nth 1 entry) (nth 2 entry)))
     (let ((buf (get-buffer " *Echo Area*")))
       (when buf
-	(save-excursion
-	  (set-buffer buf)
-	  (run-hooks 'reftex-display-copied-context-hook)))))))
+        (save-excursion
+          (set-buffer buf)
+          (run-hooks 'reftex-display-copied-context-hook)))))))
 
 (defun reftex-echo-cite (key files item)
   ;; Display citation info in echo area.
   (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol)))
-	 (cache-entry (assoc key (cdr cache)))
-	 entry string buf (all-files files))
+         (cache-entry (assoc key (cdr cache)))
+         entry string buf (all-files files))
 
     (if (and reftex-cache-cite-echo cache-entry)
-	;; We can just use the cache
-	(setq string (cdr cache-entry))
+        ;; We can just use the cache
+        (setq string (cdr cache-entry))
 
       ;; Need to look in the database
       (unless reftex-revisit-to-echo
-	(setq files (reftex-visited-files files)))
+        (setq files (reftex-visited-files files)))
 
       (setq entry 
-	    (condition-case nil
-		(save-excursion
-		  (reftex-pop-to-bibtex-entry key files nil nil item t))
-	      (error
-	       (if (and files (= (length all-files) (length files)))
-		   (message "cite: no such database entry: %s" key)
-		 (message (substitute-command-keys 
-			   (format reftex-no-info-message "cite"))))
-	       nil)))
+            (condition-case nil
+                (save-excursion
+                  (reftex-pop-to-bibtex-entry key files nil nil item t))
+              (error
+               (if (and files (= (length all-files) (length files)))
+                   (message "cite: no such database entry: %s" key)
+                 (message (substitute-command-keys 
+                           (format reftex-no-info-message "cite"))))
+               nil)))
       (when entry
-	(if item
-	    (setq string (reftex-nicify-text entry))
-	  (setq string (reftex-make-cite-echo-string
-			(reftex-parse-bibtex-entry entry)
-			reftex-docstruct-symbol)))))
+        (if item
+            (setq string (reftex-nicify-text entry))
+          (setq string (reftex-make-cite-echo-string
+                        (reftex-parse-bibtex-entry entry)
+                        reftex-docstruct-symbol)))))
     (unless (or (null string) (equal string ""))
       (message "cite: %s" string))
     (when (setq buf (get-buffer " *Echo Area*"))
       (save-excursion
-	(set-buffer buf)
-	(run-hooks 'reftex-display-copied-context-hook)))))
+        (set-buffer buf)
+        (run-hooks 'reftex-display-copied-context-hook)))))
 
 (defvar reftex-use-itimer-in-xemacs nil
   "*Non-nil means use the idle timers in XEmacs for crossref display.
   (interactive)
   (if reftex-auto-view-crossref-timer
       (progn
-	(if (featurep 'xemacs)
-	    (if reftex-use-itimer-in-xemacs
-		(delete-itimer reftex-auto-view-crossref-timer)
-	      (remove-hook 'post-command-hook 'reftex-start-itimer-once))
-	  (cancel-timer reftex-auto-view-crossref-timer))
-	(setq reftex-auto-view-crossref-timer nil)
-	(message "Automatic display of crossref information was turned off"))
+        (if (featurep 'xemacs)
+            (if reftex-use-itimer-in-xemacs
+                (delete-itimer reftex-auto-view-crossref-timer)
+              (remove-hook 'post-command-hook 'reftex-start-itimer-once))
+          (cancel-timer reftex-auto-view-crossref-timer))
+        (setq reftex-auto-view-crossref-timer nil)
+        (message "Automatic display of crossref information was turned off"))
     (setq reftex-auto-view-crossref-timer
-	  (if (featurep 'xemacs)
-	      (if reftex-use-itimer-in-xemacs
-		  (start-itimer "RefTeX Idle Timer"
-				'reftex-view-crossref-when-idle 
-				reftex-idle-time reftex-idle-time t)
-		(add-hook 'post-command-hook 'reftex-start-itimer-once)
-		t)
-	    (run-with-idle-timer
-	     reftex-idle-time t 'reftex-view-crossref-when-idle)))
+          (if (featurep 'xemacs)
+              (if reftex-use-itimer-in-xemacs
+                  (start-itimer "RefTeX Idle Timer"
+                                'reftex-view-crossref-when-idle 
+                                reftex-idle-time reftex-idle-time t)
+                (add-hook 'post-command-hook 'reftex-start-itimer-once)
+                t)
+            (run-with-idle-timer
+             reftex-idle-time t 'reftex-view-crossref-when-idle)))
     (unless reftex-auto-view-crossref
       (setq reftex-auto-view-crossref t))
     (message "Automatic display of crossref information was turned on")))
 
 (defun reftex-start-itimer-once ()
    (and reftex-mode
-	(not (itimer-live-p reftex-auto-view-crossref-timer))
-	(setq reftex-auto-view-crossref-timer
-	      (start-itimer "RefTeX Idle Timer"
-			    'reftex-view-crossref-when-idle 
-			    reftex-idle-time nil t))))
+        (not (itimer-live-p reftex-auto-view-crossref-timer))
+        (setq reftex-auto-view-crossref-timer
+              (start-itimer "RefTeX Idle Timer"
+                            'reftex-view-crossref-when-idle 
+                            reftex-idle-time nil t))))
 
 (defun reftex-view-crossref-from-bibtex (&optional arg)
   "View location in a LaTeX document which cites the BibTeX entry at point.
     ;; Establish connection to reference buffer
     (unless ref-buffer
       (setq ref-buffer
-	    (save-excursion
-	      (completing-read 
-	       "Reference buffer: "
-	       (delq nil
-		     (mapcar 
-		      (lambda (b)
-			(set-buffer b)
-			(if reftex-mode (list (buffer-name b)) nil))
-		      (buffer-list)))
-	       nil t)))
+            (save-excursion
+              (completing-read 
+               "Reference buffer: "
+               (delq nil
+                     (mapcar 
+                      (lambda (b)
+                        (set-buffer b)
+                        (if reftex-mode (list (buffer-name b)) nil))
+                      (buffer-list)))
+               nil t)))
       (put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer))
     ;; Search for citations
     (bibtex-beginning-of-entry)
     (if (looking-at
-	 "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)")
-	(progn
-	  (goto-char (match-beginning 1))
-	  (reftex-view-regexp-match
-	   (format reftex-find-citation-regexp-format
-		   (regexp-quote (match-string 1)))
-	   4 arg ref-buffer))
+         "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)")
+        (progn
+          (goto-char (match-beginning 1))
+          (reftex-view-regexp-match
+           (format reftex-find-citation-regexp-format
+                   (regexp-quote (match-string 1)))
+           4 arg ref-buffer))
       (error "Cannot find citation key in BibTeX entry"))))
 
 (defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer)
 
   ;;; Decide if new search or continued search
   (let* ((oldprop (get 'reftex-view-regexp-match :props))
-	 (newprop (list (current-buffer) re))
-	 (cont (and (not new) (equal oldprop newprop)))
-	 (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0))
-	 (current-window (selected-window))
-	 (window-conf (current-window-configuration))
-	 match pop-window)
+         (newprop (list (current-buffer) re))
+         (cont (and (not new) (equal oldprop newprop)))
+         (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0))
+         (current-window (selected-window))
+         (window-conf (current-window-configuration))
+         match pop-window)
     (switch-to-buffer-other-window (or ref-buffer (current-buffer)))
     ;; Search
     (condition-case nil
-	(if cont
-	    (setq match (reftex-global-search-continue))
-	  (reftex-access-scan-info)
-	  (setq match (reftex-global-search re (reftex-all-document-files))))
+        (if cont
+            (setq match (reftex-global-search-continue))
+          (reftex-access-scan-info)
+          (setq match (reftex-global-search re (reftex-all-document-files))))
       (error nil))
     ;; Evaluate the match.
     (if match
-	(progn
-	  (put 'reftex-view-regexp-match :props newprop)
-	  (put 'reftex-view-regexp-match :cnt (incf cnt))
-	  (reftex-highlight 0 (match-beginning highlight-group)
-			    (match-end highlight-group))
-	  (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
-	  (setq pop-window (selected-window)))
+        (progn
+          (put 'reftex-view-regexp-match :props newprop)
+          (put 'reftex-view-regexp-match :cnt (incf cnt))
+          (reftex-highlight 0 (match-beginning highlight-group)
+                            (match-end highlight-group))
+          (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
+          (setq pop-window (selected-window)))
       (put 'reftex-view-regexp-match :props nil)
       (or cont (set-window-configuration window-conf)))
     (select-window current-window)
     (if match
-	(progn
-	  (message "Match Nr. %s" cnt)
-	  pop-window)
+        (progn
+          (message "Match Nr. %s" cnt)
+          pop-window)
       (if cont
-	  (error "No further matches (total number of matches: %d)" cnt)
-	(error "No matches")))))
+          (error "No further matches (total number of matches: %d)" cnt)
+        (error "No matches")))))
 
 (defvar reftex-global-search-marker (make-marker))
 (defun reftex-global-search (regexp file-list)
   (unless (get 'reftex-global-search :file-list)
     (error "No global search to continue"))
   (let* ((file-list (get 'reftex-global-search :file-list))
-	 (regexp (get 'reftex-global-search :regexp))
-	 (buf (or (marker-buffer reftex-global-search-marker)
-		  (reftex-get-file-buffer-force (car file-list))))
-	 (pos (or (marker-position reftex-global-search-marker) 1))
-	 file)
+         (regexp (get 'reftex-global-search :regexp))
+         (buf (or (marker-buffer reftex-global-search-marker)
+                  (reftex-get-file-buffer-force (car file-list))))
+         (pos (or (marker-position reftex-global-search-marker) 1))
+         file)
     ;; Take up starting position
     (unless buf (error "No such buffer %s" buf))
     (switch-to-buffer buf)
     (goto-char pos)
     ;; Search and switch file if necessary
     (if (catch 'exit
-	  (while t
-	    (when (re-search-forward regexp nil t)
-	      (move-marker reftex-global-search-marker (point))
-	      (throw 'exit t))
-	    ;; No match - goto next file
-	    (pop file-list)
-	    (or file-list (throw 'exit nil))
-	    (setq file (car file-list)
-		  buf (reftex-get-file-buffer-force file))
-	    (unless buf (error "Cannot access file %s" file))
-	    (put 'reftex-global-search :file-list file-list)
-	    (switch-to-buffer buf)
-	    (widen)
-	    (goto-char 1)))
-	t
+          (while t
+            (when (re-search-forward regexp nil t)
+              (move-marker reftex-global-search-marker (point))
+              (throw 'exit t))
+            ;; No match - goto next file
+            (pop file-list)
+            (or file-list (throw 'exit nil))
+            (setq file (car file-list)
+                  buf (reftex-get-file-buffer-force file))
+            (unless buf (error "Cannot access file %s" file))
+            (put 'reftex-global-search :file-list file-list)
+            (switch-to-buffer buf)
+            (widen)
+            (goto-char 1)))
+        t
       (move-marker reftex-global-search-marker nil)
       (error "All files processed"))))
 
 ;;; reftex-global.el --- operations on entire documents with RefTeX
-;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.18
+;; Version: 4.21
 
 ;; This file is part of GNU Emacs.
 
   (reftex-access-scan-info t)
 
   (let ((master (reftex-TeX-master-file))
-	(cnt 0)
+        (cnt 0)
         (dlist
          (mapcar
-	  (lambda (x)
-	    (let (x1)
-	      (cond
-	       ((memq (car x)
-		      '(toc bof eof bib thebib label-numbers xr xr-doc
-			    master-dir file-error bibview-cache appendix
-			    is-multi index))
-		nil)
-	       (t
-		(setq x1 (reftex-all-assoc-string
-			  (car x) (symbol-value reftex-docstruct-symbol)))
-		(if (< 1 (length x1))
-		    (append (list (car x))
-			    (mapcar (lambda(x)
-				      (abbreviate-file-name (nth 3 x)))
-				    x1))
-		  (list nil))))))
+          (lambda (x)
+            (let (x1)
+              (cond
+               ((memq (car x)
+                      '(toc bof eof bib thebib label-numbers xr xr-doc
+                            master-dir file-error bibview-cache appendix
+                            is-multi index))
+                nil)
+               (t
+                (setq x1 (reftex-all-assoc-string
+                          (car x) (symbol-value reftex-docstruct-symbol)))
+                (if (< 1 (length x1))
+                    (append (list (car x))
+                            (mapcar (lambda(x)
+                                      (abbreviate-file-name (nth 3 x)))
+                                    x1))
+                  (list nil))))))
           (reftex-uniquify-by-car (symbol-value reftex-docstruct-symbol)))))
 
     (setq dlist (reftex-uniquify-by-car dlist))
     (insert " -------------------------------------------------------------\n")
     (use-local-map (make-sparse-keymap))
     (local-set-key [?q] (lambda () "Kill this buffer." (interactive)
-			  (kill-buffer (current-buffer)) (delete-window)))
+                          (kill-buffer (current-buffer)) (delete-window)))
     (local-set-key [?r] 'reftex-change-label)
     (while dlist
       (when (and (car (car dlist))
                  (cdr (car dlist)))
-	(incf cnt)
+        (incf cnt)
         (insert (mapconcat 'identity (car dlist) "\n    ") "\n"))
       (pop dlist))
     (goto-char (point-min))
       (message "Document does not contain duplicate labels."))))
 
 (defun reftex-change-label (&optional from to)
-  "Run `query-replace-regexp' of FROM with TO in all \\label and \\ref commands.
+  "Run `query-replace-regexp' of FROM with TO in all macro arguments.
 Works on the entire multifile document.
 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
 with the command \\[tags-loop-continue].
       (setq to (read-string (format "Replace label %s with: "
                                     from))))
     (reftex-query-replace-document
-     (concat "\\\\\\(label\\|[a-zA-Z]*ref\\){" (regexp-quote from) "}")
-     (format "\\\\\\1{%s}" to))))
+     (concat "{" (regexp-quote from) "}")
+     (format "{%s}" to))))
 
 (defun reftex-renumber-simple-labels ()
   "Renumber all simple labels in the document to make them sequentially.
   (reftex-access-scan-info 1)
   ;; Get some insurance
   (if (and (reftex-is-multi)
-	   (not (yes-or-no-p "Replacing all simple labels in multiple files is risky.  Continue? ")))
+           (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 "\\|") 
-			  "\\)"))
-	 (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
-	 (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]"))
-	 (error-fmt "Undefined label or reference %s. Ignore and continue? ")
-	 (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0))
-				      reftex-typekey-to-prefix-alist))
-	 (files (reftex-all-document-files))
-	 (list (symbol-value reftex-docstruct-symbol))
-	 translate-alist n entry label new-label nr-cell changed-sequence)
+                          (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|") 
+                          "\\)"))
+         (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
+         (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]"))
+         (error-fmt "Undefined label or reference %s. Ignore and continue? ")
+         (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0))
+                                      reftex-typekey-to-prefix-alist))
+         (files (reftex-all-document-files))
+         (list (symbol-value reftex-docstruct-symbol))
+         translate-alist n entry label new-label nr-cell changed-sequence)
 
     (while (setq entry (pop list))
       (when (and (stringp (car entry))
-		 (string-match label-re (car entry)))
-	(setq label (car entry)
-	      nr-cell (assoc (match-string 1 (car entry))
-			     label-numbers-alist))
-	(if (assoc label translate-alist)
-	    (error "Duplicate label %s" label))
-	(setq new-label (concat (match-string 1 (car entry))
-				(int-to-string (incf (cdr nr-cell)))))
-	(push (cons label new-label) translate-alist)
-	(or (string= label new-label) (setq changed-sequence t))))
+                 (string-match label-re (car entry)))
+        (setq label (car entry)
+              nr-cell (assoc (match-string 1 (car entry))
+                             label-numbers-alist))
+        (if (assoc label translate-alist)
+            (error "Duplicate label %s" label))
+        (setq new-label (concat (match-string 1 (car entry))
+                                (int-to-string (incf (cdr nr-cell)))))
+        (push (cons label new-label) translate-alist)
+        (or (string= label new-label) (setq changed-sequence t))))
 
     (unless changed-sequence
       (error "Simple labels are already in correct sequence"))
 
     ;; First test to check for erros
     (setq n (reftex-translate 
-	     files search-re translate-alist error-fmt 'test))
+             files search-re translate-alist error-fmt 'test))
 
     ;; Now the real thing.
     (if (yes-or-no-p 
-	 (format "Replace %d items at %d places in %d files? "
-		 (length translate-alist) n (length files)))
-	(progn
-	  (let ((inhibit-quit t))  ;; Do not disturb...
-	    (reftex-translate
-	     files search-re translate-alist error-fmt nil)
-	    (setq quit-flag nil))
-	  (if (and (reftex-is-multi)
-		   (yes-or-no-p "Save entire document? "))
-	      (reftex-save-all-document-buffers))
-	  ;; Rescan again...
-	  (reftex-access-scan-info 1)
-	  (message "Done replacing simple labels."))
+         (format "Replace %d items at %d places in %d files? "
+                 (length translate-alist) n (length files)))
+        (progn
+          (let ((inhibit-quit t))  ;; Do not disturb...
+            (reftex-translate
+             files search-re translate-alist error-fmt nil)
+            (setq quit-flag nil))
+          (if (and (reftex-is-multi)
+                   (yes-or-no-p "Save entire document? "))
+              (reftex-save-all-document-buffers))
+          ;; Rescan again...
+          (reftex-access-scan-info 1)
+          (message "Done replacing simple labels."))
       (message "No replacements done"))))
 
 (defun reftex-translate (files search-re translate-alist error-fmt test)
     (while (setq file (pop files))
       (setq buf (reftex-get-file-buffer-force file))
       (unless buf
-	(error "No such file %s" file))
+        (error "No such file %s" file))
       (set-buffer buf)
       (save-excursion
-	(save-restriction
-	  (widen)
-	  (goto-char (point-min))
-	  (while (re-search-forward search-re nil t)
-	    (backward-char)
-	    (save-excursion
-	      (setq label (reftex-match-string 1)
-		    cell (assoc label translate-alist)
-		    match-data (match-data)
-		    macro (reftex-what-macro 1)
-		    pos (cdr macro))
-	      (goto-char (or pos (point)))
-	      (when (and macro
-			 (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 
-					  reftex-find-label-regexp-format
-					  (regexp-quote label)))))
-		;; OK, we should replace it.
-		(set-match-data match-data)
-		(cond
-		 ((and test (not cell))
-		  ;; We've got a problem
-		  (unwind-protect
-		      (progn
-			(reftex-highlight 1 (match-beginning 0) (match-end 0))
-			(ding)
-			(or (y-or-n-p (format error-fmt label))
-			    (error "Abort")))
-		    (reftex-unhighlight 1)))
-		 ((and test cell)
-		  (incf n))
-		 ((and (not test) cell)
-		  ;; Replace
-		  (goto-char (match-beginning 1))
-		  (delete-region (match-beginning 1) (match-end 1))
-		  (insert (cdr cell)))
-		 (t nil))))))))
+        (save-restriction
+          (widen)
+          (goto-char (point-min))
+          (while (re-search-forward search-re nil t)
+            (backward-char)
+            (save-excursion
+              (setq label (reftex-match-string 1)
+                    cell (assoc label translate-alist)
+                    match-data (match-data)
+                    macro (reftex-what-macro 1)
+                    pos (cdr macro))
+              (goto-char (or pos (point)))
+              (when (and macro
+                         (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 
+                                          reftex-find-label-regexp-format
+                                          (regexp-quote label)))))
+                ;; OK, we should replace it.
+                (set-match-data match-data)
+                (cond
+                 ((and test (not cell))
+                  ;; We've got a problem
+                  (unwind-protect
+                      (progn
+                        (reftex-highlight 1 (match-beginning 0) (match-end 0))
+                        (ding)
+                        (or (y-or-n-p (format error-fmt label))
+                            (error "Abort")))
+                    (reftex-unhighlight 1)))
+                 ((and test cell)
+                  (incf n))
+                 ((and (not test) cell)
+                  ;; Replace
+                  (goto-char (match-beginning 1))
+                  (delete-region (match-beginning 1) (match-end 1))
+                  (insert (cdr cell)))
+                 (t nil))))))))
     n))
 
 (defun reftex-save-all-document-buffers ()
 labels."
   (interactive)
   (let ((files (reftex-all-document-files))
-	file buffer)
+        file buffer)
     (save-excursion
       (while (setq file (pop files))
-	(setq buffer (reftex-get-buffer-visiting file))
-	(when buffer
-	  (set-buffer buffer)
-	  (save-buffer))))))
+        (setq buffer (reftex-get-buffer-visiting file))
+        (when buffer
+          (set-buffer buffer)
+          (save-buffer))))))
 
 (defun reftex-ensure-write-access (files)
   "Make sure we have write access to all files in FILES.
   (let (file buf)
     (while (setq file (pop files))
       (unless (file-exists-p file)
-	(ding)
-	(or (y-or-n-p (format "No such file %s. Continue? " file))
-	    (error "Abort")))
+        (ding)
+        (or (y-or-n-p (format "No such file %s. Continue? " file))
+            (error "Abort")))
       (unless (file-writable-p file)
-	(ding)
-	(or (y-or-n-p (format "No write access to %s. Continue? " file))
-	    (error "Abort")))
+        (ding)
+        (or (y-or-n-p (format "No write access to %s. Continue? " file))
+            (error "Abort")))
       (when (and (setq buf (reftex-get-buffer-visiting file))
-		 (save-excursion
-		   (set-buffer buf)
-		   buffer-read-only))
-	(ding)
-	(or (y-or-n-p (format "Buffer %s is read-only. Continue? "
-			      (buffer-name buf)))
-	    (error "Abort"))))))
+                 (save-excursion
+                   (set-buffer buf)
+                   buffer-read-only))
+        (ding)
+        (or (y-or-n-p (format "Buffer %s is read-only. Continue? "
+                              (buffer-name buf)))
+            (error "Abort"))))))
 
 ;;; reftex-global.el ends here
 ;;; reftex-index.el --- index support with RefTeX
-;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.18
+;; Version: 4.21
 
 ;; This file is part of GNU Emacs.
 
 (require 'reftex)
 ;;;
 
+;; START remove for XEmacs release
+(defvar mark-active)
+(defvar zmacs-regions)
+(defvar transient-mark-mode)
+;; END remove for XEmacs release
 (defun reftex-index-selection-or-word (&optional arg phrase)
   "Put selection or the word near point into the default index macro.
 This uses the information in `reftex-index-default-macro' to make an index
 `reftex-index-math-format', which see."
   (interactive "P")
   (let* ((use-default (not (equal arg '(16))))  ; check for double prefix
-	 ;; check if we have an active selection
-	 (active (if (boundp 'zmacs-regions)
-		     (and zmacs-regions (region-exists-p))  ; XEmacs
-		   (and transient-mark-mode mark-active)))  ; Emacs
-	 (beg (if active 
-		  (region-beginning)
-		(save-excursion 
-		  (skip-syntax-backward "w\\") (point))))
-	 (end (if active
-		  (region-end)
-		(save-excursion 
-		  (skip-syntax-forward "w\\") (point))))
-	 (sel (buffer-substring beg end))
-	 (mathp (condition-case nil (texmathp) (error nil)))
-	 (current-prefix-arg nil) ; we want to call reftex-index without prefi