;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
(let* (re-list first-re rest-re
(buffer-list (if (listp buffers) buffers (list buffers)))
found-list entry buffer1 buffer alist
- key-point start-point end-point)
+ key-point start-point end-point default)
;; Read a regexp, completing on known citation keys.
+ (setq default (regexp-quote (reftex-get-bibkey-default)))
(setq re-list
(split-string
(completing-read
- "RegExp [ && RegExp...]: "
+ (concat
+ "Regex { && Regex...}: "
+ "[" default "]: ")
(if reftex-mode
(if (fboundp 'LaTeX-bibitem-list)
(LaTeX-bibitem-list)
nil nil nil 'reftex-cite-regexp-hist)
"[ \t]*&&[ \t]*"))
+ (if (or (null re-list ) (equal re-list '("")))
+ (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.
(if (string-match "\\`[ \t]*\\'" (or first-re ""))
;; Parsing is not as good as for the BibTeX database stuff.
;; The environment should be located in file FILE.
- (let* (start end buf entries re re-list file)
+ (let* (start end buf entries re re-list file default)
(unless files
(error "Need file name to find thebibliography environment"))
(while (setq file (pop files))
(unless entries
(error "No bibitems found"))
- (setq re-list (split-string
- (read-string "RegExp [ && RegExp...]: "
- nil 'reftex-cite-regexp-hist)
- "[ \t]*&&[ \t]*"))
+ ;; 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]*"))
+
+ (if (or (null re-list ) (equal re-list '("")))
+ (setq re-list (list default)))
+
(if (string-match "\\`[ \t]*\\'" (car re-list))
(error "Empty regular expression"))
entries))
+(defun reftex-get-bibkey-default ()
+ ;; Return the word before the cursor. If the cursor is in a
+ ;; citation macro, return the word before the macro.
+ (let* ((macro (reftex-what-macro 1)))
+ (save-excursion
+ (if (and macro (string-match "cite" (car macro)))
+ (goto-char (cdr macro)))
+ (skip-chars-backward "^a-zA-Z0-9")
+ (reftex-this-word))))
+
;; Parse and format individual entries
(defun reftex-get-bib-names (field entry)
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;;
;; This file is part of GNU Emacs.
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
" R<" 'reftex-index-restriction-indicator ">"
" -%-"))
(setq truncate-lines t)
+ (when (featurep 'xemacs)
+ ;; XEmacs needs the call to make-local-hook
+ (make-local-hook 'post-command-hook)
+ (make-local-hook 'pre-command-hook))
(make-local-variable 'reftex-last-follow-point)
(easy-menu-add reftex-index-menu reftex-index-map)
(add-hook 'post-command-hook 'reftex-index-post-command-hook nil t)
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;;
;; This file is part of GNU Emacs.
(goto-char (point-min))
(if (re-search-forward
(concat
- "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+ "\\(^\\)[^%]*\\\\\\("
(mapconcat 'identity reftex-bibliography-commands "\\|")
"\\){[ \t]*\\([^}]+\\)") nil t)
(setq files
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
selection-buffers)
(reftex-kill-temporary-buffers))
;; Add the prefixes, put together the relevant information in the form
- ;; (LABEL TYPEKEY SEPERATOR) and return a list of those.
+ ;; (LABEL TYPEKEY SEPARATOR) and return a list of those.
(mapcar (lambda (x)
(if (listp x)
(list (concat prefix (car (car x)))
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
(interactive)
(kill-all-local-variables)
+ (when (featurep 'xemacs)
+ ;; XEmacs needs the call to make-local-hook
+ (make-local-hook 'pre-command-hook)
+ (make-local-hook 'post-command-hook))
(setq major-mode 'reftex-select-label-mode
mode-name "LSelect")
(set (make-local-variable 'reftex-select-marked) nil)
\\{reftex-select-label-map}"
(interactive)
(kill-all-local-variables)
+ (when (featurep 'xemacs)
+ ;; XEmacs needs the call to make-local-hook
+ (make-local-hook 'pre-command-hook)
+ (make-local-hook 'post-command-hook))
(setq major-mode 'reftex-select-bib-mode
mode-name "BSelect")
(set (make-local-variable 'reftex-select-marked) nil)
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
" T<" 'reftex-toc-max-level-indicator ">"
" -%-"))
(setq truncate-lines t)
+ (when (featurep 'xemacs)
+ ;; XEmacs needs the call to make-local-hook
+ (make-local-hook 'post-command-hook)
+ (make-local-hook 'pre-command-hook))
(make-local-variable 'reftex-last-follow-point)
(add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
(add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t)
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; This file is part of GNU Emacs.
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
-;; Version: 4.17
+;; Version: 4.18
;; Keywords: tex
;; This file is part of GNU Emacs.
;;; Define the formal stuff for a minor mode named RefTeX.
;;;
-(defconst reftex-version "RefTeX version 4.17"
+(defconst reftex-version "RefTeX version 4.18"
"Version string for RefTeX.")
(defvar reftex-mode nil
;; Calculate the regular expressions
(let* (
; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
- (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
+ (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because
+ ;;; because match number are hard coded
(label-re "\\\\label{\\([^}]*\\)}")
(include-re (concat wbol
"\\\\\\("