From 7ac7387b8e5672d84f700e26c8a0ca432da058d1 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 25 Jul 2002 07:03:41 +0000 Subject: [PATCH] Updated to RefTeX 4.18 --- lisp/textmodes/reftex-auc.el | 2 +- lisp/textmodes/reftex-cite.el | 48 +++++++++++++++++++++++++++------ lisp/textmodes/reftex-dcr.el | 2 +- lisp/textmodes/reftex-global.el | 2 +- lisp/textmodes/reftex-index.el | 6 ++++- lisp/textmodes/reftex-parse.el | 5 ++-- lisp/textmodes/reftex-ref.el | 4 +-- lisp/textmodes/reftex-sel.el | 10 ++++++- lisp/textmodes/reftex-toc.el | 6 ++++- lisp/textmodes/reftex-vars.el | 2 +- lisp/textmodes/reftex.el | 7 ++--- 11 files changed, 72 insertions(+), 22 deletions(-) diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el index 4546651da91..c113e165d62 100644 --- a/lisp/textmodes/reftex-auc.el +++ b/lisp/textmodes/reftex-auc.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index ebcfd991829..39d8f26a9a6 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. @@ -164,13 +164,16 @@ (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) @@ -180,6 +183,9 @@ 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 "")) @@ -315,7 +321,7 @@ ;; 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)) @@ -351,10 +357,26 @@ (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")) @@ -375,6 +397,16 @@ 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) diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el index c0af53a9bc6..d7419ad49cc 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; ;; This file is part of GNU Emacs. diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el index d19b45d76de..613a70192c2 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index 5db364c371f..8990c15dc7e 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. @@ -299,6 +299,10 @@ Here are all local bindings. " 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) diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 702682c9f8b..c6a950da6d7 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; ;; This file is part of GNU Emacs. @@ -335,7 +335,8 @@ of master file." (goto-char (point-min)) (if (re-search-forward (concat - "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\(" +; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\(" + "\\(^\\)[^%]*\\\\\\(" (mapconcat 'identity reftex-bibliography-commands "\\|") "\\){[ \t]*\\([^}]+\\)") nil t) (setq files diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index 982062e12f9..d3aaeb518e3 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. @@ -646,7 +646,7 @@ When called with 2 C-u prefix args, disable magic word recognition." 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))) diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el index f59e2a1e03f..f888406c593 100644 --- a/lisp/textmodes/reftex-sel.el +++ b/lisp/textmodes/reftex-sel.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. @@ -49,6 +49,10 @@ During a selection process, these are the local bindings. (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) @@ -75,6 +79,10 @@ During a selection process, these are the local bindings. \\{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) diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 15685939815..c769758430c 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. @@ -62,6 +62,10 @@ Here are all local bindings. " 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) diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 05588d712e6..dca2dc95517 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; This file is part of GNU Emacs. diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 2dca200c0ec..0ccaff9ead1 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -2,7 +2,7 @@ ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Carsten Dominik -;; Version: 4.17 +;; Version: 4.18 ;; 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.17" +(defconst reftex-version "RefTeX version 4.18" "Version string for RefTeX.") (defvar reftex-mode nil @@ -1101,7 +1101,8 @@ This enforces rescanning the buffer on next use." ;; 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 "\\\\\\(" -- 2.39.5