aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2005-01-14 10:12:03 +0000
committerCarsten Dominik2005-01-14 10:12:03 +0000
commitf3c18bd097dfc12ce31e3002c1b1743ffa811f1f (patch)
treed9f2e551aa1182ec885d5143784ecf3c73ae92c1
parent1b1c49e1b3d20b1f4222cdd22371cc1b235fa7d8 (diff)
downloademacs-f3c18bd097dfc12ce31e3002c1b1743ffa811f1f.tar.gz
emacs-f3c18bd097dfc12ce31e3002c1b1743ffa811f1f.zip
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
* reftex-cite.el (reftex-bib-sort-year): Catch the case if the year is not given. * reftex-ref.el (reftex-replace-prefix-escapes): Added new escapes %m and %M, fixed bug with %F by adding save-match-data. (reftex-reference): Removed ?. from list of spaces. (reftex-label-info): Added automatic label prefix recognition * reftex-index.el (reftex-index-next-phrase): Added slave parameter to call of `reftex-index-this-phrase' (reftex-index-this-phrase): New optional argument (reftex-index-region-phrases): Added slave parameter to call of `reftex-index-this-phrase' (reftex-display-index): New argument redo (reftex-index-rescan): Added 'redo to arguments of `reftex-display-index' (reftex-index-Rescan, reftex-index-revert) (reftex-index-switch-index-tag): Added 'redo to arguments of `reftex-display-index' (reftex-index-make-phrase-regexp): Fixed bug with case-sensitive indexing. Fixed bug with matching is there is a quote before or after the word. * reftex-cite.el (reftex-all-used-citation-keys): Fix bug when collecting citation keys in lines with comments. (reftex-citation): Prefix argument no longer rescans the document, but forces prompting for optional arguments of cite macros. (reftex-do-citation): Prompting for optional arguments implemented. * reftex-vars.el (reftex-cite-format-builtin): Added optional arguments to most cite commands. (reftex-cite-cleanup-optional-args): New option (reftex-cite-prompt-optional-args): New option. (reftex-trust-label-prefix): New option * reftex-toc.el (reftex-toc-find-section): Added push-mark before changing the position in the buffer. * reftex.el (reftex-prefix-to-typekey-alist): New variable (reftex-compile-variables): Compute reftex-prefix-to-typekey-alist
-rw-r--r--lisp/textmodes/reftex-auc.el4
-rw-r--r--lisp/textmodes/reftex-cite.el149
-rw-r--r--lisp/textmodes/reftex-dcr.el4
-rw-r--r--lisp/textmodes/reftex-global.el4
-rw-r--r--lisp/textmodes/reftex-index.el45
-rw-r--r--lisp/textmodes/reftex-parse.el4
-rw-r--r--lisp/textmodes/reftex-ref.el97
-rw-r--r--lisp/textmodes/reftex-sel.el18
-rw-r--r--lisp/textmodes/reftex-toc.el9
-rw-r--r--lisp/textmodes/reftex-vars.el108
-rw-r--r--lisp/textmodes/reftex.el19
11 files changed, 351 insertions, 110 deletions
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index 534e4e7b27b..93cd0757b4e 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -1,8 +1,8 @@
1;;; reftex-auc.el --- RefTeX's interface to AUCTeX 1;;; reftex-auc.el --- RefTeX's interface to AUCTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index cfebdbdced1..54dc46eac4f 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1,8 +1,8 @@
1;;; reftex-cite.el --- creating citations with RefTeX 1;;; reftex-cite.el --- creating citations with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -49,11 +49,11 @@
49 TAB Enter citation key with completion. 49 TAB Enter citation key with completion.
50 RET Accept current entry (also on mouse-2) and create \\cite macro. 50 RET Accept current entry (also on mouse-2) and create \\cite macro.
51 m / u Mark/Unmark the entry. 51 m / u Mark/Unmark the entry.
52 e / E Create BibTeX file with all (marked/unmarked) entries
52 a / A Put all (marked) entries into one/many \\cite commands.") 53 a / A Put all (marked) entries into one/many \\cite commands.")
53 54
54;; Find bibtex files 55;; Find bibtex files
55 56
56
57(defmacro reftex-with-special-syntax-for-bib (&rest body) 57(defmacro reftex-with-special-syntax-for-bib (&rest body)
58 `(let ((saved-syntax (syntax-table))) 58 `(let ((saved-syntax (syntax-table)))
59 (unwind-protect 59 (unwind-protect
@@ -311,8 +311,8 @@
311 (not (stringp (car al1)))))) 311 (not (stringp (car al1))))))
312 312
313(defun reftex-bib-sort-year (e1 e2) 313(defun reftex-bib-sort-year (e1 e2)
314 (< (string-to-int (cdr (assoc "year" e1))) 314 (< (string-to-int (or (cdr (assoc "year" e1)) "0"))
315 (string-to-int (cdr (assoc "year" e2))))) 315 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
316 316
317(defun reftex-bib-sort-year-reverse (e1 e2) 317(defun reftex-bib-sort-year-reverse (e1 e2)
318 (> (string-to-int (or (cdr (assoc "year" e1)) "0")) 318 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
@@ -597,12 +597,13 @@ to `reftex-cite-format' and inserted into the buffer.
597 597
598If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. 598If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
599 599
600FORMAT-KEY can be used to pre-select a citation format. 600FORAT-KEY can be used to pre-select a citation format.
601 601
602When called with one or two `C-u' prefixes, first rescans the document. 602When called with a `C-u' prefix, prompt for optional arguments in
603When called with a numeric prefix, make that many citations. When 603cite macros. When called with a numeric prefix, make that many
604called with point inside the braces of a `\\cite' command, it will 604citations. When called with point inside the braces of a `\\cite'
605add another key, ignoring the value of `reftex-cite-format'. 605command, it will add another key, ignoring the value of
606`reftex-cite-format'.
606 607
607The regular expression uses an expanded syntax: && is interpreted as `and'. 608The regular expression uses an expanded syntax: && is interpreted as `and'.
608Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. 609Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
@@ -618,7 +619,7 @@ While entering the regexp, completion on knows citation keys is possible.
618 ;; Thus look for the scanning info only if in reftex-mode. 619 ;; Thus look for the scanning info only if in reftex-mode.
619 620
620 (when reftex-mode 621 (when reftex-mode
621 (reftex-access-scan-info current-prefix-arg)) 622 (reftex-access-scan-info nil))
622 623
623 ;; Call reftex-do-citation, but protected 624 ;; Call reftex-do-citation, but protected
624 (unwind-protect 625 (unwind-protect
@@ -629,11 +630,14 @@ While entering the regexp, completion on knows citation keys is possible.
629 ;; This really does the work of reftex-citation. 630 ;; This really does the work of reftex-citation.
630 631
631 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) 632 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
633 (start 0)
632 (docstruct-symbol reftex-docstruct-symbol) 634 (docstruct-symbol reftex-docstruct-symbol)
633 (selected-entries (reftex-offer-bib-menu)) 635 (selected-entries (reftex-offer-bib-menu))
634 (insert-entries selected-entries) 636 (insert-entries selected-entries)
635 entry string cite-view) 637 entry string cite-view)
636 638
639 (when (stringp selected-entries)
640 (error selected-entries))
637 (unless selected-entries (error "Quit")) 641 (unless selected-entries (error "Quit"))
638 642
639 (if (stringp selected-entries) 643 (if (stringp selected-entries)
@@ -646,6 +650,7 @@ While entering the regexp, completion on knows citation keys is possible.
646 650
647 (when (eq (car selected-entries) 'concat) 651 (when (eq (car selected-entries) 'concat)
648 ;; All keys go into a single command - we need to trick a little 652 ;; All keys go into a single command - we need to trick a little
653 ;; FIXME: Unfortunately, this meens that commenting does not work right.
649 (pop selected-entries) 654 (pop selected-entries)
650 (let ((concat-keys (mapconcat 'car selected-entries ","))) 655 (let ((concat-keys (mapconcat 'car selected-entries ",")))
651 (setq insert-entries 656 (setq insert-entries
@@ -655,7 +660,7 @@ While entering the regexp, completion on knows citation keys is possible.
655 660
656 ;; We shall insert this into the buffer... 661 ;; We shall insert this into the buffer...
657 (message "Formatting...") 662 (message "Formatting...")
658 663
659 (while (setq entry (pop insert-entries)) 664 (while (setq entry (pop insert-entries))
660 ;; Format the citation and insert it 665 ;; Format the citation and insert it
661 (setq string (if reftex-format-cite-function 666 (setq string (if reftex-format-cite-function
@@ -663,6 +668,24 @@ While entering the regexp, completion on knows citation keys is possible.
663 (reftex-get-bib-field "&key" entry) 668 (reftex-get-bib-field "&key" entry)
664 format) 669 format)
665 (reftex-format-citation entry format))) 670 (reftex-format-citation entry format)))
671 (when (or (eq reftex-cite-prompt-optional-args t)
672 (and reftex-cite-prompt-optional-args
673 (equal arg '(4))))
674 (let ((start 0) (nth 0) value)
675 (while (setq start (string-match "\\[\\]" string start))
676 (setq value (read-string (format "Optional argument %d: "
677 (setq nth (1+ nth)))))
678 (setq string (replace-match (concat "[" value "]") t t string))
679 (setq start (1+ start)))))
680 ;; Should we cleanup empty optional arguments?
681 ;; if the first is empty, it can be removed. If the second is empty,
682 ;; it has to go.
683 (when reftex-cite-cleanup-optional-args
684 (cond
685 ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string)
686 (setq string (replace-match "\\1" nil nil string)))
687 ((string-match "\\[\\]\\[\\]" string)
688 (setq string (replace-match "" t t string)))))
666 (insert string)) 689 (insert string))
667 690
668 ;; Reposition cursor? 691 ;; Reposition cursor?
@@ -842,6 +865,17 @@ While entering the regexp, completion on knows citation keys is possible.
842 (mapcar 'car (nreverse reftex-select-marked)) 865 (mapcar 'car (nreverse reftex-select-marked))
843 found-list))) 866 found-list)))
844 (throw 'done t)) 867 (throw 'done t))
868 ((eq key ?e)
869 ;; Take all (marked), and push the symbol 'concat
870 (reftex-extract-bib-file found-list reftex-select-marked)
871 (setq selected-entries "BibTeX database file created")
872 (throw 'done t))
873 ((eq key ?E)
874 ;; Take all (marked), and push the symbol 'concat
875 (reftex-extract-bib-file found-list reftex-select-marked
876 'complement)
877 (setq selected-entries "BibTeX database file created")
878 (throw 'done t))
845 ((or (eq key ?\C-m) 879 ((or (eq key ?\C-m)
846 (eq key 'return)) 880 (eq key 'return))
847 ;; Take selected 881 ;; Take selected
@@ -882,6 +916,29 @@ While entering the regexp, completion on knows citation keys is possible.
882 (ding) 916 (ding)
883 found-list))) 917 found-list)))
884 918
919(defun reftex-extract-bib-file (all &optional marked complement)
920 ;; Limit FOUND-LIST with more regular expressions
921 (let ((file (read-file-name "File to create: ")))
922 (find-file-other-window file)
923 (if (> (buffer-size) 0)
924 (unless (yes-or-no-p
925 (format "Overwrite non-empty file %s? " file))
926 (error "Abort")))
927 (erase-buffer)
928 (setq all (delq nil
929 (mapcar
930 (lambda (x)
931 (if marked
932 (if (or (and (assoc x marked) (not complement))
933 (and (not (assoc x marked)) complement))
934 (cdr (assoc "&entry" x))
935 nil)
936 (cdr (assoc "&entry" x))))
937 all)))
938 (insert (mapconcat 'identity all "\n\n"))
939 (save-buffer)
940 (goto-char (point-min))))
941
885(defun reftex-insert-bib-matches (list) 942(defun reftex-insert-bib-matches (list)
886 ;; Insert the bib matches and number them correctly 943 ;; Insert the bib matches and number them correctly
887 (let ((mouse-face 944 (let ((mouse-face
@@ -1043,5 +1100,73 @@ While entering the regexp, completion on knows citation keys is possible.
1043 1100
1044 (select-window win))) 1101 (select-window win)))
1045 1102
1103;;; Global BibTeX file
1104(defun reftex-all-used-citation-keys ()
1105 (reftex-access-scan-info)
1106 (let ((files (reftex-all-document-files)) file keys kkk kk k)
1107 (save-excursion
1108 (while (setq file (pop files))
1109 (set-buffer (reftex-get-file-buffer-force file 'mark))
1110 (save-excursion
1111 (save-restriction
1112 (widen)
1113 (goto-char (point-min))
1114 (while (re-search-forward "^[^%\n\r]*\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t)
1115 (setq kk (match-string-no-properties 3))
1116 (while (string-match "%.*\n?" kk)
1117 (setq kk (replace-match "" t t kk)))
1118 (setq kk (split-string kk "[, \t\r\n]+"))
1119 (while (setq k (pop kk))
1120 (or (member k keys)
1121 (setq keys (cons k keys)))))))))
1122 (reftex-kill-temporary-buffers)
1123 keys))
1124
1125(defun reftex-create-bibtex-file (bibfile)
1126 "Create a new BibTeX database file with all entries referenced in document.
1127The command prompts for a filename and writes the collected entries to
1128that file. Only entries referenced in the current document with
1129any \\cite-like macros are used.
1130The sequence in the new file is the same as it was in the old database."
1131 (interactive "FNew BibTeX file: ")
1132 (let ((keys (reftex-all-used-citation-keys))
1133 (files (reftex-get-bibfile-list))
1134 file key entries beg end entry)
1135 (save-excursion
1136 (while (setq file (pop files))
1137 (set-buffer (reftex-get-file-buffer-force file 'mark))
1138 (reftex-with-special-syntax-for-bib
1139 (save-excursion
1140 (save-restriction
1141 (widen)
1142 (goto-char (point-min))
1143 (while (re-search-forward
1144 "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
1145 nil t)
1146 (setq key (match-string 1)
1147 beg (match-beginning 0)
1148 end (progn
1149 (goto-char (match-beginning 1))
1150 (condition-case nil
1151 (up-list 1)
1152 (error (goto-char (match-end 0))))
1153 (point)))
1154 (when (member key keys)
1155 (setq entry (buffer-substring beg end)
1156 entries (cons entry entries)
1157 keys (delete key keys)))))))))
1158 (find-file-other-window bibfile)
1159 (if (> (buffer-size) 0)
1160 (unless (yes-or-no-p
1161 (format "Overwrite non-empty file %s? " bibfile))
1162 (error "Abort")))
1163 (erase-buffer)
1164 (insert (mapconcat 'identity (reverse entries) "\n\n"))
1165 (goto-char (point-min))
1166 (save-buffer)
1167 (message "%d entries extracted and copied to new database"
1168 (length entries))))
1169
1170
1046;;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89 1171;;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89
1047;;; reftex-cite.el ends here 1172;;; reftex-cite.el ends here
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index dc47a5e7564..e832465cf17 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -1,8 +1,8 @@
1;;; reftex-dcr.el --- viewing cross references and citations with RefTeX 1;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; 6;;
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index 84b4c7c67f5..d4d91b476e9 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -1,8 +1,8 @@
1;;; reftex-global.el --- operations on entire documents with RefTeX 1;;; reftex-global.el --- operations on entire documents with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 71b3b624770..cb02f2e056f 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1,8 +1,8 @@
1;;; reftex-index.el --- index support with RefTeX 1;;; reftex-index.el --- index support with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -360,7 +360,7 @@ _ ^ Add/Remove parent key (to make this item a subitem).
360 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))) 360 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
361 match)) 361 match))
362 362
363(defun reftex-display-index (&optional tag overriding-restriction 363(defun reftex-display-index (&optional tag overriding-restriction redo
364 &rest locations) 364 &rest locations)
365 "Display a buffer with an index compiled from the current document. 365 "Display a buffer with an index compiled from the current document.
366When the document has multiple indices, first prompts for the correct one. 366When the document has multiple indices, first prompts for the correct one.
@@ -387,7 +387,7 @@ With prefix 3, restrict index to region."
387 (calling-file (buffer-file-name)) 387 (calling-file (buffer-file-name))
388 (restriction 388 (restriction
389 (or overriding-restriction 389 (or overriding-restriction
390 (and (interactive-p) 390 (and (not redo)
391 (reftex-get-restriction current-prefix-arg docstruct)))) 391 (reftex-get-restriction current-prefix-arg docstruct))))
392 (locations 392 (locations
393 ;; See if we are on an index macro as initial position 393 ;; See if we are on an index macro as initial position
@@ -427,7 +427,7 @@ With prefix 3, restrict index to region."
427 (if restriction 427 (if restriction
428 (setq reftex-index-restriction-indicator (car restriction) 428 (setq reftex-index-restriction-indicator (car restriction)
429 reftex-index-restriction-data (cdr restriction)) 429 reftex-index-restriction-data (cdr restriction))
430 (if (interactive-p) 430 (if (not redo)
431 (setq reftex-index-restriction-indicator nil 431 (setq reftex-index-restriction-indicator nil
432 reftex-index-restriction-data nil))) 432 reftex-index-restriction-data nil)))
433 (when (= (buffer-size) 0) 433 (when (= (buffer-size) 0)
@@ -703,7 +703,7 @@ The function will go to the section where the entry at point was defined."
703 (error "Don't know which file to rescan. Try `C-u r'") 703 (error "Don't know which file to rescan. Try `C-u r'")
704 (switch-to-buffer (reftex-get-file-buffer-force file)) 704 (switch-to-buffer (reftex-get-file-buffer-force file))
705 (setq current-prefix-arg '(4)) 705 (setq current-prefix-arg '(4))
706 (reftex-display-index index-tag nil line))) 706 (reftex-display-index index-tag nil 'redo line)))
707 (reftex-index-Rescan)) 707 (reftex-index-Rescan))
708 (reftex-kill-temporary-buffers))) 708 (reftex-kill-temporary-buffers)))
709(defun reftex-index-Rescan (&rest ignore) 709(defun reftex-index-Rescan (&rest ignore)
@@ -714,7 +714,7 @@ The function will go to the section where the entry at point was defined."
714 (switch-to-buffer 714 (switch-to-buffer
715 (reftex-get-file-buffer-force reftex-last-index-file)) 715 (reftex-get-file-buffer-force reftex-last-index-file))
716 (setq current-prefix-arg '(16)) 716 (setq current-prefix-arg '(16))
717 (reftex-display-index index-tag nil line))) 717 (reftex-display-index index-tag nil 'redo line)))
718(defun reftex-index-revert (&rest ignore) 718(defun reftex-index-revert (&rest ignore)
719 "Regenerate the *Index* from the internal lists. No reparsing os done." 719 "Regenerate the *Index* from the internal lists. No reparsing os done."
720 (interactive) 720 (interactive)
@@ -727,14 +727,14 @@ The function will go to the section where the entry at point was defined."
727 (reftex-erase-buffer buf) 727 (reftex-erase-buffer buf)
728 (setq current-prefix-arg nil 728 (setq current-prefix-arg nil
729 reftex-last-follow-point 1) 729 reftex-last-follow-point 1)
730 (reftex-display-index index-tag nil data line))) 730 (reftex-display-index index-tag nil 'redo data line)))
731(defun reftex-index-switch-index-tag (&rest ignore) 731(defun reftex-index-switch-index-tag (&rest ignore)
732 "Switch to a different index of the same document." 732 "Switch to a different index of the same document."
733 (interactive) 733 (interactive)
734 (switch-to-buffer 734 (switch-to-buffer
735 (reftex-get-file-buffer-force reftex-last-index-file)) 735 (reftex-get-file-buffer-force reftex-last-index-file))
736 (setq current-prefix-arg nil) 736 (setq current-prefix-arg nil)
737 (reftex-display-index)) 737 (reftex-display-index nil nil 'redo))
738 738
739(defun reftex-index-restrict-to-section (&optional force) 739(defun reftex-index-restrict-to-section (&optional force)
740 "Restrict index to entries defined in same document sect. as entry at point." 740 "Restrict index to entries defined in same document sect. as entry at point."
@@ -1352,23 +1352,23 @@ Here are all local bindings.
1352 (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t) 1352 (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
1353 (progn 1353 (progn
1354 (goto-char (match-beginning 0)) 1354 (goto-char (match-beginning 0))
1355 (reftex-index-this-phrase)) 1355 (reftex-index-this-phrase 'slave))
1356 (error "No more phrase lines after point")))) 1356 (error "No more phrase lines after point"))))
1357 1357
1358(defun reftex-index-this-phrase () 1358(defun reftex-index-this-phrase (&optional slave)
1359 "Index the phrase in the current line. 1359 "Index the phrase in the current line.
1360Does a global search and replace in the entire document. At each 1360Does a global search and replace in the entire document. At each
1361match, the user will be asked to confirm the replacement." 1361match, the user will be asked to confirm the replacement."
1362 (interactive) 1362 (interactive)
1363 (if (interactive-p) (reftex-index-phrases-parse-header t)) 1363 (if (not slave) (reftex-index-phrases-parse-header t))
1364 (save-excursion 1364 (save-excursion
1365 (beginning-of-line) 1365 (beginning-of-line)
1366 (cond ((looking-at reftex-index-phrases-comment-regexp) 1366 (cond ((looking-at reftex-index-phrases-comment-regexp)
1367 (if (interactive-p) (error "Comment line"))) 1367 (if (not slave) (error "Comment line")))
1368 ((looking-at "^[ \t]*$") 1368 ((looking-at "^[ \t]*$")
1369 (if (interactive-p) (error "Empty line"))) 1369 (if (not slave) (error "Empty line")))
1370 ((looking-at reftex-index-phrases-macrodef-regexp) 1370 ((looking-at reftex-index-phrases-macrodef-regexp)
1371 (if (interactive-p) (error "Macro definition line"))) 1371 (if (not slave) (error "Macro definition line")))
1372 ((looking-at reftex-index-phrases-phrase-regexp12) 1372 ((looking-at reftex-index-phrases-phrase-regexp12)
1373 ;; This is a phrase 1373 ;; This is a phrase
1374 (let* ((char (if (not (equal (match-string 1) "")) 1374 (let* ((char (if (not (equal (match-string 1) ""))
@@ -1429,7 +1429,7 @@ Calls `reftex-index-this-phrase' on each line in the region."
1429 (goto-char beg) 1429 (goto-char beg)
1430 (while (not (or (eobp) 1430 (while (not (or (eobp)
1431 (>= (point) end))) 1431 (>= (point) end)))
1432 (save-excursion (reftex-index-this-phrase)) 1432 (save-excursion (reftex-index-this-phrase 'slave))
1433 (beginning-of-line 2))) 1433 (beginning-of-line 2)))
1434 1434
1435(defun reftex-index-phrases-parse-header (&optional get-files) 1435(defun reftex-index-phrases-parse-header (&optional get-files)
@@ -1736,12 +1736,15 @@ With optional arg ALLOW-NEWLINE, allow single newline between words."
1736 "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)" 1736 "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)"
1737 "\\([ \t]+\\)"))) 1737 "\\([ \t]+\\)")))
1738 (concat (if (and as-words (string-match "\\`\\w" (car words))) 1738 (concat (if (and as-words (string-match "\\`\\w" (car words)))
1739 "\\<" "") 1739 "\\(\\<\\|[`']\\)" "")
1740 (mapconcat (lambda (w) (regexp-quote (downcase w))) 1740 (mapconcat (lambda (w) (regexp-quote
1741 (if reftex-index-phrases-case-fold-search
1742 (downcase w)
1743 w)))
1741 words space-re) 1744 words space-re)
1742 (if (and as-words 1745 (if (and as-words
1743 (string-match "\\w\\'" (nth (1- (length words)) words))) 1746 (string-match "\\w\\'" (nth (1- (length words)) words)))
1744 "\\>" "")))) 1747 "\\(\\>\\|'\\)" ""))))
1745 1748
1746(defun reftex-index-simplify-phrase (phrase) 1749(defun reftex-index-simplify-phrase (phrase)
1747 "Make phrase single spaces and single line." 1750 "Make phrase single spaces and single line."
@@ -1825,6 +1828,8 @@ both ends."
1825 (unwind-protect 1828 (unwind-protect
1826 (while (re-search-forward re nil t) 1829 (while (re-search-forward re nil t)
1827 (catch 'next-match 1830 (catch 'next-match
1831 (if (reftex-in-comment)
1832 (throw 'next-match nil))
1828 (if (and (fboundp reftex-index-verify-function) 1833 (if (and (fboundp reftex-index-verify-function)
1829 (not (funcall reftex-index-verify-function))) 1834 (not (funcall reftex-index-verify-function)))
1830 (throw 'next-match nil)) 1835 (throw 'next-match nil))
@@ -1925,7 +1930,7 @@ both ends."
1925 (reftex-unhighlight 0)))) 1930 (reftex-unhighlight 0))))
1926 1931
1927(defun reftex-index-phrase-match-is-indexed (beg end) 1932(defun reftex-index-phrase-match-is-indexed (beg end)
1928 ;; CHeck if match is in an argument of an index macro, or if an 1933 ;; Check if match is in an argument of an index macro, or if an
1929 ;; index macro is directly attached to the match. 1934 ;; index macro is directly attached to the match.
1930 (save-excursion 1935 (save-excursion
1931 (goto-char end) 1936 (goto-char end)
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 534775bf5a5..630c7101725 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -1,8 +1,8 @@
1;;; reftex-parse.el --- parser functions for RefTeX 1;;; reftex-parse.el --- parser functions for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; 6;;
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 2d4935aedde..43095e2d684 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -1,8 +1,8 @@
1;;; reftex-ref.el --- code to create labels and references with RefTeX 1;;; reftex-ref.el --- code to create labels and references with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -96,14 +96,27 @@ If optional BOUND is an integer, limit backward searches to that point."
96 96
97(defun reftex-label-info (label &optional file bound derive env-or-mac) 97(defun reftex-label-info (label &optional file bound derive env-or-mac)
98 ;; Return info list on LABEL at point. 98 ;; Return info list on LABEL at point.
99 (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) 99 (let* ((prefix (if (string-match "^[a-zA-Z0-9]+:" label)
100 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) 100 (match-string 0 label)))
101 (typekey (cdr (assoc prefix reftex-prefix-to-typekey-alist)))
101 (file (or file (buffer-file-name))) 102 (file (or file (buffer-file-name)))
102 (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist))) 103 (trust reftex-trust-label-prefix)
103 (text (reftex-short-context env-or-mac parse reftex-location-start
104 derive))
105 (in-comment (reftex-in-comment))) 104 (in-comment (reftex-in-comment)))
106 (list label typekey text file in-comment))) 105 (if (and typekey
106 (cond ((eq trust t) t)
107 ((null trust) nil)
108 ((stringp trust) (string-match trust typekey))
109 ((listp trust) (member typekey trust))
110 (t nil)))
111 (list label typekey
112 (reftex-nicify-text (reftex-context-substring))
113 file in-comment)
114 (let* ((env-or-mac (or env-or-mac (reftex-label-location bound)))
115 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
116 (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist)))
117 (text (reftex-short-context env-or-mac parse reftex-location-start
118 derive)))
119 (list label typekey text file in-comment)))))
107 120
108;;; Creating labels --------------------------------------------------------- 121;;; Creating labels ---------------------------------------------------------
109 122
@@ -296,35 +309,43 @@ also applies `reftex-translate-to-ascii-function' to the string."
296 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num) 309 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
297 (setq letter (match-string 1 prefix)) 310 (setq letter (match-string 1 prefix))
298 (setq replace 311 (setq replace
299 (cond 312 (save-match-data
300 ((equal letter "f") 313 (cond
301 (file-name-sans-extension 314 ((equal letter "f")
302 (file-name-nondirectory (buffer-file-name)))) 315 (file-name-sans-extension
303 ((equal letter "F") 316 (file-name-nondirectory (buffer-file-name))))
304 (let ((masterdir (file-name-directory (reftex-TeX-master-file))) 317 ((equal letter "F")
305 (file (file-name-sans-extension (buffer-file-name)))) 318 (let ((masterdir (file-name-directory (reftex-TeX-master-file)))
306 (if (string-match (concat "\\`" (regexp-quote masterdir)) 319 (file (file-name-sans-extension (buffer-file-name))))
307 file) 320 (if (string-match (concat "\\`" (regexp-quote masterdir))
308 (substring file (length masterdir)) 321 file)
309 file))) 322 (substring file (length masterdir))
310 ((equal letter "u") 323 file)))
311 (or (user-login-name) "")) 324 ((equal letter "m")
312 ((equal letter "S") 325 (file-name-sans-extension
313 (let* (macro level-exp level) 326 (file-name-nondirectory (reftex-TeX-master-file))))
314 (save-excursion 327 ((equal letter "M")
315 (save-match-data 328 (file-name-nondirectory
316 (when (re-search-backward reftex-section-regexp nil t) 329 (substring (file-name-directory (reftex-TeX-master-file))
317 (setq macro (reftex-match-string 2) 330 0 -1)))
318 level-exp (cdr (assoc macro reftex-section-levels-all)) 331 ((equal letter "u")
319 level (if (symbolp level-exp) 332 (or (user-login-name) ""))
320 (abs (save-match-data 333 ((equal letter "S")
321 (funcall level-exp))) 334 (let* (macro level-exp level)
322 (abs level-exp)))) 335 (save-excursion
323 (cdr (or (assoc macro reftex-section-prefixes) 336 (save-match-data
324 (assoc level reftex-section-prefixes) 337 (when (re-search-backward reftex-section-regexp nil t)
325 (assq t reftex-section-prefixes) 338 (setq macro (reftex-match-string 2)
326 (list t "sec:"))))))) 339 level-exp (cdr (assoc macro reftex-section-levels-all))
327 (t ""))) 340 level (if (symbolp level-exp)
341 (abs (save-match-data
342 (funcall level-exp)))
343 (abs level-exp))))
344 (cdr (or (assoc macro reftex-section-prefixes)
345 (assoc level reftex-section-prefixes)
346 (assq t reftex-section-prefixes)
347 (list t "sec:")))))))
348 (t ""))))
328 (setq num (1- (+ (match-beginning 1) (length replace))) 349 (setq num (1- (+ (match-beginning 1) (length replace)))
329 prefix (replace-match replace nil nil prefix))) 350 prefix (replace-match replace nil nil prefix)))
330 prefix))) 351 prefix)))
@@ -449,7 +470,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
449 470
450 ;; remove ~ if we do already have a space 471 ;; remove ~ if we do already have a space
451 (when (and (= ?~ (string-to-char form)) 472 (when (and (= ?~ (string-to-char form))
452 (member (preceding-char) '(?\ ?\t ?\n ?. ?~))) 473 (member (preceding-char) '(?\ ?\t ?\n ?~)))
453 (setq form (substring form 1))) 474 (setq form (substring form 1)))
454 ;; do we have a special format? 475 ;; do we have a special format?
455 (setq reftex-format-ref-function 476 (setq reftex-format-ref-function
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index 3074e83b681..8b0ebb2ca2b 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -1,8 +1,8 @@
1;;; reftex-sel.el --- the selection modes for RefTeX 1;;; reftex-sel.el --- the selection modes for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -607,13 +607,11 @@ Useful for large TOC's."
607 (setq ovl (make-overlay boe eoe)) 607 (setq ovl (make-overlay boe eoe))
608 (push (list data ovl separator) reftex-select-marked) 608 (push (list data ovl separator) reftex-select-marked)
609 (overlay-put ovl 'face reftex-select-mark-face) 609 (overlay-put ovl 'face reftex-select-mark-face)
610 (if (featurep 'xemacs) 610 (overlay-put ovl 'before-string
611 ;; before-string property is broken in Emacs 611 (if separator
612 (overlay-put ovl 'before-string 612 (format "*%c%d* " separator
613 (if separator 613 (length reftex-select-marked))
614 (format "*%c%d* " separator 614 (format "*%d* " (length reftex-select-marked))))
615 (length reftex-select-marked))
616 (format "*%d* " (length reftex-select-marked)))))
617 (message "Entry has mark no. %d" (length reftex-select-marked)))) 615 (message "Entry has mark no. %d" (length reftex-select-marked))))
618 616
619(defun reftex-select-mark-comma () 617(defun reftex-select-mark-comma ()
@@ -725,7 +723,7 @@ Useful for large TOC's."
725 (define-key reftex-select-label-map (car x) (cdr x))) 723 (define-key reftex-select-label-map (car x) (cdr x)))
726 724
727;; Specific bindings in reftex-select-bib-map 725;; Specific bindings in reftex-select-bib-map
728(loop for key across "grRaA" do 726(loop for key across "grRaAeE" do
729 (define-key reftex-select-bib-map (vector (list key)) 727 (define-key reftex-select-bib-map (vector (list key))
730 (list 'lambda '() 728 (list 'lambda '()
731 "Press `?' during selection to find out about this key." 729 "Press `?' during selection to find out about this key."
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 8d217f08dfb..0f0b72332b8 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -2,7 +2,7 @@
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -754,13 +754,13 @@ if these sets are sorted blocks in the alist."
754 "Make sure all files of the document are being visited by buffers, 754 "Make sure all files of the document are being visited by buffers,
755and that the scanning info is absolutely up to date. 755and that the scanning info is absolutely up to date.
756We do this by rescanning with reftex-keep-temporary-buffers bound to t. 756We do this by rescanning with reftex-keep-temporary-buffers bound to t.
757The variable PRO-OR-DE is assumed to be dynamically scoped into this function. 757The variable PRO-OR-DE is assumed to be dynamically scoped into thes function.
758When finished, we exit with an error message." 758When finished, we exit with an error message."
759 (let ((reftex-keep-temporary-buffers t)) 759 (let ((reftex-keep-temporary-buffers t))
760 (reftex-toc-Rescan) 760 (reftex-toc-Rescan)
761 (reftex-toc-restore-region start-line mark-line) 761 (reftex-toc-restore-region start-line mark-line)
762 (throw 'exit 762 (throw 'exit
763 "TOC had to be updated first. Please check selection and repeat the command."))) 763 (format "TOC had to be updated first. Please check selection and repeat the command." pro-or-de))))
764 764
765(defun reftex-toc-rename-label () 765(defun reftex-toc-rename-label ()
766 "Rename the currently selected label in the *TOC* buffer. 766 "Rename the currently selected label in the *TOC* buffer.
@@ -868,6 +868,7 @@ label prefix determines the wording of a reference."
868 ((and (markerp marker) (marker-buffer marker)) 868 ((and (markerp marker) (marker-buffer marker))
869 ;; Buffer is still live and we have the marker. Should be easy. 869 ;; Buffer is still live and we have the marker. Should be easy.
870 (switch-to-buffer-other-window (marker-buffer marker)) 870 (switch-to-buffer-other-window (marker-buffer marker))
871 (push-mark nil)
871 (goto-char (marker-position marker)) 872 (goto-char (marker-position marker))
872 (or (looking-at (regexp-quote literal)) 873 (or (looking-at (regexp-quote literal))
873 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) 874 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal))
@@ -1088,4 +1089,4 @@ always show the current section in connection with the option
1088 1089
1089 1090
1090;;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e 1091;;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e
1091;;; reftex-toc.el ends here \ No newline at end of file 1092;;; reftex-toc.el ends here
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index 53357342c51..a7c0cb1c1ad 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -1,8 +1,8 @@
1;;; reftex-vars.el --- configuration variables for RefTeX 1;;; reftex-vars.el --- configuration variables for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -128,13 +128,13 @@ distribution. Mixed-case symbols are convenience aliases.")
128 128
129(defconst reftex-cite-format-builtin 129(defconst reftex-cite-format-builtin
130 '((default "Default macro \\cite{%l}" 130 '((default "Default macro \\cite{%l}"
131 "\\cite{%l}") 131 "\\cite[]{%l}")
132 (natbib "The Natbib package" 132 (natbib "The Natbib package"
133 ((?\C-m . "\\cite{%l}") 133 ((?\C-m . "\\cite[][]{%l}")
134 (?t . "\\citet{%l}") 134 (?t . "\\citet[][]{%l}")
135 (?T . "\\citet*{%l}") 135 (?T . "\\citet*[][]{%l}")
136 (?p . "\\citep{%l}") 136 (?p . "\\citep[][]{%l}")
137 (?P . "\\citep*{%l}") 137 (?P . "\\citep*[][]{%l}")
138 (?e . "\\citep[e.g.][]{%l}") 138 (?e . "\\citep[e.g.][]{%l}")
139 (?s . "\\citep[see][]{%l}") 139 (?s . "\\citep[see][]{%l}")
140 (?a . "\\citeauthor{%l}") 140 (?a . "\\citeauthor{%l}")
@@ -157,8 +157,8 @@ distribution. Mixed-case symbols are convenience aliases.")
157 (bibentry "The Bibentry package" 157 (bibentry "The Bibentry package"
158 "\\bibentry{%l}") 158 "\\bibentry{%l}")
159 (harvard "The Harvard package" 159 (harvard "The Harvard package"
160 ((?\C-m . "\\cite{%l}") 160 ((?\C-m . "\\cite[]{%l}")
161 (?p . "\\cite{%l}") 161 (?p . "\\cite[]{%l}")
162 (?t . "\\citeasnoun{%l}") 162 (?t . "\\citeasnoun{%l}")
163 (?n . "\\citeasnoun{%l}") 163 (?n . "\\citeasnoun{%l}")
164 (?s . "\\possessivecite{%l}") 164 (?s . "\\possessivecite{%l}")
@@ -166,17 +166,17 @@ distribution. Mixed-case symbols are convenience aliases.")
166 (?y . "\\citeyear{%l}") 166 (?y . "\\citeyear{%l}")
167 (?a . "\\citename{%l}"))) 167 (?a . "\\citename{%l}")))
168 (chicago "The Chicago package" 168 (chicago "The Chicago package"
169 ((?\C-m . "\\cite{%l}") 169 ((?\C-m . "\\cite[]{%l}")
170 (?t . "\\citeN{%l}") 170 (?t . "\\citeN[]{%l}")
171 (?T . "\\shortciteN{%l}") 171 (?T . "\\shortciteN{%l}")
172 (?p . "\\cite{%l}") 172 (?p . "\\cite[]{%l}")
173 (?P . "\\shortcite{%l}") 173 (?P . "\\shortcite{%l}")
174 (?a . "\\citeA{%l}") 174 (?a . "\\citeA{%l}")
175 (?A . "\\shortciteA{%l}") 175 (?A . "\\shortciteA{%l}")
176 (?y . "\\citeyear{%l}"))) 176 (?y . "\\citeyear{%l}")))
177 (astron "The Astron package" 177 (astron "The Astron package"
178 ((?\C-m . "\\cite{%l}") 178 ((?\C-m . "\\cite[]{%l}")
179 (?p . "\\cite{%l}" ) 179 (?p . "\\cite[]{%l}" )
180 (?t . "%2a (\\cite{%l})"))) 180 (?t . "%2a (\\cite{%l})")))
181 (author-year "Do-it-yourself Author-year" 181 (author-year "Do-it-yourself Author-year"
182 ((?\C-m . "\\cite{%l}") 182 ((?\C-m . "\\cite{%l}")
@@ -484,6 +484,8 @@ LABEL-PREFIX
484 empty string. The prefix may contain the following `%' escapes: 484 empty string. The prefix may contain the following `%' escapes:
485 %f Current file name with directory and extension stripped. 485 %f Current file name with directory and extension stripped.
486 %F Current file name relative to directory of master file. 486 %F Current file name relative to directory of master file.
487 %m Master file name, directory and extension stripped.
488 %M Directory name (without path) where master file is located.
487 %u User login name, on systems which support this. 489 %u User login name, on systems which support this.
488 %S A section prefix derived with variable `reftex-section-prefixes'. 490 %S A section prefix derived with variable `reftex-section-prefixes'.
489 491
@@ -631,6 +633,43 @@ the final regular expression - so %s will be replaced with the environment
631or macro." 633or macro."
632 :group 'reftex-defining-label-environments 634 :group 'reftex-defining-label-environments
633 :type '(repeat (cons (symbol) (regexp)))) 635 :type '(repeat (cons (symbol) (regexp))))
636
637(defcustom reftex-trust-label-prefix nil
638 "Non-nil means, trust the label prefix when determining label type.
639It is customary to use special label prefixes to distinguish different label
640types. The label prefixes have no syntactic meaning in LaTeX (unless
641special packages like fancyref) are being used. RefTeX can and by
642default does parse around each label to detect the correct label type,
643but this process can be slow when a document contains thousands of
644labels. If you use label prefixes consistently, you may speed up
645document parsing by setting this variable to a non-nil value. RefTeX
646will then compare the label prefix with the prefixes found in
647`reftex-label-alist' and derive the correct label type in this way.
648Possible values for this option are:
649
650t This means to trust any label prefixes found.
651regexp If a regexp, only prefixes matched by the regexp are trusted.
652list List of accepted prefixes, as strings. The colon is part of
653 the prefix, e.g. (\"fn:\" \"eqn:\" \"item:\").
654nil Never trust a label prefix.
655
656The only disadvantage of using this feature is that the label context
657displayed in the label selection buffer along with each label is
658simply some text after the label definition. This is no problem if you
659place labels keeping this in mind (e.g. *before* the equation, *at
660the beginning* of a fig/tab caption ...). Anyway, it is probably best
661to use the regexp or the list value types to fine-tune this feature.
662For example, if your document contains thousands of footnotes with
663labels fn:xxx, you may want to set this variable to the value \"^fn:$\" or
664\(\"fn:\"). Then RefTeX will still do extensive parsing for any
665non-footnote labels."
666 :group 'reftex-defining-label-environments
667 :type '(choice
668 (const :tag "Always" t)
669 (const :tag "Never" nil)
670 (regexp)
671 (repeat :tag "List"
672 (string :tag "prefix (with colon)"))))
634 673
635(defcustom reftex-special-environment-functions nil 674(defcustom reftex-special-environment-functions nil
636 "List of functions to be called when trying to figure out current environment. 675 "List of functions to be called when trying to figure out current environment.
@@ -1010,6 +1049,9 @@ display, and for (setq reftex-comment-citations t).
1010%< as a special operator kills punctuation and space around it after the 1049%< as a special operator kills punctuation and space around it after the
1011string has been formatted. 1050string has been formatted.
1012 1051
1052A pair of square brackets indicates an optional argument, and RefTeX
1053will prompt for the values of these arguments.
1054
1013Beware that all this only works with BibTeX database files. When 1055Beware that all this only works with BibTeX database files. When
1014citations are made from the \\bibitems in an explicit thebibliography 1056citations are made from the \\bibitems in an explicit thebibliography
1015environment, only %l is available. 1057environment, only %l is available.
@@ -1042,6 +1084,42 @@ E.g.: (setq reftex-cite-format 'natbib)"
1042 (cons (character :tag "Key character" ?\r) 1084 (cons (character :tag "Key character" ?\r)
1043 (string :tag "Format string" ""))))) 1085 (string :tag "Format string" "")))))
1044 1086
1087(defcustom reftex-cite-prompt-optional-args 'maybe
1088 "*Non-nil means, prompt for empty optional arguments in cite macros.
1089When an entry in `reftex-cite-format' ist given with square brackets to
1090indicate optional arguments (for example \\cite[][]{%l}), RefTeX can
1091prompt for values. Possible values are:
1092
1093nil Never prompt for optional arguments
1094t Always prompt
1095maybe Prompt only if `reftex-citation' was called with C-u prefix arg
1096
1097Unnecessary empty optional arguments are removed before insertion into
1098the buffer. See `reftex-cite-cleanup-optional-args'."
1099 :group 'reftex-citation-support
1100 :type '(choice
1101 (const :tag "Always" t)
1102 (const :tag "When called with prefix arg" maybe)
1103 (const :tag "Never" nil)))
1104
1105(defcustom reftex-cite-cleanup-optional-args t
1106 "*Non-nil means, remove unnecessary empty optional arguments in cite macros.
1107The cite macros provided by some packages (for example
1108natbib) allow specifying two optional arguments, one for a prefix to
1109the citation, and a second for a postfix. When only one optional
1110argument is given, it is interpreted as postfix. When this option is
1111t, RefTeX removes unnecessary empty optional arguments from the cite
1112macro before insertion. For example, it will change
1113 \\cite[][]{Jones} -> \\cite{Jones}
1114 \\cite[][Chapter 1]{Jones} -> \\cite[Chapter 1]{Jones}
1115 \\cite[see][]{Jones} -> \\cite[see][]{Jones}
1116 \\cite[see][Chapter 1]{Jones} -> \\cite{Jones}
1117Is is possible that other packages have other conventions about which
1118optional argument is interpreted how - that is why this cleaning up
1119can be turned off."
1120 :group 'reftex-citation-support
1121 :type 'boolean)
1122
1045(defcustom reftex-comment-citations nil 1123(defcustom reftex-comment-citations nil
1046 "*Non-nil means add a comment for each citation describing the full entry. 1124 "*Non-nil means add a comment for each citation describing the full entry.
1047The comment is formatted according to `reftex-cite-comment-format'." 1125The comment is formatted according to `reftex-cite-comment-format'."
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index c00400a7b96..e177805e9c4 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1,8 +1,8 @@
1;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX 1;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; Keywords: tex 6;; Keywords: tex
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
@@ -300,7 +300,7 @@
300;;; Define the formal stuff for a minor mode named RefTeX. 300;;; Define the formal stuff for a minor mode named RefTeX.
301;;; 301;;;
302 302
303(defconst reftex-version "RefTeX version 4.21" 303(defconst reftex-version "RefTeX version 4.26"
304 "Version string for RefTeX.") 304 "Version string for RefTeX.")
305 305
306(defvar reftex-mode nil 306(defvar reftex-mode nil
@@ -669,6 +669,8 @@ the label information is recompiled on next use."
669 669
670;; Alist relating magic words to a label type. 670;; Alist relating magic words to a label type.
671(defvar reftex-words-to-typekey-alist nil) 671(defvar reftex-words-to-typekey-alist nil)
672;; Alist relating label prefixes to a label type.
673(defvar reftex-prefix-to-typekey-alist nil)
672 674
673;; The last list-of-labels entry used in a reference. 675;; The last list-of-labels entry used in a reference.
674(defvar reftex-last-used-reference (list nil nil nil nil)) 676(defvar reftex-last-used-reference (list nil nil nil nil))
@@ -750,6 +752,7 @@ the label information is recompiled on next use."
750 reftex-typekey-to-format-alist 752 reftex-typekey-to-format-alist
751 reftex-typekey-to-prefix-alist 753 reftex-typekey-to-prefix-alist
752 reftex-words-to-typekey-alist 754 reftex-words-to-typekey-alist
755 reftex-prefix-to-typekey-alist
753 reftex-type-query-prompt 756 reftex-type-query-prompt
754 reftex-type-query-help 757 reftex-type-query-help
755 758
@@ -904,6 +907,8 @@ This enforces rescanning the buffer on next use."
904 macro verify repeat nindex tag key toc-level toc-levels) 907 macro verify repeat nindex tag key toc-level toc-levels)
905 908
906 (setq reftex-words-to-typekey-alist nil 909 (setq reftex-words-to-typekey-alist nil
910 reftex-prefix-to-typekey-alist
911 '(("sec:" . "s") ("cha:" . "s") ("chap:" . "s"))
907 reftex-typekey-list nil 912 reftex-typekey-list nil
908 reftex-typekey-to-format-alist nil 913 reftex-typekey-to-format-alist nil
909 reftex-typekey-to-prefix-alist nil 914 reftex-typekey-to-prefix-alist nil
@@ -946,6 +951,10 @@ This enforces rescanning the buffer on next use."
946 (if typekey 951 (if typekey
947 (add-to-list 'reftex-typekey-list typekey)) 952 (add-to-list 'reftex-typekey-list typekey))
948 (if (and typekey prefix 953 (if (and typekey prefix
954 (not (assoc prefix reftex-prefix-to-typekey-alist)))
955 (add-to-list 'reftex-prefix-to-typekey-alist
956 (cons prefix typekey)))
957 (if (and typekey prefix
949 (not (assoc typekey reftex-typekey-to-prefix-alist))) 958 (not (assoc typekey reftex-typekey-to-prefix-alist)))
950 (add-to-list 'reftex-typekey-to-prefix-alist 959 (add-to-list 'reftex-typekey-to-prefix-alist
951 (cons typekey prefix))) 960 (cons typekey prefix)))
@@ -1676,6 +1685,7 @@ When DIE is non-nil, throw an error if file not found."
1676 "Make a citation using BibTeX database files." t) 1685 "Make a citation using BibTeX database files." t)
1677(autoload 'reftex-default-bibliography "reftex-cite") 1686(autoload 'reftex-default-bibliography "reftex-cite")
1678(autoload 'reftex-bib-or-thebib "reftex-cite") 1687(autoload 'reftex-bib-or-thebib "reftex-cite")
1688(autoload 'reftex-create-bibtex-file "reftex-cite")
1679 1689
1680;;; ========================================================================= 1690;;; =========================================================================
1681;;; 1691;;;
@@ -2439,6 +2449,7 @@ IGNORE-WORDS List of words which should be removed from the string."
2439 ["Restore from File" (reftex-access-parse-file 'restore) t]) 2449 ["Restore from File" (reftex-access-parse-file 'restore) t])
2440 ("Global Actions" 2450 ("Global Actions"
2441 ["Search Whole Document" reftex-search-document t] 2451 ["Search Whole Document" reftex-search-document t]
2452 ["Search Again" tags-loop-continue t]
2442 ["Replace in Document" reftex-query-replace-document t] 2453 ["Replace in Document" reftex-query-replace-document t]
2443 ["Grep on Document" reftex-grep-document t] 2454 ["Grep on Document" reftex-grep-document t]
2444 "--" 2455 "--"
@@ -2447,6 +2458,8 @@ IGNORE-WORDS List of words which should be removed from the string."
2447 ["Change Label and Refs" reftex-change-label t] 2458 ["Change Label and Refs" reftex-change-label t]
2448 ["Renumber Simple Labels" reftex-renumber-simple-labels t] 2459 ["Renumber Simple Labels" reftex-renumber-simple-labels t]
2449 "--" 2460 "--"
2461 ["Create BibTeX File" reftex-create-bibtex-file t]
2462 "--"
2450 ["Create TAGS File" reftex-create-tags-file t] 2463 ["Create TAGS File" reftex-create-tags-file t]
2451 "--" 2464 "--"
2452 ["Save Document" reftex-save-all-document-buffers t]) 2465 ["Save Document" reftex-save-all-document-buffers t])