changeset 46612:7522419c4db0

Updated to reftex 4.17
author Carsten Dominik <dominik@science.uva.nl>
date Mon, 22 Jul 2002 10:36:26 +0000
parents ae5b4f42f14c
children 97c52254a77a
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, 219 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/reftex-auc.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-auc.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-auc.el --- RefTeX's interface to AUC TeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/textmodes/reftex-cite.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-cite.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-cite.el --- creating citations with RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
@@ -53,6 +53,15 @@
 
 ;; Find bibtex files
 
+
+(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)
+       (set-syntax-table saved-syntax))))
+
 (defun reftex-default-bibliography ()
   ;; Return the expanded value of `reftex-default-bibliography'.
   ;; The expanded value is cached.
@@ -193,63 +202,64 @@
             (message "Scanning bibliography database %s" buffer1))
 
           (set-buffer buffer1)
-          (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"))
+		 
+		 ;; 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
@@ -390,6 +400,7 @@
             (progn
               (set-buffer (get-buffer-create " *RefTeX-scratch*"))
               (fundamental-mode)
+	      (set-syntax-table reftex-syntax-table-for-bib)
               (erase-buffer)
               (insert entry))
           (widen)
@@ -834,6 +845,7 @@
 
 (defun reftex-format-names (namelist n)
   (let (last (len (length namelist)))
+    (if (= n 0) (setq n len))
     (cond
      ((< len 1) "")
      ((= 1 len) (car namelist))
--- a/lisp/textmodes/reftex-dcr.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-dcr.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 ;;
 
 ;; This file is part of GNU Emacs.
--- a/lisp/textmodes/reftex-global.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-global.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-global.el --- operations on entire documents with RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/textmodes/reftex-index.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-index.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-index.el --- index support with RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
@@ -1819,6 +1819,9 @@
     (unwind-protect
 	(while (re-search-forward re nil t)
 	  (catch 'next-match
+	    (if (and (fboundp reftex-index-verify-function)
+		     (not (funcall reftex-index-verify-function)))
+		(throw 'next-match nil))
 	    (setq match (match-string 0))
 	    (setq mathp
 		  (save-match-data
--- a/lisp/textmodes/reftex-parse.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-parse.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-parse.el --- parser functions for RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 ;;
 
 ;; This file is part of GNU Emacs.
@@ -198,6 +198,7 @@
         toc-entry index-entry next-buf buf)
 
     (catch 'exit
+      (debug)
       (setq file-found (reftex-locate-file file "tex" master-dir))
       (if (and (not file-found)
 	       (setq buf (reftex-get-buffer-visiting file)))
@@ -334,7 +335,10 @@
     (save-excursion
       (goto-char (point-min))
       (if (re-search-forward
-	   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\\\(no\\)?bibliography{[ \t]*\\([^}]+\\)" nil t)
+	   (concat
+	    "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+	    (mapconcat 'identity reftex-bibliography-commands "\\|")
+	    "\\){[ \t]*\\([^}]+\\)") nil t)
 	  (setq files 
 		(split-string (reftex-match-string 3)
 			      "[ \t\n\r]*,[ \t\n\r]*")))))
--- a/lisp/textmodes/reftex-ref.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-ref.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-ref.el --- code to create labels and references with RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/textmodes/reftex-sel.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-sel.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-sel.el --- the selection modes for RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/textmodes/reftex-toc.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-toc.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-toc.el --- RefTeX's table of contents mode
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
@@ -72,6 +72,7 @@
   "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-include-labels-indicator nil)
 (defvar reftex-toc-include-index-indicator nil)
 (defvar reftex-toc-max-level-indicator nil)
@@ -127,7 +128,7 @@
 	 (docstruct-symbol reftex-docstruct-symbol)
 	 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
 	 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
-	 (here-I-am (if rebuild 
+	 (here-I-am (if rebuild
 			(get 'reftex-toc :reftex-data)
 		      (car (reftex-where-am-I))))
 	 offset)
@@ -137,8 +138,14 @@
       (when (or (not reftex-toc-keep-other-windows)
 		(< (window-height) (* 2 window-min-height)))
 	(delete-other-windows))
-      (setq reftex-last-window-height (window-height))  ; remember
-      (split-window)
+
+      (setq reftex-last-window-width (window-width)
+	    reftex-last-window-height (window-height))  ; remember
+      (if reftex-toc-split-windows-horizontally
+	  (split-window-horizontally
+	   (floor (* (frame-width) reftex-toc-split-windows-horizontally-fraction)))
+	(split-window))
+
       (let ((default-major-mode 'reftex-toc-mode))
 	(switch-to-buffer "*toc*")))
 
@@ -237,9 +244,13 @@
 
 (defun reftex-re-enlarge ()
   ;; Enlarge windiw to a remembered size
-  (enlarge-window
-   (max 0 (- (or reftex-last-window-height (window-height))
-	     (window-height)))))
+  (if reftex-toc-split-windows-horizontally
+      (enlarge-window-horizontally
+       (max 0 (- (or reftex-last-window-width (window-width))
+		 (window-width))))
+    (enlarge-window
+     (max 0 (- (or reftex-last-window-height (window-height))
+	       (window-height))))))
 
 (defun reftex-toc-show-help ()
   "Show a summary of special key bindings."
--- a/lisp/textmodes/reftex-vars.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex-vars.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex-vars.el --- configuration variables for RefTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 
 ;; This file is part of GNU Emacs.
 
@@ -136,7 +136,8 @@
       (?s    . "\\citep[see][]{%l}")
       (?a    . "\\citeauthor{%l}")
       (?A    . "\\citeauthor*{%l}")
-      (?y    . "\\citeyear{%l}")))
+      (?y    . "\\citeyear{%l}")
+      (?n    . "\\nocite{%l}")))
     (bibentry "The Bibentry package"
       "\\bibentry{%l}")
     (harvard "The Harvard package"
@@ -205,12 +206,57 @@
   :prefix "reftex-"
   :group 'tex)
 
+
 ;; Table of contents configuration --------------------------------------
 
 (defgroup reftex-table-of-contents-browser nil
   "A multifile table of contents browser."
   :group 'reftex)
 
+(defcustom reftex-include-file-commands '("include" "input")
+  "LaTeX commands which input another file.
+The file name is expected after the command, either in braces or separated
+by whitespace."
+  :group 'reftex-table-of-contents-browser
+  :type '(repeat string))
+
+(defcustom reftex-max-section-depth 12
+  "Maximum depth of section levels in document structure.
+Standard LaTeX needs default is 7, but there are packages for which this
+needs to be larger."
+  :group 'reftex-table-of-contents-browser
+  :type 'integer)
+
+;; LaTeX section commands and level numbers
+(defcustom reftex-section-levels
+  '(
+    ("part"            .  0)
+    ("chapter"         .  1)
+    ("section"         .  2)
+    ("subsection"      .  3)
+    ("subsubsection"   .  4)
+    ("paragraph"       .  5)
+    ("subparagraph"    .  6)
+    ("subsubparagraph" .  7)
+    ("addchap"         . -1) ; KOMA-Script
+    ("addsec"          . -2) ; KOMA-Script
+;;; ("minisec"         . -7) ; KOMA-Script
+    )
+  "Commands and levels used for defining sections in the document.
+This is an alist with each element like (COMMAND-NAME . LEVEL).
+The car of each cons cell is the name of the section macro (without
+the backslash).  The cdr is a number indicating its level.  A negative
+level means the same level as the positive value, but the section will
+never get a number.  The cdr may also be a function which will be called
+to after the section-re matched to determine the level."
+  :group 'reftex-table-of-contents-browser
+  :set 'reftex-set-dirty
+  :type '(repeat
+          (cons (string :tag "sectioning macro" "")
+		(choice
+		 (number :tag "level           " 0)
+		 (symbol :tag "function        " my-level-func)))))
+
 (defcustom reftex-toc-max-level 100
   "*The maximum level of toc entries which will be included in the TOC.
 Section headings with a bigger level will be ignored.  In RefTeX, chapters
@@ -219,6 +265,17 @@
   :group 'reftex-table-of-contents-browser
   :type 'integer)
 
+(defcustom reftex-toc-split-windows-horizontally nil
+  "*Non-nil means, create TOC window by splitting window horizontally."
+  :group 'reftex-table-of-contents-browser
+  :type 'boolean)
+
+(defcustom reftex-toc-split-windows-horizontally-fraction .5
+  "*Fraction of the horizontal width of the frame to be used for TOC window.
+Only relevant when `reftex-toc-split-windows-horizontally' is non-nil."
+  :group 'reftex-table-of-contents-browser
+  :type 'number)
+
 (defcustom reftex-toc-keep-other-windows t
   "*Non-nil means, split the selected window to display the *toc* buffer.
 This helps to keep the window configuration, but makes the *toc* small.
@@ -479,43 +536,6 @@
 		 (nth 0 x)))
 	 reftex-label-alist-builtin)))))
 
-(defcustom reftex-max-section-depth 12
-  "Maximum depth of section levels in document structure.
-Standard LaTeX needs default is 7, but there are packages for which this
-needs to be larger."
-  :group 'reftex-defining-label-environments
-  :type 'integer)
-
-;; LaTeX section commands and level numbers
-(defcustom reftex-section-levels
-  '(
-    ("part"            .  0)
-    ("chapter"         .  1)
-    ("section"         .  2)
-    ("subsection"      .  3)
-    ("subsubsection"   .  4)
-    ("paragraph"       .  5)
-    ("subparagraph"    .  6)
-    ("subsubparagraph" .  7)
-    ("addchap"         . -1) ; KOMA-Script
-    ("addsec"          . -2) ; KOMA-Script
-;;; ("minisec"         . -7) ; KOMA-Script
-    )
-  "Commands and levels used for defining sections in the document.
-This is an alist with each element like (COMMAND-NAME . LEVEL).
-The car of each cons cell is the name of the section macro (without
-the backslash).  The cdr is a number indicating its level.  A negative
-level means the same level as the positive value, but the section will
-never get a number.  The cdr may also be a function which will be called
-to after the section-re matched to determine the level."
-  :group 'reftex-defining-label-environments
-  :set 'reftex-set-dirty
-  :type '(repeat
-          (cons (string :tag "sectioning macro" "")
-		(choice
-		 (number :tag "level           " 0)
-		 (symbol :tag "function        " my-level-func)))))
-
 (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',
@@ -855,6 +875,12 @@
   "Support for referencing bibliographic data with BibTeX."
   :group 'reftex)
 
+(defcustom reftex-bibliography-commands '("bibliography" "nobibliography")
+  "LaTeX commands which specify the BibTeX databases to use with the document."
+  :group 'reftex-citation-support
+  :type '(repeat string))
+
+
 (defvar reftex-bibfile-ignore-list nil) ; compatibility
 (defcustom reftex-bibfile-ignore-regexps nil
   "*List of regular expressions to exclude files in \\bibliography{..}.
@@ -898,7 +924,7 @@
 In the format, the following percent escapes will be expanded.
 
 %l   The BibTeX label of the citation.
-%a   List of author names, see also `reftex-cite-punctuation.
+%a   List of author names, see also `reftex-cite-punctuation'.
 %2a  Like %a, but abbreviate more than 2 authors like Jones et al.
 %A   First author name only.
 %e   Works like %a, but on list of editor names. (%2e and %E work a well)
@@ -1175,6 +1201,14 @@
   :group 'reftex-index-support
   :type 'boolean)
 
+(defcustom reftex-index-verify-function nil
+  "A function which is called  at each match during global indexing.
+If the function returns nil, the current match is skipped."
+  :group 'reftex-index-support
+  :type '(choice
+	  (const :tag "No verification" nil)
+	  (function)))
+
 (defcustom reftex-index-phrases-skip-indexed-matches nil
   "*Non-nil means, skip matches which appear to be indexed already.
 When doing global indexing from the phrases buffer, searches for some
--- a/lisp/textmodes/reftex.el	Mon Jul 22 02:19:34 2002 +0000
+++ b/lisp/textmodes/reftex.el	Mon Jul 22 10:36:26 2002 +0000
@@ -1,8 +1,8 @@
 ;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
-;; Version: 4.16
+;; Author: Carsten Dominik <dominik@science.uva.nl>
+;; Version: 4.17
 ;; Keywords: tex
 
 ;; This file is part of GNU Emacs.
@@ -300,7 +300,7 @@
 ;;; Define the formal stuff for a minor mode named RefTeX.
 ;;;
 
-(defconst reftex-version "RefTeX version 4.16"
+(defconst reftex-version "RefTeX version 4.17"
   "Version string for RefTeX.")
 
 (defvar reftex-mode nil
@@ -312,6 +312,7 @@
 
 (defvar reftex-mode-menu nil)
 (defvar reftex-syntax-table nil)
+(defvar reftex-syntax-table-for-bib nil)
 
 (defvar reftex-auto-view-crossref-timer nil
   "The timer used for auto-view-crossref.")
@@ -371,6 +372,12 @@
 	  (setq reftex-syntax-table (copy-syntax-table (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))
+	  (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
+	  (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
+	  (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
+	  (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
         (run-hooks 'reftex-mode-hook))
     ;; Mode was turned off
     (easy-menu-remove reftex-mode-menu)))
@@ -610,49 +617,49 @@
 ;; The following constants are derived from `reftex-label-alist'.
 
 ;; Prompt used for label type queries directed to the user.
-(defconst reftex-type-query-prompt nil)
+(defvar reftex-type-query-prompt nil)
 
 ;; Help string for label type queries.
-(defconst reftex-type-query-help nil)
+(defvar reftex-type-query-help nil)
 
 ;; Alist relating label type to reference format.
-(defconst reftex-typekey-to-format-alist nil)
+(defvar reftex-typekey-to-format-alist nil)
 
 ;; Alist relating label type to label prefix.
-(defconst reftex-typekey-to-prefix-alist nil)
+(defvar reftex-typekey-to-prefix-alist nil)
 
 ;; Alist relating environments or macros to label type and context regexp.
-(defconst reftex-env-or-mac-alist nil)
+(defvar reftex-env-or-mac-alist nil)
 
 ;; List of special environment parser functions
-(defconst reftex-special-env-parsers nil)
+(defvar reftex-special-env-parsers nil)
 
 ;; List of macros carrying a label.
-(defconst reftex-label-mac-list nil)
+(defvar reftex-label-mac-list nil)
 
 ;; List of environments carrying a label.
-(defconst reftex-label-env-list nil)
+(defvar reftex-label-env-list nil)
 
 ;; List of all typekey letters in use.
-(defconst reftex-typekey-list nil)
+(defvar reftex-typekey-list nil)
 
 ;; Alist relating magic words to a label type.
-(defconst reftex-words-to-typekey-alist nil)
+(defvar reftex-words-to-typekey-alist nil)
 
 ;; The last list-of-labels entry used in a reference.
 (defvar reftex-last-used-reference (list nil nil nil nil))
 
 ;; Alist relating index macros to other info.
-(defconst reftex-key-to-index-macro-alist nil)
+(defvar reftex-key-to-index-macro-alist nil)
 ;; Prompt for index macro queries
-(defconst reftex-query-index-macro-prompt nil)
+(defvar reftex-query-index-macro-prompt nil)
 ;; Help string for index macro queries
-(defconst reftex-query-index-macro-help nil)
+(defvar reftex-query-index-macro-help nil)
 
 ;; The message when follow-mode is suspended
-(defconst reftex-no-follow-message
+(defvar reftex-no-follow-message
   "No follow-mode into unvisited file.  Press SPC to visit it.")
-(defconst reftex-no-info-message
+(defvar reftex-no-info-message
   "%s: info not available, use `\\[reftex-view-crossref]' to get it.")
 
 ;; Global variables used for communication between functions.
@@ -1092,9 +1099,15 @@
 		  reftex-section-levels))
 
     ;; Calculate the regular expressions
-    (let* ((wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
+    (let* (
+;	   (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
+	   (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
 	   (label-re "\\\\label{\\([^}]*\\)}")
-	   (include-re (concat wbol "\\\\\\(include\\|input\\)[{ \t]+\\([^} \t\n\r]+\\)"))
+	   (include-re (concat wbol 
+			       "\\\\\\("
+			       (mapconcat 'identity 
+					  reftex-include-file-commands "\\|")
+			       "\\)[{ \t]+\\([^} \t\n\r]+\\)"))
 	   (section-re
 	    (concat wbol "\\\\\\("
 		    (mapconcat (lambda (x) (regexp-quote (car x)))