diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 143 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-auc.el | 29 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-cite.el | 166 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-dcr.el | 16 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-global.el | 7 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-index.el | 21 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-parse.el | 17 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-ref.el | 130 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-sel.el | 47 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-toc.el | 18 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-vars.el | 215 | ||||
| -rw-r--r-- | lisp/textmodes/reftex.el | 651 |
12 files changed, 839 insertions, 621 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 38dacef1fd8..902bf63be72 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,146 @@ | |||
| 1 | 2012-09-30 Ralf Angeli <angeli@caeruleus.net> | ||
| 2 | |||
| 3 | Merge from standalone RefTeX repository. | ||
| 4 | |||
| 5 | The following ChangeLog entries are shortened versions of the | ||
| 6 | original ones with file paths adapted. A not so strongly edited | ||
| 7 | version of the original ChangeLog can be found in the commit log. | ||
| 8 | |||
| 9 | * textmodes/reftex-auc.el: Move `provide' call to bottom of file. | ||
| 10 | (reftex-arg-cite): Use `reftex-cite-key-separator'. Correctly | ||
| 11 | handle new value type returned by `reftex-citation'. | ||
| 12 | |||
| 13 | * textmodes/reftex-cite.el (reftex-create-bibtex-file): Make sure | ||
| 14 | that entries with whitespace at various places are found. Doc | ||
| 15 | fix. Include entries that are cross-referenced from cited entries. | ||
| 16 | Include @String definitions in the resulting bib file. Add header | ||
| 17 | and footer defined in `reftex-create-bibtex-header' and | ||
| 18 | `reftex-create-bibtex-footer'. | ||
| 19 | (reftex-do-citation): Make it possible again to insert | ||
| 20 | non-existent entries. Save match data when asking for optional | ||
| 21 | arguments. Return all keys, not just the first one. | ||
| 22 | (reftex-all-used-citation-keys): Fix regexp to correctly extract | ||
| 23 | all citations in the same line. | ||
| 24 | (reftex-parse-bibtex-entry): Accept additional optional argument | ||
| 25 | `raw' and keep quotes or braces if it is non-nil. Match fields | ||
| 26 | containing hyphens besides word constituents. | ||
| 27 | (reftex-get-string-refs): New function. | ||
| 28 | (reftex-extract-bib-entries): Check if BibTeX file changed on disk | ||
| 29 | and ask if it should be reread in case it did. | ||
| 30 | (reftex-pop-to-bibtex-entry) | ||
| 31 | (reftex-extract-bib-entries-from-thebibliography): Match \bibitem | ||
| 32 | entries with spaces or tabs in front of arguments. | ||
| 33 | (reftex-pop-to-bibtex-entry, reftex-extract-bib-entries) | ||
| 34 | (reftex-parse-bibtex-entry, reftex-create-bibtex-file): Match | ||
| 35 | entries containing numbers and symbol constituents. | ||
| 36 | (reftex-do-citation, reftex-figure-out-cite-format): Use | ||
| 37 | `reftex-cite-key-separator'. | ||
| 38 | |||
| 39 | * textmodes/reftex-dcr.el: Move provide statement to end of file. | ||
| 40 | (reftex-mouse-view-crossref): Explain why point is set. | ||
| 41 | |||
| 42 | * textmodes/reftex-global.el: Whitespace changes. | ||
| 43 | |||
| 44 | * textmodes/reftex-index.el: Move provide statement to end of | ||
| 45 | file. | ||
| 46 | (reftex-index-selection-or-word): Use `reftex-region-active-p'. | ||
| 47 | (reftex-index-visit-phrases-buffer): Set marker when visiting | ||
| 48 | buffer. This allows for returning from the phrases file to the | ||
| 49 | file one was just editing instead of the file where the last | ||
| 50 | phrases was added from. | ||
| 51 | (reftex-index-phrases-syntax-table): New variable. Give ?\" | ||
| 52 | punctuation syntax as it usually is not used as string quote in | ||
| 53 | TeX-related modes and may occur unmatched. The change also | ||
| 54 | prevents fontification of quoted content. | ||
| 55 | (reftex-index-phrases-mode): Use it. | ||
| 56 | |||
| 57 | * textmodes/reftex-parse.el (reftex-parse-from-file): Move | ||
| 58 | backward one char if a `\' was matched after a section macro. | ||
| 59 | (reftex-parse-from-file): Use beginning of match instead of end as | ||
| 60 | bound. | ||
| 61 | |||
| 62 | * textmodes/reftex-ref.el: Adapt creation of | ||
| 63 | `reftex-<package>-<macro>' functions to new structure of | ||
| 64 | `reftex-ref-style-alist'. | ||
| 65 | (reftex-reference): Use `reftex-ref-style-list' function. Adapt | ||
| 66 | to new structure of `reftex-ref-style-alist'. Prompt for a | ||
| 67 | reference macro if `reftex-ref-macro-prompt' is non-nil. | ||
| 68 | (reftex-reference): Pass refstyle to `reftex-format-special'. | ||
| 69 | Determine reference macro by looking at | ||
| 70 | `reftex-ref-style-default-list' and `reftex-ref-style-alist'. Use | ||
| 71 | only one special format function. | ||
| 72 | (reftex-varioref-vref, reftex-fancyref-fref) | ||
| 73 | (reftex-fancyref-Fref): Remove definitions. The functions are now | ||
| 74 | generated from `reftex-ref-style-alist'. | ||
| 75 | (reftex-format-vref, reftex-format-Fref, reftex-format-fref): | ||
| 76 | Remove. | ||
| 77 | (reftex-format-special): New function. | ||
| 78 | |||
| 79 | * textmodes/reftex-sel.el | ||
| 80 | (reftex-select-cycle-ref-style-internal): Adapt to new structure | ||
| 81 | of `reftex-ref-style-alist'. Remove code for testing macro type. | ||
| 82 | (reftex-select-toggle-varioref) | ||
| 83 | (reftex-select-toggle-fancyref): Remove. | ||
| 84 | (reftex-select-cycle-ref-style-internal) | ||
| 85 | (reftex-select-cycle-ref-style-forward) | ||
| 86 | (reftex-select-cycle-ref-style-backward): New functions. | ||
| 87 | (reftex-select-label-map): Use `v' and `V' for general cycling | ||
| 88 | through reference styles. Add `p' for switching between number | ||
| 89 | and page reference types. | ||
| 90 | |||
| 91 | * textmodes/reftex-toc.el (reftex-re-enlarge): Call | ||
| 92 | `enlarge-window' only if there is something to do because in Emacs | ||
| 93 | the horizontal version throws an error even if the parameter is 0. | ||
| 94 | |||
| 95 | * textmodes/reftex-vars.el (reftex-label-alist): Doc fix. | ||
| 96 | (reftex-plug-into-AUCTeX): Doc fix. | ||
| 97 | (reftex-vref-is-default, reftex-fref-is-default): Adapt doc | ||
| 98 | string. Adapt to new name. | ||
| 99 | (reftex-ref-style-alist): Change structure so that it is not | ||
| 100 | possible to use multiple different package names within a style. | ||
| 101 | Remove the symbols for symbols for macro type distinction. Add | ||
| 102 | characters for macro selection. | ||
| 103 | (reftex-ref-macro-prompt, reftex-create-bibtex-header) | ||
| 104 | (reftex-create-bibtex-footer): New variables. | ||
| 105 | (reftex-format-ref-function): Mention third argument of special | ||
| 106 | format function. | ||
| 107 | (reftex-ref-style-alist, reftex-ref-style-default-list): New | ||
| 108 | variables. | ||
| 109 | (reftex-vref-is-default, reftex-fref-is-default): Adapt doc string | ||
| 110 | to new implementation. Mark as obsolete. Add compatibility code | ||
| 111 | for honoring the variable values in case they are set. | ||
| 112 | (reftex-cite-format-builtin, reftex-bibliography-commands): Add | ||
| 113 | support for ConTeXt. | ||
| 114 | (reftex-format-ref-function, reftex-format-cite-function): Fix | ||
| 115 | custom type. | ||
| 116 | (reftex-cite-key-separator): New variable. | ||
| 117 | |||
| 118 | * textmodes/reftex.el (reftex-syntax-table-for-bib) | ||
| 119 | (reftex-mode): Do not derive `reftex-syntax-table-for-bib' from | ||
| 120 | `reftex-syntax-table' because parens have to retain their paren | ||
| 121 | syntax in order for parsing of BibTeX entries like @book(...) to | ||
| 122 | work. | ||
| 123 | (reftex-in-comment): Do not error out if `comment-start-skip' is | ||
| 124 | not set. Deal correctly with escaped comment characters. | ||
| 125 | (reftex-tie-multifile-symbols): Add doc string. Initialize | ||
| 126 | `reftex-ref-style-list'. | ||
| 127 | (reftex-untie-multifile-symbols): Add doc string. | ||
| 128 | (reftex-add-index-macros): Doc fix. | ||
| 129 | (reftex-ref-style-activate, reftex-ref-style-toggle) | ||
| 130 | (reftex-ref-style-list): New functions. | ||
| 131 | (reftex-mode-menu): Use them. Adapt to new structure of | ||
| 132 | `reftex-ref-style-alist'. | ||
| 133 | (reftex-select-with-char): Kill the RefTeX Select buffer when | ||
| 134 | done. | ||
| 135 | (reftex-remove-if): New function. | ||
| 136 | (reftex-erase-all-selection-and-index-buffers) | ||
| 137 | (reftex-mode-menu): Reference styles are now computed from | ||
| 138 | `reftex-ref-style-alist'. Fix typo. | ||
| 139 | (reftex-report-bug): New function. | ||
| 140 | (reftex-uniquify, reftex-uniquify-by-car): Replace O(n^2) | ||
| 141 | algorithms with O(n log n). Introduce optional argument SORT (not | ||
| 142 | yet used). | ||
| 143 | |||
| 1 | 2012-09-30 Fabián Ezequiel Gallina <fgallina@cuca> | 144 | 2012-09-30 Fabián Ezequiel Gallina <fgallina@cuca> |
| 2 | 145 | ||
| 3 | Enhancements for triple-quote string syntax. | 146 | Enhancements for triple-quote string syntax. |
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el index 3a875f0dfa3..72013c5b241 100644 --- a/lisp/textmodes/reftex-auc.el +++ b/lisp/textmodes/reftex-auc.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,21 +25,21 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-auc) | 28 | |
| 31 | (require 'reftex) | 29 | (require 'reftex) |
| 32 | ;;; | 30 | |
| 33 | 31 | (declare-function TeX-argument-prompt "ext:tex" | |
| 34 | (declare-function TeX-argument-insert "ext:tex" (name optional &optional prefix)) | 32 | (optional prompt default &optional complete)) |
| 35 | (declare-function TeX-argument-prompt "ext:tex" (optional prompt default &optional complete)) | 33 | (declare-function TeX-argument-insert "ext:tex" |
| 36 | (declare-function multi-prompt "ext:multi-prompt" | 34 | (name optional &optional prefix)) |
| 37 | (separator | ||
| 38 | unique prompt table | ||
| 39 | &optional mp-predicate require-match initial history)) | ||
| 40 | (declare-function LaTeX-add-index-entries "ext:tex" (&rest entries) t) | ||
| 41 | (declare-function LaTeX-add-labels "ext:tex" (&rest entries) t) | 35 | (declare-function LaTeX-add-labels "ext:tex" (&rest entries) t) |
| 36 | (declare-function LaTeX-add-index-entries "ext:tex" (&rest entries) t) | ||
| 42 | (declare-function LaTeX-bibitem-list "ext:tex" () t) | 37 | (declare-function LaTeX-bibitem-list "ext:tex" () t) |
| 43 | (declare-function LaTeX-index-entry-list "ext:tex" () t) | 38 | (declare-function LaTeX-index-entry-list "ext:tex" () t) |
| 44 | (declare-function LaTeX-label-list "ext:tex" () t) | 39 | (declare-function LaTeX-label-list "ext:tex" () t) |
| 40 | (declare-function multi-prompt "ext:multi-prompt" | ||
| 41 | (separator unique prompt table &optional | ||
| 42 | mp-predicate require-match initial history)) | ||
| 45 | 43 | ||
| 46 | (defun reftex-plug-flag (which) | 44 | (defun reftex-plug-flag (which) |
| 47 | ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX | 45 | ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX |
| @@ -76,14 +74,15 @@ What is being used depends upon `reftex-plug-into-AUCTeX'." | |||
| 76 | (let (items) | 74 | (let (items) |
| 77 | (cond | 75 | (cond |
| 78 | ((and (not definition) (reftex-plug-flag 3)) | 76 | ((and (not definition) (reftex-plug-flag 3)) |
| 79 | (setq items (list (or (reftex-citation t) "")))) | 77 | (setq items (or (reftex-citation t) (list "")))) |
| 80 | (t | 78 | (t |
| 81 | (setq prompt (concat (if optional "(Optional) " "") | 79 | (setq prompt (concat (if optional "(Optional) " "") |
| 82 | (if prompt prompt "Add key") | 80 | (if prompt prompt "Add key") |
| 83 | " (default none): ")) | 81 | " (default none): ")) |
| 84 | (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list))))) | 82 | (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list))))) |
| 85 | (apply 'LaTeX-add-bibitems items) | 83 | (apply 'LaTeX-add-bibitems items) |
| 86 | (TeX-argument-insert (mapconcat 'identity items ",") optional))) | 84 | (TeX-argument-insert (mapconcat 'identity items reftex-cite-key-separator) |
| 85 | optional))) | ||
| 87 | 86 | ||
| 88 | 87 | ||
| 89 | (defun reftex-arg-index-tag (optional &optional prompt &rest args) | 88 | (defun reftex-arg-index-tag (optional &optional prompt &rest args) |
| @@ -223,4 +222,6 @@ of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See | |||
| 223 | (defun reftex-notice-new-section () | 222 | (defun reftex-notice-new-section () |
| 224 | (reftex-notice-new 1 'force)) | 223 | (reftex-notice-new 1 'force)) |
| 225 | 224 | ||
| 225 | (provide 'reftex-auc) | ||
| 226 | |||
| 226 | ;;; reftex-auc.el ends here | 227 | ;;; reftex-auc.el ends here |
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index 229d12b2906..52fa6dbf9d2 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -129,9 +127,10 @@ | |||
| 129 | 127 | ||
| 130 | (let* ((re | 128 | (let* ((re |
| 131 | (if item | 129 | (if item |
| 132 | (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}") | 130 | (concat "\\\\bibitem[ \t]*\\(\\[[^]]*\\]\\)?[ \t]*{" |
| 133 | (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key) | 131 | (regexp-quote key) "}") |
| 134 | "[, \t\r\n}]"))) | 132 | (concat "@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*[{(][ \t\n\r]*" |
| 133 | (regexp-quote key) "[, \t\r\n}]"))) | ||
| 135 | (buffer-conf (current-buffer)) | 134 | (buffer-conf (current-buffer)) |
| 136 | file buf pos oldpos) | 135 | file buf pos oldpos) |
| 137 | 136 | ||
| @@ -229,7 +228,13 @@ | |||
| 229 | buffer (not reftex-keep-temporary-buffers)))) | 228 | buffer (not reftex-keep-temporary-buffers)))) |
| 230 | (if (not buffer1) | 229 | (if (not buffer1) |
| 231 | (message "No such BibTeX file %s (ignored)" buffer) | 230 | (message "No such BibTeX file %s (ignored)" buffer) |
| 232 | (message "Scanning bibliography database %s" buffer1)) | 231 | (message "Scanning bibliography database %s" buffer1) |
| 232 | (unless (verify-visited-file-modtime buffer1) | ||
| 233 | (when (y-or-n-p | ||
| 234 | (format "File %s changed on disk. Reread from disk? " | ||
| 235 | (file-name-nondirectory | ||
| 236 | (buffer-file-name buffer1)))) | ||
| 237 | (with-current-buffer buffer1 (revert-buffer t t))))) | ||
| 233 | 238 | ||
| 234 | (set-buffer buffer1) | 239 | (set-buffer buffer1) |
| 235 | (reftex-with-special-syntax-for-bib | 240 | (reftex-with-special-syntax-for-bib |
| @@ -238,8 +243,8 @@ | |||
| 238 | (while (re-search-forward first-re nil t) | 243 | (while (re-search-forward first-re nil t) |
| 239 | (catch 'search-again | 244 | (catch 'search-again |
| 240 | (setq key-point (point)) | 245 | (setq key-point (point)) |
| 241 | (unless (re-search-backward | 246 | (unless (re-search-backward "\\(\\`\\|[\n\r]\\)[ \t]*\ |
| 242 | "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t) | 247 | @\\(\\(?:\\w\\|\\s_\\)+\\)[ \t\n\r]*[{(]" nil t) |
| 243 | (throw 'search-again nil)) | 248 | (throw 'search-again nil)) |
| 244 | (setq start-point (point)) | 249 | (setq start-point (point)) |
| 245 | (goto-char (match-end 0)) | 250 | (goto-char (match-end 0)) |
| @@ -451,7 +456,8 @@ | |||
| 451 | (setq names (replace-match " " nil t names))) | 456 | (setq names (replace-match " " nil t names))) |
| 452 | (split-string names "\n"))) | 457 | (split-string names "\n"))) |
| 453 | 458 | ||
| 454 | (defun reftex-parse-bibtex-entry (entry &optional from to) | 459 | (defun reftex-parse-bibtex-entry (entry &optional from to raw) |
| 460 | ; if RAW is non-nil, keep double quotes/curly braces delimiting fields | ||
| 455 | (let (alist key start field) | 461 | (let (alist key start field) |
| 456 | (save-excursion | 462 | (save-excursion |
| 457 | (save-restriction | 463 | (save-restriction |
| @@ -463,41 +469,56 @@ | |||
| 463 | (erase-buffer) | 469 | (erase-buffer) |
| 464 | (insert entry)) | 470 | (insert entry)) |
| 465 | (widen) | 471 | (widen) |
| 466 | (narrow-to-region from to)) | 472 | (if (and from to) (narrow-to-region from to))) |
| 467 | (goto-char (point-min)) | 473 | (goto-char (point-min)) |
| 468 | 474 | ||
| 469 | (if (re-search-forward | 475 | (if (re-search-forward "@\\(\\(?:\\w\\|\\s_\\)+\\)[ \t\n\r]*\ |
| 470 | "@\\(\\w+\\)[ \t\n\r]*[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t) | 476 | \[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t) |
| 471 | (setq alist | 477 | (setq alist |
| 472 | (list | 478 | (list |
| 473 | (cons "&type" (downcase (reftex-match-string 1))) | 479 | (cons "&type" (downcase (reftex-match-string 1))) |
| 474 | (cons "&key" (reftex-match-string 2))))) | 480 | (cons "&key" (reftex-match-string 2))))) |
| 475 | (while (re-search-forward "\\(\\w+\\)[ \t\n\r]*=[ \t\n\r]*" nil t) | 481 | (while (re-search-forward "\\(\\(?:\\w\\|-\\)+\\)[ \t\n\r]*=[ \t\n\r]*" |
| 482 | nil t) | ||
| 476 | (setq key (downcase (reftex-match-string 1))) | 483 | (setq key (downcase (reftex-match-string 1))) |
| 477 | (cond | 484 | (cond |
| 478 | ((= (following-char) ?{) | 485 | ((= (following-char) ?{) |
| 479 | (forward-char 1) | 486 | (cond |
| 480 | (setq start (point)) | 487 | (raw |
| 481 | (condition-case nil | 488 | (setq start (point)) |
| 482 | (up-list 1) | 489 | (forward-char 1)) |
| 483 | (error nil))) | 490 | (t |
| 491 | (forward-char 1) | ||
| 492 | (setq start (point)) | ||
| 493 | (condition-case nil | ||
| 494 | (up-list 1) | ||
| 495 | (error nil))))) | ||
| 484 | ((= (following-char) ?\") | 496 | ((= (following-char) ?\") |
| 485 | (forward-char 1) | 497 | (cond |
| 486 | (setq start (point)) | 498 | (raw |
| 499 | (setq start (point)) | ||
| 500 | (forward-char 1)) | ||
| 501 | (t | ||
| 502 | (forward-char 1) | ||
| 503 | (setq start (point)))) | ||
| 487 | (while (and (search-forward "\"" nil t) | 504 | (while (and (search-forward "\"" nil t) |
| 488 | (= ?\\ (char-after (- (point) 2)))))) | 505 | (= ?\\ (char-after (- (point) 2)))))) |
| 489 | (t | 506 | (t |
| 490 | (setq start (point)) | 507 | (setq start (point)) |
| 491 | (re-search-forward "[ \t]*[\n\r,}]" nil 1))) | 508 | (re-search-forward "[ \t]*[\n\r,}]" nil 1))) |
| 492 | (setq field (buffer-substring-no-properties start (1- (point)))) | 509 | ;; extract field value, ignore trailing comma if in RAW mode |
| 510 | (let ((stop (if (and raw (not (= (char-after (1- (point))) ?,))) | ||
| 511 | (point) | ||
| 512 | (1- (point))) )) | ||
| 513 | (setq field (buffer-substring-no-properties start stop))) | ||
| 493 | ;; remove extra whitespace | 514 | ;; remove extra whitespace |
| 494 | (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field) | 515 | (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field) |
| 495 | (setq field (replace-match " " nil t field))) | 516 | (setq field (replace-match " " nil t field))) |
| 496 | ;; remove leading garbage | 517 | ;; remove leading garbage |
| 497 | (if (string-match "^[ \t{]+" field) | 518 | (if (string-match (if raw "^[ \t]+" "^[ \t{]+") field) |
| 498 | (setq field (replace-match "" nil t field))) | 519 | (setq field (replace-match "" nil t field))) |
| 499 | ;; remove trailing garbage | 520 | ;; remove trailing garbage |
| 500 | (if (string-match "[ \t}]+$" field) | 521 | (if (string-match (if raw "[ \t]+$" "[ \t}]+$") field) |
| 501 | (setq field (replace-match "" nil t field))) | 522 | (setq field (replace-match "" nil t field))) |
| 502 | (push (cons key field) alist)))) | 523 | (push (cons key field) alist)))) |
| 503 | alist)) | 524 | alist)) |
| @@ -638,15 +659,13 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 638 | (insert-entries selected-entries) | 659 | (insert-entries selected-entries) |
| 639 | entry string cite-view) | 660 | entry string cite-view) |
| 640 | 661 | ||
| 641 | (when (stringp selected-entries) | ||
| 642 | (error selected-entries)) | ||
| 643 | (unless selected-entries (error "Quit")) | 662 | (unless selected-entries (error "Quit")) |
| 644 | 663 | ||
| 645 | (if (stringp selected-entries) | 664 | (if (stringp selected-entries) |
| 646 | ;; Nonexistent entry | 665 | ;; Nonexistent entry |
| 647 | (setq selected-entries nil | 666 | (setq insert-entries (list (list selected-entries |
| 648 | insert-entries (list (list selected-entries | 667 | (cons "&key" selected-entries))) |
| 649 | (cons "&key" selected-entries)))) | 668 | selected-entries nil) |
| 650 | ;; It makes sense to compute the cite-view strings. | 669 | ;; It makes sense to compute the cite-view strings. |
| 651 | (setq cite-view t)) | 670 | (setq cite-view t)) |
| 652 | 671 | ||
| @@ -654,7 +673,8 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 654 | ;; All keys go into a single command - we need to trick a little | 673 | ;; All keys go into a single command - we need to trick a little |
| 655 | ;; FIXME: Unfortunately, this means that commenting does not work right. | 674 | ;; FIXME: Unfortunately, this means that commenting does not work right. |
| 656 | (pop selected-entries) | 675 | (pop selected-entries) |
| 657 | (let ((concat-keys (mapconcat 'car selected-entries ","))) | 676 | (let ((concat-keys (mapconcat 'car selected-entries |
| 677 | reftex-cite-key-separator))) | ||
| 658 | (setq insert-entries | 678 | (setq insert-entries |
| 659 | (list (list concat-keys (cons "&key" concat-keys)))))) | 679 | (list (list concat-keys (cons "&key" concat-keys)))))) |
| 660 | 680 | ||
| @@ -675,8 +695,9 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 675 | (equal arg '(4)))) | 695 | (equal arg '(4)))) |
| 676 | (let ((start 0) (nth 0) value) | 696 | (let ((start 0) (nth 0) value) |
| 677 | (while (setq start (string-match "\\[\\]" string start)) | 697 | (while (setq start (string-match "\\[\\]" string start)) |
| 678 | (setq value (read-string (format "Optional argument %d: " | 698 | (setq value (save-match-data |
| 679 | (setq nth (1+ nth))))) | 699 | (read-string (format "Optional argument %d: " |
| 700 | (setq nth (1+ nth)))))) | ||
| 680 | (setq string (replace-match (concat "[" value "]") t t string)) | 701 | (setq string (replace-match (concat "[" value "]") t t string)) |
| 681 | (setq start (1+ start))))) | 702 | (setq start (1+ start))))) |
| 682 | ;; Should we cleanup empty optional arguments? | 703 | ;; Should we cleanup empty optional arguments? |
| @@ -725,7 +746,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 725 | (forward-char 1))) | 746 | (forward-char 1))) |
| 726 | 747 | ||
| 727 | ;; Return the citation key | 748 | ;; Return the citation key |
| 728 | (car (car selected-entries)))) | 749 | (mapcar 'car selected-entries))) |
| 729 | 750 | ||
| 730 | (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) | 751 | (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) |
| 731 | ;; Check if there is already a cite command at point and change cite format | 752 | ;; Check if there is already a cite command at point and change cite format |
| @@ -744,9 +765,13 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 744 | (if (or (not arg) (not (listp arg))) | 765 | (if (or (not arg) (not (listp arg))) |
| 745 | (setq format | 766 | (setq format |
| 746 | (concat | 767 | (concat |
| 747 | (if (member (preceding-char) '(?\{ ?,)) "" ",") | 768 | (if (member (preceding-char) '(?\{ ?,)) |
| 769 | "" | ||
| 770 | reftex-cite-key-separator) | ||
| 748 | "%l" | 771 | "%l" |
| 749 | (if (member (following-char) '(?\} ?,)) "" ","))) | 772 | (if (member (following-char) '(?\} ?,)) |
| 773 | "" | ||
| 774 | reftex-cite-key-separator))) | ||
| 750 | (setq format "%l"))) | 775 | (setq format "%l"))) |
| 751 | (t | 776 | (t |
| 752 | ;; Figure out the correct format | 777 | ;; Figure out the correct format |
| @@ -1114,7 +1139,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 1114 | (save-restriction | 1139 | (save-restriction |
| 1115 | (widen) | 1140 | (widen) |
| 1116 | (goto-char (point-min)) | 1141 | (goto-char (point-min)) |
| 1117 | (while (re-search-forward "^[^%\n\r]*\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t) | 1142 | (while (re-search-forward "\\(?:^\\|\\=\\)[^%\n\r]*?\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t) |
| 1118 | (setq kk (match-string-no-properties 3)) | 1143 | (setq kk (match-string-no-properties 3)) |
| 1119 | (while (string-match "%.*\n?" kk) | 1144 | (while (string-match "%.*\n?" kk) |
| 1120 | (setq kk (replace-match "" t t kk))) | 1145 | (setq kk (replace-match "" t t kk))) |
| @@ -1125,18 +1150,35 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 1125 | (reftex-kill-temporary-buffers) | 1150 | (reftex-kill-temporary-buffers) |
| 1126 | keys)) | 1151 | keys)) |
| 1127 | 1152 | ||
| 1153 | (defun reftex-get-string-refs (alist) | ||
| 1154 | "Return a list of BibTeX @string references that appear as values in ALIST." | ||
| 1155 | (reftex-remove-if (lambda (x) (string-match "^\\([\"{]\\|[0-9]+$\\)" x)) | ||
| 1156 | ;; get list of values, discard keys | ||
| 1157 | (mapcar 'cdr | ||
| 1158 | ;; remove &key and &type entries | ||
| 1159 | (reftex-remove-if (lambda (pair) | ||
| 1160 | (string-match "^&" (car pair))) | ||
| 1161 | alist)))) | ||
| 1162 | |||
| 1128 | (defun reftex-create-bibtex-file (bibfile) | 1163 | (defun reftex-create-bibtex-file (bibfile) |
| 1129 | "Create a new BibTeX database file with all entries referenced in document. | 1164 | "Create a new BibTeX database file with all entries referenced in document. |
| 1130 | The command prompts for a filename and writes the collected entries to | 1165 | The command prompts for a filename and writes the collected |
| 1131 | that file. Only entries referenced in the current document with | 1166 | entries to that file. Only entries referenced in the current |
| 1132 | any \\cite-like macros are used. | 1167 | document with any \\cite-like macros are used. The sequence in |
| 1133 | The sequence in the new file is the same as it was in the old database." | 1168 | the new file is the same as it was in the old database. |
| 1169 | |||
| 1170 | Entries referenced from other entries must appear after all | ||
| 1171 | referencing entries. | ||
| 1172 | |||
| 1173 | You can define strings to be used as header or footer for the | ||
| 1174 | created files in the variables `reftex-create-bibtex-header' or | ||
| 1175 | `reftex-create-bibtex-footer' respectively." | ||
| 1134 | (interactive "FNew BibTeX file: ") | 1176 | (interactive "FNew BibTeX file: ") |
| 1135 | (let ((keys (reftex-all-used-citation-keys)) | 1177 | (let ((keys (reftex-all-used-citation-keys)) |
| 1136 | (files (reftex-get-bibfile-list)) | 1178 | (files (reftex-get-bibfile-list)) |
| 1137 | file key entries beg end entry) | 1179 | file key entries beg end entry string-keys string-entries) |
| 1138 | (save-current-buffer | 1180 | (save-current-buffer |
| 1139 | (while (setq file (pop files)) | 1181 | (dolist (file files) |
| 1140 | (set-buffer (reftex-get-file-buffer-force file 'mark)) | 1182 | (set-buffer (reftex-get-file-buffer-force file 'mark)) |
| 1141 | (reftex-with-special-syntax-for-bib | 1183 | (reftex-with-special-syntax-for-bib |
| 1142 | (save-excursion | 1184 | (save-excursion |
| @@ -1156,14 +1198,54 @@ The sequence in the new file is the same as it was in the old database." | |||
| 1156 | (when (member key keys) | 1198 | (when (member key keys) |
| 1157 | (setq entry (buffer-substring beg end) | 1199 | (setq entry (buffer-substring beg end) |
| 1158 | entries (cons entry entries) | 1200 | entries (cons entry entries) |
| 1159 | keys (delete key keys))))))))) | 1201 | keys (delete key keys)) |
| 1202 | |||
| 1203 | ;; check for crossref entries | ||
| 1204 | (let* ((attr-list (reftex-parse-bibtex-entry nil beg end)) | ||
| 1205 | (xref-key (cdr (assoc "crossref" attr-list)))) | ||
| 1206 | (if xref-key (pushnew xref-key keys))) | ||
| 1207 | ;; check for string references | ||
| 1208 | (let* ((raw-fields (reftex-parse-bibtex-entry nil beg end t)) | ||
| 1209 | (string-fields (reftex-get-string-refs raw-fields))) | ||
| 1210 | (dolist (skey string-fields) | ||
| 1211 | (unless (member skey string-keys) | ||
| 1212 | (push skey string-keys))))))))))) | ||
| 1213 | ;; second pass: grab @string references | ||
| 1214 | (if string-keys | ||
| 1215 | (save-current-buffer | ||
| 1216 | (dolist (file files) | ||
| 1217 | (set-buffer (reftex-get-file-buffer-force file 'mark)) | ||
| 1218 | (reftex-with-special-syntax-for-bib | ||
| 1219 | (save-excursion | ||
| 1220 | (save-restriction | ||
| 1221 | (widen) | ||
| 1222 | (goto-char (point-min)) | ||
| 1223 | (while (re-search-forward | ||
| 1224 | "^[ \t]*@[Ss][Tt][Rr][Ii][Nn][Gg][ \t]*{[ \t]*\\([^ \t\r\n]+\\)" | ||
| 1225 | nil t) | ||
| 1226 | (setq key (match-string 1) | ||
| 1227 | beg (match-beginning 0) | ||
| 1228 | end (progn | ||
| 1229 | (goto-char (match-beginning 1)) | ||
| 1230 | (condition-case nil | ||
| 1231 | (up-list 1) | ||
| 1232 | (error (goto-char (match-end 0)))) | ||
| 1233 | (point))) | ||
| 1234 | (when (member key string-keys) | ||
| 1235 | (setq entry (buffer-substring beg end) | ||
| 1236 | string-entries (cons entry string-entries) | ||
| 1237 | string-keys (delete key string-keys)))))))))) | ||
| 1160 | (find-file-other-window bibfile) | 1238 | (find-file-other-window bibfile) |
| 1161 | (if (> (buffer-size) 0) | 1239 | (if (> (buffer-size) 0) |
| 1162 | (unless (yes-or-no-p | 1240 | (unless (yes-or-no-p |
| 1163 | (format "Overwrite non-empty file %s? " bibfile)) | 1241 | (format "Overwrite non-empty file %s? " bibfile)) |
| 1164 | (error "Abort"))) | 1242 | (error "Abort"))) |
| 1165 | (erase-buffer) | 1243 | (erase-buffer) |
| 1244 | (if reftex-create-bibtex-header (insert reftex-create-bibtex-header "\n\n")) | ||
| 1245 | (insert (mapconcat 'identity (reverse string-entries) "\n\n")) | ||
| 1246 | (if string-entries (insert "\n\n\n")) | ||
| 1166 | (insert (mapconcat 'identity (reverse entries) "\n\n")) | 1247 | (insert (mapconcat 'identity (reverse entries) "\n\n")) |
| 1248 | (if reftex-create-bibtex-footer (insert "\n\n" reftex-create-bibtex-footer)) | ||
| 1167 | (goto-char (point-min)) | 1249 | (goto-char (point-min)) |
| 1168 | (save-buffer) | 1250 | (save-buffer) |
| 1169 | (message "%d entries extracted and copied to new database" | 1251 | (message "%d entries extracted and copied to new database" |
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el index b1e426c5566..7d102e5a802 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,10 +25,10 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-dcr) | 28 | |
| 31 | (provide 'reftex-vcr) | 29 | (declare-function bibtex-beginning-of-entry "bibtex" ()) |
| 30 | |||
| 32 | (require 'reftex) | 31 | (require 'reftex) |
| 33 | ;;; | ||
| 34 | 32 | ||
| 35 | (defun reftex-view-crossref (&optional arg auto-how fail-quietly) | 33 | (defun reftex-view-crossref (&optional arg auto-how fail-quietly) |
| 36 | "View cross reference of macro at point. Point must be on the KEY | 34 | "View cross reference of macro at point. Point must be on the KEY |
| @@ -229,6 +227,7 @@ If it is a \\cite, show the BibTeX database entry. | |||
| 229 | If there is no such macro at point, search forward to find one. | 227 | If there is no such macro at point, search forward to find one. |
| 230 | With argument, actually select the window showing the cross reference." | 228 | With argument, actually select the window showing the cross reference." |
| 231 | (interactive "e") | 229 | (interactive "e") |
| 230 | ;; Make sure the referencing macro stays visible in the original window. | ||
| 232 | (mouse-set-point ev) | 231 | (mouse-set-point ev) |
| 233 | (reftex-view-crossref current-prefix-arg)) | 232 | (reftex-view-crossref current-prefix-arg)) |
| 234 | 233 | ||
| @@ -348,15 +347,14 @@ will display info in the echo area." | |||
| 348 | (message "Automatic display of crossref information was turned on"))) | 347 | (message "Automatic display of crossref information was turned on"))) |
| 349 | 348 | ||
| 350 | (defun reftex-start-itimer-once () | 349 | (defun reftex-start-itimer-once () |
| 351 | (and (featurep 'xemacs) reftex-mode | 350 | (and (featurep 'xemacs) |
| 351 | reftex-mode | ||
| 352 | (not (itimer-live-p reftex-auto-view-crossref-timer)) | 352 | (not (itimer-live-p reftex-auto-view-crossref-timer)) |
| 353 | (setq reftex-auto-view-crossref-timer | 353 | (setq reftex-auto-view-crossref-timer |
| 354 | (start-itimer "RefTeX Idle Timer" | 354 | (start-itimer "RefTeX Idle Timer" |
| 355 | 'reftex-view-crossref-when-idle | 355 | 'reftex-view-crossref-when-idle |
| 356 | reftex-idle-time nil t)))) | 356 | reftex-idle-time nil t)))) |
| 357 | 357 | ||
| 358 | (declare-function bibtex-beginning-of-entry "bibtex" ()) | ||
| 359 | |||
| 360 | (defun reftex-view-crossref-from-bibtex (&optional arg) | 358 | (defun reftex-view-crossref-from-bibtex (&optional arg) |
| 361 | "View location in a LaTeX document which cites the BibTeX entry at point. | 359 | "View location in a LaTeX document which cites the BibTeX entry at point. |
| 362 | Since BibTeX files can be used by many LaTeX documents, this function | 360 | Since BibTeX files can be used by many LaTeX documents, this function |
| @@ -481,4 +479,6 @@ Calling this function several times find successive citation locations." | |||
| 481 | (move-marker reftex-global-search-marker nil) | 479 | (move-marker reftex-global-search-marker nil) |
| 482 | (error "All files processed")))) | 480 | (error "All files processed")))) |
| 483 | 481 | ||
| 482 | (provide 'reftex-dcr) | ||
| 483 | |||
| 484 | ;;; reftex-dcr.el ends here | 484 | ;;; reftex-dcr.el ends here |
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el index d836bbb6cb8..ebe0aae73f8 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -407,7 +405,7 @@ Also checks if buffers visiting the files are in read-only mode." | |||
| 407 | (when flist | 405 | (when flist |
| 408 | (if wrapp | 406 | (if wrapp |
| 409 | (unless isearch-forward | 407 | (unless isearch-forward |
| 410 | (setq flist (last flist))) | 408 | (setq flist (last flist))) |
| 411 | (unless isearch-forward | 409 | (unless isearch-forward |
| 412 | (setq flist (reverse flist))) | 410 | (setq flist (reverse flist))) |
| 413 | (while (not (string= (car flist) cb)) | 411 | (while (not (string= (car flist) cb)) |
| @@ -437,7 +435,8 @@ With no argument, this command toggles | |||
| 437 | (with-current-buffer crt-buf | 435 | (with-current-buffer crt-buf |
| 438 | (when reftex-mode | 436 | (when reftex-mode |
| 439 | (if (boundp 'multi-isearch-next-buffer-function) | 437 | (if (boundp 'multi-isearch-next-buffer-function) |
| 440 | (set (make-local-variable 'multi-isearch-next-buffer-function) | 438 | (set (make-local-variable |
| 439 | 'multi-isearch-next-buffer-function) | ||
| 441 | 'reftex-isearch-switch-to-next-file) | 440 | 'reftex-isearch-switch-to-next-file) |
| 442 | (set (make-local-variable 'isearch-wrap-function) | 441 | (set (make-local-variable 'isearch-wrap-function) |
| 443 | 'reftex-isearch-wrap-function) | 442 | 'reftex-isearch-wrap-function) |
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index 1d15dfbed7e..5b884dd8480 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,9 +25,9 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-index) | 28 | (declare-function texmathp "ext:texmathp" ()) |
| 29 | |||
| 31 | (require 'reftex) | 30 | (require 'reftex) |
| 32 | ;;; | ||
| 33 | 31 | ||
| 34 | ;; START remove for XEmacs release | 32 | ;; START remove for XEmacs release |
| 35 | (defvar mark-active) | 33 | (defvar mark-active) |
| @@ -37,8 +35,6 @@ | |||
| 37 | (defvar TeX-master) | 35 | (defvar TeX-master) |
| 38 | ;; END remove for XEmacs release | 36 | ;; END remove for XEmacs release |
| 39 | 37 | ||
| 40 | (declare-function texmathp "ext:texmathp" ()) | ||
| 41 | |||
| 42 | (defun reftex-index-selection-or-word (&optional arg phrase) | 38 | (defun reftex-index-selection-or-word (&optional arg phrase) |
| 43 | "Put selection or the word near point into the default index macro. | 39 | "Put selection or the word near point into the default index macro. |
| 44 | This uses the information in `reftex-index-default-macro' to make an index | 40 | This uses the information in `reftex-index-default-macro' to make an index |
| @@ -52,9 +48,7 @@ which is part of AUCTeX, the string is first processed with the | |||
| 52 | (interactive "P") | 48 | (interactive "P") |
| 53 | (let* ((use-default (not (equal arg '(16)))) ; check for double prefix | 49 | (let* ((use-default (not (equal arg '(16)))) ; check for double prefix |
| 54 | ;; check if we have an active selection | 50 | ;; check if we have an active selection |
| 55 | (active (if (featurep 'xemacs) | 51 | (active (reftex-region-active-p)) |
| 56 | (and zmacs-regions (region-exists-p)) ; XEmacs | ||
| 57 | (and transient-mark-mode mark-active))) ; Emacs | ||
| 58 | (beg (if active | 52 | (beg (if active |
| 59 | (region-beginning) | 53 | (region-beginning) |
| 60 | (save-excursion | 54 | (save-excursion |
| @@ -1244,7 +1238,11 @@ This gets refreshed in every phrases command.") | |||
| 1244 | 1238 | ||
| 1245 | map) | 1239 | map) |
| 1246 | "Keymap used for *toc* buffer.") | 1240 | "Keymap used for *toc* buffer.") |
| 1247 | 1241 | (defvar reftex-index-phrases-syntax-table | |
| 1242 | (let ((table (make-syntax-table))) | ||
| 1243 | (modify-syntax-entry ?\" "." table) | ||
| 1244 | table) | ||
| 1245 | "Syntax table for RefTeX Index Phrases mode.") | ||
| 1248 | 1246 | ||
| 1249 | (defun reftex-index-phrase-selection-or-word (arg) | 1247 | (defun reftex-index-phrase-selection-or-word (arg) |
| 1250 | "Add current selection or word at point to the phrases buffer. | 1248 | "Add current selection or word at point to the phrases buffer. |
| @@ -1264,6 +1262,7 @@ You get a chance to edit the entry in the phrases buffer - finish with | |||
| 1264 | "Switch to the phrases buffer, initialize if empty." | 1262 | "Switch to the phrases buffer, initialize if empty." |
| 1265 | (interactive) | 1263 | (interactive) |
| 1266 | (reftex-access-scan-info) | 1264 | (reftex-access-scan-info) |
| 1265 | (set-marker reftex-index-return-marker (point)) | ||
| 1267 | (let* ((master (reftex-TeX-master-file)) | 1266 | (let* ((master (reftex-TeX-master-file)) |
| 1268 | (name (concat (file-name-sans-extension master) | 1267 | (name (concat (file-name-sans-extension master) |
| 1269 | reftex-index-phrase-file-extension))) | 1268 | reftex-index-phrase-file-extension))) |
| @@ -1371,6 +1370,7 @@ For more information see the RefTeX User Manual. | |||
| 1371 | Here are all local bindings. | 1370 | Here are all local bindings. |
| 1372 | 1371 | ||
| 1373 | \\{reftex-index-phrases-mode-map}" | 1372 | \\{reftex-index-phrases-mode-map}" |
| 1373 | :syntax-table reftex-index-phrases-syntax-table | ||
| 1374 | (set (make-local-variable 'font-lock-defaults) | 1374 | (set (make-local-variable 'font-lock-defaults) |
| 1375 | reftex-index-phrases-font-lock-defaults) | 1375 | reftex-index-phrases-font-lock-defaults) |
| 1376 | (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map) | 1376 | (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map) |
| @@ -2093,5 +2093,6 @@ Does not do a save-excursion." | |||
| 2093 | reftex-index-phrases-macro-data "\n")))) | 2093 | reftex-index-phrases-macro-data "\n")))) |
| 2094 | (reftex-select-with-char prompt help delay))) | 2094 | (reftex-select-with-char prompt help delay))) |
| 2095 | 2095 | ||
| 2096 | (provide 'reftex-index) | ||
| 2096 | 2097 | ||
| 2097 | ;;; reftex-index.el ends here | 2098 | ;;; reftex-index.el ends here |
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index c6526d1b6ce..791b5d7b945 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,7 +25,7 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-parse) | 28 | |
| 31 | (require 'reftex) | 29 | (require 'reftex) |
| 32 | 30 | ||
| 33 | (defmacro reftex-with-special-syntax (&rest body) | 31 | (defmacro reftex-with-special-syntax (&rest body) |
| @@ -241,8 +239,17 @@ of master file." | |||
| 241 | 239 | ||
| 242 | ((match-end 3) | 240 | ((match-end 3) |
| 243 | ;; It is a section | 241 | ;; It is a section |
| 244 | (setq bound (point)) | ||
| 245 | 242 | ||
| 243 | ;; Use the beginning as bound and not the end | ||
| 244 | ;; (i.e. (point)) because the section command might | ||
| 245 | ;; be the start of the current environment to be | ||
| 246 | ;; found by `reftex-label-info'. | ||
| 247 | (setq bound (match-beginning 0)) | ||
| 248 | ;; The section regexp matches a character at the end | ||
| 249 | ;; we are not interested in. Especially if it is the | ||
| 250 | ;; backslash of a following macro we want to find in | ||
| 251 | ;; the next parsing iteration. | ||
| 252 | (when (eq (char-before) ?\\) (backward-char)) | ||
| 246 | ;; Insert in List | 253 | ;; Insert in List |
| 247 | (setq toc-entry (reftex-section-info file)) | 254 | (setq toc-entry (reftex-section-info file)) |
| 248 | (when toc-entry | 255 | (when toc-entry |
| @@ -1072,4 +1079,6 @@ of master file." | |||
| 1072 | nrest (- nrest i)))) | 1079 | nrest (- nrest i)))) |
| 1073 | string)) | 1080 | string)) |
| 1074 | 1081 | ||
| 1082 | (provide 'reftex-parse) | ||
| 1083 | |||
| 1075 | ;;; reftex-parse.el ends here | 1084 | ;;; reftex-parse.el ends here |
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index 1882e7dde56..9b9f1a0f68f 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,10 +25,9 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-ref) | 28 | |
| 31 | (require 'reftex) | 29 | (require 'reftex) |
| 32 | (require 'reftex-parse) | 30 | (require 'reftex-parse) |
| 33 | ;;; | ||
| 34 | 31 | ||
| 35 | (defun reftex-label-location (&optional bound) | 32 | (defun reftex-label-location (&optional bound) |
| 36 | "Return the environment or macro which determines the label type at point. | 33 | "Return the environment or macro which determines the label type at point. |
| @@ -413,27 +410,54 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 413 | 410 | ||
| 414 | (interactive) | 411 | (interactive) |
| 415 | 412 | ||
| 416 | ;; check for active recursive edits | 413 | ;; Check for active recursive edits |
| 417 | (reftex-check-recursive-edit) | 414 | (reftex-check-recursive-edit) |
| 418 | 415 | ||
| 419 | ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | 416 | ;; Ensure access to scanning info and rescan buffer if prefix is '(4) |
| 420 | (reftex-access-scan-info current-prefix-arg) | 417 | (reftex-access-scan-info current-prefix-arg) |
| 421 | 418 | ||
| 422 | (unless type | 419 | (let ((reftex-refstyle (when (and (boundp 'reftex-refstyle) reftex-refstyle) |
| 423 | ;; guess type from context | 420 | reftex-refstyle)) |
| 424 | (if (and reftex-guess-label-type | 421 | (reftex-format-ref-function reftex-format-ref-function) |
| 425 | (setq type (reftex-guess-label-type))) | 422 | (form "\\ref{%s}") |
| 426 | (setq cut (cdr type) | 423 | label labels sep sep1 style-alist) |
| 427 | type (car type)) | 424 | |
| 428 | (setq type (reftex-query-label-type)))) | 425 | (unless reftex-refstyle |
| 429 | 426 | (if reftex-ref-macro-prompt | |
| 430 | (let* ((reftex-refstyle | 427 | (progn |
| 431 | (cond ((reftex-typekey-check type reftex-vref-is-default) "\\vref") | 428 | ;; Build a temporary list which handles more easily. |
| 432 | ((reftex-typekey-check type reftex-fref-is-default) "\\fref") | 429 | (dolist (elt reftex-ref-style-alist) |
| 433 | (t "\\ref"))) | 430 | (when (member (car elt) (reftex-ref-style-list)) |
| 434 | (reftex-format-ref-function reftex-format-ref-function) | 431 | (mapc (lambda (x) |
| 435 | (form "\\ref{%s}") | 432 | (add-to-list 'style-alist (cons (cadr x) (car x)) t)) |
| 436 | label labels sep sep1) | 433 | (nth 2 elt)))) |
| 434 | ;; Prompt the user for the macro. | ||
| 435 | (let ((key (reftex-select-with-char | ||
| 436 | "" (concat "SELECT A REFERENCE FORMAT\n\n" | ||
| 437 | (mapconcat | ||
| 438 | (lambda (x) | ||
| 439 | (format "[%c] %s %s" (car x) | ||
| 440 | (if (> (car x) 31) " " "") | ||
| 441 | (cdr x))) | ||
| 442 | style-alist "\n"))))) | ||
| 443 | (setq reftex-refstyle (cdr (assoc key style-alist))) | ||
| 444 | (unless reftex-refstyle | ||
| 445 | (error "No reference macro associated with key `%c'" key)))) | ||
| 446 | ;; Get the first macro from `reftex-ref-style-alist' which | ||
| 447 | ;; matches the first entry in the list of active styles. | ||
| 448 | (setq reftex-refstyle | ||
| 449 | (or (caar (nth 2 (assoc (car (reftex-ref-style-list)) | ||
| 450 | reftex-ref-style-alist))) | ||
| 451 | ;; Use the first entry in r-r-s-a as a last resort. | ||
| 452 | (caar (nth 2 (car reftex-ref-style-alist))))))) | ||
| 453 | |||
| 454 | (unless type | ||
| 455 | ;; Guess type from context | ||
| 456 | (if (and reftex-guess-label-type | ||
| 457 | (setq type (reftex-guess-label-type))) | ||
| 458 | (setq cut (cdr type) | ||
| 459 | type (car type)) | ||
| 460 | (setq type (reftex-query-label-type)))) | ||
| 437 | 461 | ||
| 438 | ;; Have the user select a label | 462 | ;; Have the user select a label |
| 439 | (set-marker reftex-select-return-marker (point)) | 463 | (set-marker reftex-select-return-marker (point)) |
| @@ -472,17 +496,13 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 472 | (member (preceding-char) '(?\ ?\t ?\n ?~))) | 496 | (member (preceding-char) '(?\ ?\t ?\n ?~))) |
| 473 | (setq form (substring form 1))) | 497 | (setq form (substring form 1))) |
| 474 | ;; do we have a special format? | 498 | ;; do we have a special format? |
| 475 | (setq reftex-format-ref-function | 499 | (unless (string= reftex-refstyle "\\ref") |
| 476 | (cond | 500 | (setq reftex-format-ref-function 'reftex-format-special)) |
| 477 | ((string= reftex-refstyle "\\vref") 'reftex-format-vref) | ||
| 478 | ((string= reftex-refstyle "\\fref") 'reftex-format-fref) | ||
| 479 | ((string= reftex-refstyle "\\Fref") 'reftex-format-Fref) | ||
| 480 | (t reftex-format-ref-function))) | ||
| 481 | ;; ok, insert the reference | 501 | ;; ok, insert the reference |
| 482 | (if sep1 (insert sep1)) | 502 | (if sep1 (insert sep1)) |
| 483 | (insert | 503 | (insert |
| 484 | (if reftex-format-ref-function | 504 | (if reftex-format-ref-function |
| 485 | (funcall reftex-format-ref-function label form) | 505 | (funcall reftex-format-ref-function label form reftex-refstyle) |
| 486 | (format form label label))) | 506 | (format form label label))) |
| 487 | ;; take out the initial ~ for good | 507 | ;; take out the initial ~ for good |
| 488 | (and (= ?~ (string-to-char form)) | 508 | (and (= ?~ (string-to-char form)) |
| @@ -791,34 +811,31 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 791 | (run-hooks 'reftex-display-copied-context-hook) | 811 | (run-hooks 'reftex-display-copied-context-hook) |
| 792 | (setq buffer-read-only t)))))) | 812 | (setq buffer-read-only t)))))) |
| 793 | 813 | ||
| 794 | (defun reftex-varioref-vref () | 814 | ;; Generate functions for direct insertion of specific referencing |
| 795 | "Insert a reference using the `\\vref' macro from the varioref package." | 815 | ;; macros. The functions are named `reftex-<package>-<macro>', |
| 796 | (interactive) | 816 | ;; e.g. `reftex-varioref-vref'. |
| 797 | (let ((reftex-format-ref-function 'reftex-format-vref)) | 817 | (dolist (elt reftex-ref-style-alist) |
| 798 | (reftex-reference))) | 818 | (when (stringp (nth 1 elt)) |
| 799 | (defun reftex-fancyref-fref () | 819 | (dolist (item (nth 2 elt)) |
| 800 | "Insert a reference using the `\\fref' macro from the fancyref package." | 820 | (let ((macro (car item)) |
| 801 | (interactive) | 821 | (package (nth 1 elt))) |
| 802 | (let ((reftex-format-ref-function 'reftex-format-fref) | 822 | (eval `(defun ,(intern (format "reftex-%s-%s" package |
| 803 | ;;(reftex-guess-label-type nil) ;FIXME do we want this???? | 823 | (substring macro 1 (length macro)))) () |
| 804 | ) | 824 | ,(format "Insert a reference using the `%s' macro from the %s \ |
| 805 | (reftex-reference))) | 825 | package.\n\nThis is a generated function." |
| 806 | (defun reftex-fancyref-Fref () | 826 | macro package) |
| 807 | "Insert a reference using the `\\Fref' macro from the fancyref package." | 827 | (interactive) |
| 808 | (interactive) | 828 | (let ((reftex-refstyle ,macro)) |
| 809 | (let ((reftex-format-ref-function 'reftex-format-Fref) | 829 | (reftex-reference)))))))) |
| 810 | ;;(reftex-guess-label-type nil) ;FIXME do we want this???? | 830 | |
| 811 | ) | 831 | (defun reftex-format-special (label fmt refstyle) |
| 812 | (reftex-reference))) | 832 | "Apply selected reference style to format FMT and add LABEL. |
| 813 | 833 | Replace any occurrences of \"\\ref\" with REFSTYLE." | |
| 814 | (defun reftex-format-vref (label fmt) | 834 | ;; Replace instances of \ref in `fmt' with the special reference |
| 815 | (while (string-match "\\\\ref{" fmt) | 835 | ;; style selected by the user. |
| 816 | (setq fmt (replace-match "\\vref{" t t fmt))) | 836 | (while (string-match "\\(\\\\ref\\)[ \t]*{" fmt) |
| 817 | (format fmt label label)) | 837 | (setq fmt (replace-match refstyle t t fmt 1))) |
| 818 | (defun reftex-format-Fref (label def-fmt) | 838 | (format fmt label)) |
| 819 | (format "\\Fref{%s}" label)) | ||
| 820 | (defun reftex-format-fref (label def-fmt) | ||
| 821 | (format "\\fref{%s}" label)) | ||
| 822 | 839 | ||
| 823 | (defun reftex-goto-label (&optional other-window) | 840 | (defun reftex-goto-label (&optional other-window) |
| 824 | "Prompt for a label (with completion) and jump to the location of this label. | 841 | "Prompt for a label (with completion) and jump to the location of this label. |
| @@ -847,5 +864,6 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window." | |||
| 847 | (goto-char where)) | 864 | (goto-char where)) |
| 848 | (reftex-unhighlight 0))) | 865 | (reftex-unhighlight 0))) |
| 849 | 866 | ||
| 867 | (provide 'reftex-ref) | ||
| 850 | 868 | ||
| 851 | ;;; reftex-ref.el ends here | 869 | ;;; reftex-ref.el ends here |
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el index 1a400436311..68355f9b16f 100644 --- a/lisp/textmodes/reftex-sel.el +++ b/lisp/textmodes/reftex-sel.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -27,9 +25,8 @@ | |||
| 27 | ;;; Code: | 25 | ;;; Code: |
| 28 | 26 | ||
| 29 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 30 | (provide 'reftex-sel) | 28 | |
| 31 | (require 'reftex) | 29 | (require 'reftex) |
| 32 | ;;; | ||
| 33 | 30 | ||
| 34 | ;; Common bindings in reftex-select-label-mode-map | 31 | ;; Common bindings in reftex-select-label-mode-map |
| 35 | ;; and reftex-select-bib-mode-map. | 32 | ;; and reftex-select-bib-mode-map. |
| @@ -86,8 +83,8 @@ | |||
| 86 | (loop for x in | 83 | (loop for x in |
| 87 | '(("b" . reftex-select-jump-to-previous) | 84 | '(("b" . reftex-select-jump-to-previous) |
| 88 | ("z" . reftex-select-jump) | 85 | ("z" . reftex-select-jump) |
| 89 | ("v" . reftex-select-toggle-varioref) | 86 | ("v" . reftex-select-cycle-ref-style-forward) |
| 90 | ("V" . reftex-select-toggle-fancyref) | 87 | ("V" . reftex-select-cycle-ref-style-backward) |
| 91 | ("m" . reftex-select-mark) | 88 | ("m" . reftex-select-mark) |
| 92 | ("u" . reftex-select-unmark) | 89 | ("u" . reftex-select-unmark) |
| 93 | ("," . reftex-select-mark-comma) | 90 | ("," . reftex-select-mark-comma) |
| @@ -511,6 +508,7 @@ During a selection process, these are the local bindings. | |||
| 511 | (defvar last-data) | 508 | (defvar last-data) |
| 512 | (defvar call-back) | 509 | (defvar call-back) |
| 513 | (defvar help-string) | 510 | (defvar help-string) |
| 511 | (defvar reftex-refstyle) | ||
| 514 | 512 | ||
| 515 | ;; The selection commands | 513 | ;; The selection commands |
| 516 | 514 | ||
| @@ -604,23 +602,28 @@ Useful for large TOC's." | |||
| 604 | (setq reftex-last-follow-point -1) | 602 | (setq reftex-last-follow-point -1) |
| 605 | (setq cb-flag (not cb-flag))) | 603 | (setq cb-flag (not cb-flag))) |
| 606 | 604 | ||
| 607 | (defvar reftex-refstyle) ; from reftex-reference | 605 | (defun reftex-select-cycle-ref-style-internal (&optional reverse) |
| 606 | "Cycle through macros used for referencing. | ||
| 607 | Cycle in reverse order if optional argument REVERSE is non-nil." | ||
| 608 | (let (list) | ||
| 609 | (dolist (style (reftex-ref-style-list)) | ||
| 610 | (mapc (lambda (x) (add-to-list 'list (car x) t)) | ||
| 611 | (nth 2 (assoc style reftex-ref-style-alist)))) | ||
| 612 | (when reverse | ||
| 613 | (setq list (reverse list))) | ||
| 614 | (setq reftex-refstyle (or (cadr (member reftex-refstyle list)) (car list)))) | ||
| 615 | (force-mode-line-update)) | ||
| 608 | 616 | ||
| 609 | (defun reftex-select-toggle-varioref () | 617 | (defun reftex-select-cycle-ref-style-forward () |
| 610 | "Toggle the macro used for referencing the label between \\ref and \\vref." | 618 | "Cycle forward through macros used for referencing." |
| 611 | (interactive) | 619 | (interactive) |
| 612 | (if (string= reftex-refstyle "\\ref") | 620 | (reftex-select-cycle-ref-style-internal)) |
| 613 | (setq reftex-refstyle "\\vref") | 621 | |
| 614 | (setq reftex-refstyle "\\ref")) | 622 | (defun reftex-select-cycle-ref-style-backward () |
| 615 | (force-mode-line-update)) | 623 | "Cycle backward through macros used for referencing." |
| 616 | (defun reftex-select-toggle-fancyref () | ||
| 617 | "Toggle the macro used for referencing the label between \\ref and \\vref." | ||
| 618 | (interactive) | 624 | (interactive) |
| 619 | (setq reftex-refstyle | 625 | (reftex-select-cycle-ref-style-internal t)) |
| 620 | (cond ((string= reftex-refstyle "\\ref") "\\fref") | 626 | |
| 621 | ((string= reftex-refstyle "\\fref") "\\Fref") | ||
| 622 | (t "\\ref"))) | ||
| 623 | (force-mode-line-update)) | ||
| 624 | (defun reftex-select-show-insertion-point () | 627 | (defun reftex-select-show-insertion-point () |
| 625 | "Show the point from where selection was started in another window." | 628 | "Show the point from where selection was started in another window." |
| 626 | (interactive) | 629 | (interactive) |
| @@ -721,7 +724,7 @@ Useful for large TOC's." | |||
| 721 | (if sep | 724 | (if sep |
| 722 | (format "*%c%d* " sep (decf cnt)) | 725 | (format "*%c%d* " sep (decf cnt)) |
| 723 | (format "*%d* " (decf cnt))))) | 726 | (format "*%d* " (decf cnt))))) |
| 724 | reftex-select-marked) | 727 | reftex-select-marked) |
| 725 | (message "Entry no longer marked"))) | 728 | (message "Entry no longer marked"))) |
| 726 | 729 | ||
| 727 | (defun reftex-select-help () | 730 | (defun reftex-select-help () |
| @@ -731,4 +734,6 @@ Useful for large TOC's." | |||
| 731 | (princ help-string)) | 734 | (princ help-string)) |
| 732 | (reftex-enlarge-to-fit "*RefTeX Help*" t)) | 735 | (reftex-enlarge-to-fit "*RefTeX Help*" t)) |
| 733 | 736 | ||
| 737 | (provide 'reftex-sel) | ||
| 738 | |||
| 734 | ;;; reftex-sel.el ends here | 739 | ;;; reftex-sel.el ends here |
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 519236a3621..4f73322d3f5 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -372,14 +370,14 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |||
| 372 | (error t))))) | 370 | (error t))))) |
| 373 | 371 | ||
| 374 | (defun reftex-re-enlarge () | 372 | (defun reftex-re-enlarge () |
| 375 | ;; Enlarge window to a remembered size. | 373 | "Enlarge window to a remembered size." |
| 376 | (if reftex-toc-split-windows-horizontally | 374 | (let ((count (if reftex-toc-split-windows-horizontally |
| 377 | (enlarge-window-horizontally | 375 | (- (or reftex-last-window-width (window-width)) |
| 378 | (max 0 (- (or reftex-last-window-width (window-width)) | 376 | (window-width)) |
| 379 | (window-width)))) | 377 | (- (or reftex-last-window-height (window-height)) |
| 380 | (enlarge-window | 378 | (window-height))))) |
| 381 | (max 0 (- (or reftex-last-window-height (window-height)) | 379 | (when (> count 0) |
| 382 | (window-height)))))) | 380 | (enlarge-window count reftex-toc-split-windows-horizontally)))) |
| 383 | 381 | ||
| 384 | (defun reftex-toc-dframe-p (&optional frame error) | 382 | (defun reftex-toc-dframe-p (&optional frame error) |
| 385 | ;; Check if FRAME is the dedicated TOC frame. | 383 | ;; Check if FRAME is the dedicated TOC frame. |
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 3470ef9f3c1..df3d729adca 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Maintainer: auctex-devel@gnu.org | 6 | ;; Maintainer: auctex-devel@gnu.org |
| 7 | ;; Version: 4.31 | ||
| 8 | ;; Package: reftex | ||
| 9 | 7 | ||
| 10 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 11 | 9 | ||
| @@ -207,6 +205,11 @@ distribution. Mixed-case symbols are convenience aliases.") | |||
| 207 | (?p . "(%2a %y\\nocite{%l})"))) | 205 | (?p . "(%2a %y\\nocite{%l})"))) |
| 208 | (locally "Full info in parenthesis" | 206 | (locally "Full info in parenthesis" |
| 209 | "(%2a %y, %j %v, %P, %e: %b, %u, %s %<)") | 207 | "(%2a %y, %j %v, %P, %e: %b, %u, %s %<)") |
| 208 | (context | ||
| 209 | "ConTeXt bib module" | ||
| 210 | ((?\C-m . "\\cite[%l]") | ||
| 211 | (?s . "\\cite[][%l]") | ||
| 212 | (?n . "\\nocite[%l]"))) | ||
| 210 | ) | 213 | ) |
| 211 | "Builtin versions of the citation format. | 214 | "Builtin versions of the citation format. |
| 212 | The following conventions are valid for all alist entries: | 215 | The following conventions are valid for all alist entries: |
| @@ -239,7 +242,7 @@ distribution. Mixed-case symbols are convenience aliases.") | |||
| 239 | "LaTeX label and citation support." | 242 | "LaTeX label and citation support." |
| 240 | :tag "RefTeX" | 243 | :tag "RefTeX" |
| 241 | :link '(url-link :tag "Home Page" | 244 | :link '(url-link :tag "Home Page" |
| 242 | "http://staff.science.uva.nl/~dominik/Tools/reftex/") | 245 | "http://www.gnu.org/software/auctex/reftex.html") |
| 243 | :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el") | 246 | :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el") |
| 244 | :link '(custom-manual "(reftex)Top") | 247 | :link '(custom-manual "(reftex)Top") |
| 245 | :prefix "reftex-" | 248 | :prefix "reftex-" |
| @@ -261,8 +264,8 @@ by whitespace." | |||
| 261 | 264 | ||
| 262 | (defcustom reftex-max-section-depth 12 | 265 | (defcustom reftex-max-section-depth 12 |
| 263 | "Maximum depth of section levels in document structure. | 266 | "Maximum depth of section levels in document structure. |
| 264 | Standard LaTeX needs default is 7, but there are packages for which this | 267 | The default in standard LaTeX is 7, but there are packages for |
| 265 | needs to be larger." | 268 | which this needs to be larger." |
| 266 | :group 'reftex-table-of-contents-browser | 269 | :group 'reftex-table-of-contents-browser |
| 267 | :type 'integer) | 270 | :type 'integer) |
| 268 | 271 | ||
| @@ -329,7 +332,7 @@ recentering will work for any TOC window created during the session. | |||
| 329 | 332 | ||
| 330 | Value 'frame (the default) means, turn automatic recentering on only while the | 333 | Value 'frame (the default) means, turn automatic recentering on only while the |
| 331 | dedicated TOC frame does exist, and do the recentering only in that frame. So | 334 | dedicated TOC frame does exist, and do the recentering only in that frame. So |
| 332 | when creating that frame (with \"d\" key in an ordinary TOC window), the | 335 | when creating that frame (with `d' key in an ordinary TOC window), the |
| 333 | automatic recentering is turned on. When the frame gets destroyed, automatic | 336 | automatic recentering is turned on. When the frame gets destroyed, automatic |
| 334 | recentering is turned off again. | 337 | recentering is turned off again. |
| 335 | 338 | ||
| @@ -383,8 +386,8 @@ This flag can be toggled from within the *toc* buffer with the `i' key." | |||
| 383 | 386 | ||
| 384 | (defcustom reftex-toc-confirm-promotion 2 | 387 | (defcustom reftex-toc-confirm-promotion 2 |
| 385 | "Non-nil means, promotion/demotion commands first prompt for confirmation. | 388 | "Non-nil means, promotion/demotion commands first prompt for confirmation. |
| 386 | When nil, the command is executed immediately. When this is an integer | 389 | If nil, the command is executed immediately. If this is an integer N, |
| 387 | N, ask for confirmation only if N or more section commands are going to be | 390 | ask for confirmation only if N or more section commands are going to be |
| 388 | changed." | 391 | changed." |
| 389 | :group 'reftex-table-of-contents-browser | 392 | :group 'reftex-table-of-contents-browser |
| 390 | :type '(choice | 393 | :type '(choice |
| @@ -408,7 +411,7 @@ This flag can be toggled from within the *toc* buffer with the `f' key." | |||
| 408 | 411 | ||
| 409 | (defcustom reftex-revisit-to-follow nil | 412 | (defcustom reftex-revisit-to-follow nil |
| 410 | "Non-nil means, follow-mode will revisit files if necessary. | 413 | "Non-nil means, follow-mode will revisit files if necessary. |
| 411 | When nil, follow-mode will be suspended for stuff in unvisited files." | 414 | If nil, follow-mode will be suspended for stuff in unvisited files." |
| 412 | :group 'reftex-table-of-contents-browser | 415 | :group 'reftex-table-of-contents-browser |
| 413 | :group 'reftex-referencing-labels | 416 | :group 'reftex-referencing-labels |
| 414 | :type 'boolean) | 417 | :type 'boolean) |
| @@ -452,8 +455,8 @@ of options." | |||
| 452 | (defcustom reftex-label-alist nil | 455 | (defcustom reftex-label-alist nil |
| 453 | "Alist with information on environments for \\label-\\ref use. | 456 | "Alist with information on environments for \\label-\\ref use. |
| 454 | 457 | ||
| 455 | This docstring is easier to understand after reading the configuration | 458 | This doc string is easier to understand after reading the configuration |
| 456 | examples in `reftex.el'. Looking at the builtin defaults in the constant | 459 | examples in the manual. Looking at the builtin defaults in the constant |
| 457 | `reftex-label-alist-builtin' may also be instructive. | 460 | `reftex-label-alist-builtin' may also be instructive. |
| 458 | 461 | ||
| 459 | Set this variable to define additions and changes to the default. The only | 462 | Set this variable to define additions and changes to the default. The only |
| @@ -481,12 +484,11 @@ ENV-OR-MACRO | |||
| 481 | Special names: `section' for section labels, `any' to define a group | 484 | Special names: `section' for section labels, `any' to define a group |
| 482 | which contains all labels. | 485 | which contains all labels. |
| 483 | 486 | ||
| 484 | This may also be a function to do local parsing and identify point | 487 | This may also be a function to do local parsing and identify point to |
| 485 | to be in a non-standard label environment. The function must take | 488 | be in a non-standard label environment. The function must take an |
| 486 | an argument BOUND and limit backward searches to this value. It | 489 | argument BOUND and limit backward searches to this value. It should |
| 487 | should return either nil or a cons cell (FUNCTION . POSITION) with | 490 | return either nil or the position where the special environment starts. |
| 488 | the function symbol and the position where the special environment | 491 | See the Info documentation for an example. |
| 489 | starts. See the Info documentation for an example. | ||
| 490 | 492 | ||
| 491 | Finally this may also be nil if the entry is only meant to change | 493 | Finally this may also be nil if the entry is only meant to change |
| 492 | some settings associated with the type indicator character (see below). | 494 | some settings associated with the type indicator character (see below). |
| @@ -500,7 +502,7 @@ TYPE-KEY | |||
| 500 | `equation' and `eqnarray'). | 502 | `equation' and `eqnarray'). |
| 501 | If the type indicator is nil and the macro has a label argument {*}, | 503 | If the type indicator is nil and the macro has a label argument {*}, |
| 502 | the macro defines neutral labels just like \\label. In this case | 504 | the macro defines neutral labels just like \\label. In this case |
| 503 | the reminder of this entry is ignored. | 505 | the remainder of this entry is ignored. |
| 504 | 506 | ||
| 505 | LABEL-PREFIX | 507 | LABEL-PREFIX |
| 506 | Label prefix string, like \"tab:\". | 508 | Label prefix string, like \"tab:\". |
| @@ -516,8 +518,8 @@ LABEL-PREFIX | |||
| 516 | Example: In a file `intro.tex', \"eq:%f:\" will become \"eq:intro:\"). | 518 | Example: In a file `intro.tex', \"eq:%f:\" will become \"eq:intro:\"). |
| 517 | 519 | ||
| 518 | REFERENCE-FORMAT | 520 | REFERENCE-FORMAT |
| 519 | Format string for reference insert in buffer. `%s' will be replaced by | 521 | Format string for reference insertion in buffer. `%s' will be replaced |
| 520 | the label. | 522 | by the label. |
| 521 | When the format starts with `~', the `~' will only be inserted if | 523 | When the format starts with `~', the `~' will only be inserted if |
| 522 | there is not already a whitespace before point. | 524 | there is not already a whitespace before point. |
| 523 | 525 | ||
| @@ -533,7 +535,7 @@ CONTEXT-METHOD | |||
| 533 | - If an integer, use the nth argument of the macro. As a special case, | 535 | - If an integer, use the nth argument of the macro. As a special case, |
| 534 | 1000 means to get text after the last macro argument. | 536 | 1000 means to get text after the last macro argument. |
| 535 | - If a string, use as regexp to search *backward* from the label. Context | 537 | - If a string, use as regexp to search *backward* from the label. Context |
| 536 | is then the text following the end of the match. E.g. putting this to | 538 | is then the text following the end of the match. E.g. setting this to |
| 537 | \"\\\\\\\\caption[[{]\" will use the caption in a figure or table | 539 | \"\\\\\\\\caption[[{]\" will use the caption in a figure or table |
| 538 | environment. | 540 | environment. |
| 539 | \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays. | 541 | \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays. |
| @@ -755,8 +757,7 @@ And here is the setup for RefTeX: | |||
| 755 | 757 | ||
| 756 | 3. Tell RefTeX to use this function | 758 | 3. Tell RefTeX to use this function |
| 757 | 759 | ||
| 758 | (setq reftex-special-environment-functions '(my-detect-linguex-list)) | 760 | (setq reftex-special-environment-functions '(my-detect-linguex-list))" |
| 759 | " | ||
| 760 | :group 'reftex-defining-label-environments | 761 | :group 'reftex-defining-label-environments |
| 761 | :type 'hook) | 762 | :type 'hook) |
| 762 | 763 | ||
| @@ -820,11 +821,13 @@ RefTeX's default function uses the variable `reftex-derive-label-parameters'." | |||
| 820 | :type 'symbol) | 821 | :type 'symbol) |
| 821 | 822 | ||
| 822 | (defcustom reftex-translate-to-ascii-function 'reftex-latin1-to-ascii | 823 | (defcustom reftex-translate-to-ascii-function 'reftex-latin1-to-ascii |
| 823 | "Filter function which will process a context string before it is used | 824 | "Filter function to convert a string to ASCII. |
| 824 | to derive a label from it. The intended application is to convert ISO or | 825 | The function is used to process a context string before it is |
| 825 | Mule characters into something valid in labels. The default function | 826 | used to derive a label from it. The intended application is to |
| 826 | removes the accents from Latin-1 characters. X-Symbol (>=2.6) sets this | 827 | convert ISO or Mule characters into something valid in labels. |
| 827 | variable to the much more general `x-symbol-translate-to-ascii'." | 828 | The default function removes the accents from Latin-1 characters. |
| 829 | X-Symbol (>=2.6) sets this variable to the much more general | ||
| 830 | `x-symbol-translate-to-ascii'." | ||
| 828 | :group 'reftex-making-and-inserting-labels | 831 | :group 'reftex-making-and-inserting-labels |
| 829 | :type 'symbol) | 832 | :type 'symbol) |
| 830 | 833 | ||
| @@ -947,28 +950,79 @@ This is used to string together whole reference sets, like | |||
| 947 | :group 'reftex-referencing-labels | 950 | :group 'reftex-referencing-labels |
| 948 | :type '(repeat (cons (character) (string)))) | 951 | :type '(repeat (cons (character) (string)))) |
| 949 | 952 | ||
| 953 | (defcustom reftex-ref-style-alist | ||
| 954 | '(("Default" t | ||
| 955 | (("\\ref" ?\C-m) ("\\pageref" ?p))) | ||
| 956 | ("Varioref" "varioref" | ||
| 957 | (("\\vref" ?v) ("\\vpageref" ?g) ("\\Vref" ?V) ("\\Ref" ?R))) | ||
| 958 | ("Fancyref" "fancyref" | ||
| 959 | (("\\fref" ?f) ("\\Fref" ?F))) | ||
| 960 | ("Hyperref" "hyperref" | ||
| 961 | (("\\autoref" ?a) ("\\autopageref" ?u)))) | ||
| 962 | "Alist of reference styles. | ||
| 963 | Each element is a list of the style name, the name of the LaTeX | ||
| 964 | package associated with the style or t for any package, and an | ||
| 965 | alist of macros where the first entry of each item is the | ||
| 966 | reference macro and the second a key for selecting the macro when | ||
| 967 | the macro type is being prompted for. (See also | ||
| 968 | `reftex-ref-macro-prompt'.) The keys, represented as characters, | ||
| 969 | have to be unique." | ||
| 970 | :group 'reftex-referencing-labels | ||
| 971 | :type '(alist :key-type (string :tag "Style name") | ||
| 972 | :value-type (group (choice :tag "Package" | ||
| 973 | (const :tag "Any package" t) | ||
| 974 | (string :tag "Name")) | ||
| 975 | (repeat :tag "Macros" | ||
| 976 | (group (string :tag "Macro") | ||
| 977 | (character :tag "Key")))))) | ||
| 978 | |||
| 979 | (defcustom reftex-ref-macro-prompt t | ||
| 980 | "If non-nil, `reftex-reference' prompts for the reference macro." | ||
| 981 | :group 'reftex-referencing-labels | ||
| 982 | :type 'boolean) | ||
| 983 | |||
| 950 | (defcustom reftex-vref-is-default nil | 984 | (defcustom reftex-vref-is-default nil |
| 951 | "Non-nil means, the varioref macro \\vref is used as default. | 985 | "Non-nil means, the varioref reference style is used as default. |
| 952 | In the selection buffer, the `v' key toggles the reference macro between | 986 | The value of this variable determines the default which is active |
| 953 | `\\ref' and `\\vref'. The value of this variable determines the default | 987 | when entering the selection process. Instead of nil or t, this |
| 954 | which is active when entering the selection process. | 988 | may also be a string of type letters indicating the label types |
| 955 | Instead of nil or t, this may also be a string of type letters indicating | 989 | for which it should be true. |
| 956 | the label types for which it should be true." | 990 | |
| 991 | This variable is obsolete, use `reftex-ref-style-default-list' | ||
| 992 | instead." | ||
| 957 | :group 'reftex-referencing-labels | 993 | :group 'reftex-referencing-labels |
| 958 | :type `(choice :tag "\\vref is default macro" ,@reftex-tmp)) | 994 | :type `(choice :tag "\\vref is default macro" ,@reftex-tmp)) |
| 959 | ;;;###autoload(put 'reftex-vref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x)))) | 995 | ;;;###autoload(put 'reftex-vref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x)))) |
| 960 | 996 | ||
| 961 | (defcustom reftex-fref-is-default nil | 997 | (defcustom reftex-fref-is-default nil |
| 962 | "Non-nil means, the fancyref macro \\fref is used as default. | 998 | "Non-nil means, the fancyref reference style is used as default. |
| 963 | In the selection buffer, the `V' key toggles the reference macro between | 999 | The value of this variable determines the default which is active |
| 964 | `\\ref', `\\fref' and `\\Fref'. The value of this variable determines | 1000 | when entering the selection process. Instead of nil or t, this |
| 965 | the default which is active when entering the selection process. | 1001 | may also be a string of type letters indicating the label types |
| 966 | Instead of nil or t, this may also be a string of type letters indicating | 1002 | for which it should be true. |
| 967 | the label types for which it should be true." | 1003 | |
| 1004 | This variable is obsolete, use `reftex-ref-style-default-list' | ||
| 1005 | instead." | ||
| 968 | :group 'reftex-referencing-labels | 1006 | :group 'reftex-referencing-labels |
| 969 | :type `(choice :tag "\\fref is default macro" ,@reftex-tmp)) | 1007 | :type `(choice :tag "\\fref is default macro" ,@reftex-tmp)) |
| 970 | ;;;###autoload(put 'reftex-fref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x)))) | 1008 | ;;;###autoload(put 'reftex-fref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x)))) |
| 971 | 1009 | ||
| 1010 | (defcustom reftex-ref-style-default-list '("Default") | ||
| 1011 | "List of reference styles to be activated by default. | ||
| 1012 | The order is significant and controls the order in which macros | ||
| 1013 | can be cycled in the buffer for selecting a label. The entries | ||
| 1014 | in the list have to match the respective reference style names | ||
| 1015 | used in the variable `reftex-ref-style-alist'." | ||
| 1016 | :group 'reftex-referencing-labels | ||
| 1017 | :type `(set ,@(mapcar (lambda (x) (list 'const (car x))) | ||
| 1018 | reftex-ref-style-alist))) | ||
| 1019 | |||
| 1020 | ;; Compatibility with obsolete variables. | ||
| 1021 | (when reftex-vref-is-default | ||
| 1022 | (add-to-list 'reftex-ref-style-default-list "Varioref")) | ||
| 1023 | (when reftex-fref-is-default | ||
| 1024 | (add-to-list 'reftex-ref-style-default-list "Fancyref")) | ||
| 1025 | |||
| 972 | (defcustom reftex-level-indent 2 | 1026 | (defcustom reftex-level-indent 2 |
| 973 | "Number of spaces to be used for indentation per section level." | 1027 | "Number of spaces to be used for indentation per section level." |
| 974 | :group 'reftex-referencing-labels | 1028 | :group 'reftex-referencing-labels |
| @@ -987,19 +1041,22 @@ a label type. If you set this variable to nil, RefTeX will always prompt." | |||
| 987 | 1041 | ||
| 988 | (defcustom reftex-format-ref-function nil | 1042 | (defcustom reftex-format-ref-function nil |
| 989 | "Function which produces the string to insert as a reference. | 1043 | "Function which produces the string to insert as a reference. |
| 990 | Normally should be nil, because the format to insert a reference can | 1044 | Normally should be nil, because the format to insert a reference |
| 991 | already be specified in `reftex-label-alist'. | 1045 | can already be specified in `reftex-label-alist'. |
| 992 | This hook also is used by the special commands to insert `\\vref' and `\\fref' | 1046 | |
| 993 | references, so even if you set this, your setting will be ignored by | 1047 | This hook also is used by the special commands to insert |
| 994 | the special commands. | 1048 | e.g. `\\vref' and `\\fref' references, so even if you set this, |
| 995 | The function will be called with two arguments, the LABEL and the DEFAULT | 1049 | your setting will be ignored by the special commands. |
| 996 | FORMAT, which normally is `~\\ref{%s}'. The function should return the | 1050 | |
| 997 | string to insert into the buffer." | 1051 | The function will be called with three arguments, the LABEL, the |
| 1052 | DEFAULT FORMAT, which normally is `~\\ref{%s}' and the REFERENCE | ||
| 1053 | STYLE. The function should return the string to insert into the | ||
| 1054 | buffer." | ||
| 998 | :group 'reftex-referencing-labels | 1055 | :group 'reftex-referencing-labels |
| 999 | :type 'function) | 1056 | :type '(choice (const nil) function)) |
| 1000 | 1057 | ||
| 1001 | (defcustom reftex-select-label-mode-hook nil | 1058 | (defcustom reftex-select-label-mode-hook nil |
| 1002 | "Mode hook for reftex-select-label-mode." | 1059 | "Mode hook for `reftex-select-label-mode'." |
| 1003 | :group 'reftex-referencing-labels | 1060 | :group 'reftex-referencing-labels |
| 1004 | :type 'hook) | 1061 | :type 'hook) |
| 1005 | 1062 | ||
| @@ -1009,7 +1066,8 @@ string to insert into the buffer." | |||
| 1009 | "Support for referencing bibliographic data with BibTeX." | 1066 | "Support for referencing bibliographic data with BibTeX." |
| 1010 | :group 'reftex) | 1067 | :group 'reftex) |
| 1011 | 1068 | ||
| 1012 | (defcustom reftex-bibliography-commands '("bibliography" "nobibliography") | 1069 | (defcustom reftex-bibliography-commands |
| 1070 | '("bibliography" "nobibliography" "setupbibtex\\[.*?database=") | ||
| 1013 | "LaTeX commands which specify the BibTeX databases to use with the document." | 1071 | "LaTeX commands which specify the BibTeX databases to use with the document." |
| 1014 | :group 'reftex-citation-support | 1072 | :group 'reftex-citation-support |
| 1015 | :type '(repeat string)) | 1073 | :type '(repeat string)) |
| @@ -1114,7 +1172,7 @@ E.g.: (setq reftex-cite-format 'natbib)" | |||
| 1114 | 1172 | ||
| 1115 | (defcustom reftex-cite-prompt-optional-args 'maybe | 1173 | (defcustom reftex-cite-prompt-optional-args 'maybe |
| 1116 | "Non-nil means, prompt for empty optional arguments in cite macros. | 1174 | "Non-nil means, prompt for empty optional arguments in cite macros. |
| 1117 | When an entry in `reftex-cite-format' ist given with square brackets to | 1175 | When an entry in `reftex-cite-format' is given with square brackets to |
| 1118 | indicate optional arguments (for example \\cite[][]{%l}), RefTeX can | 1176 | indicate optional arguments (for example \\cite[][]{%l}), RefTeX can |
| 1119 | prompt for values. Possible values are: | 1177 | prompt for values. Possible values are: |
| 1120 | 1178 | ||
| @@ -1189,13 +1247,28 @@ The function will be called with two arguments, the CITATION KEY and the | |||
| 1189 | DEFAULT FORMAT, which is taken from `reftex-cite-format'. The function | 1247 | DEFAULT FORMAT, which is taken from `reftex-cite-format'. The function |
| 1190 | should return the string to insert into the buffer." | 1248 | should return the string to insert into the buffer." |
| 1191 | :group 'reftex-citation-support | 1249 | :group 'reftex-citation-support |
| 1192 | :type 'function) | 1250 | :type '(choice (const nil) function)) |
| 1193 | 1251 | ||
| 1194 | (defcustom reftex-select-bib-mode-hook nil | 1252 | (defcustom reftex-select-bib-mode-hook nil |
| 1195 | "Mode hook for reftex-select-bib-mode." | 1253 | "Mode hook for reftex-select-bib-mode." |
| 1196 | :group 'reftex-citation-support | 1254 | :group 'reftex-citation-support |
| 1197 | :type 'hook) | 1255 | :type 'hook) |
| 1198 | 1256 | ||
| 1257 | (defcustom reftex-cite-key-separator "," | ||
| 1258 | "String to be used for separating several keys in a \\cite macro." | ||
| 1259 | :group 'reftex-citation-support | ||
| 1260 | :type 'string) | ||
| 1261 | |||
| 1262 | (defcustom reftex-create-bibtex-header nil | ||
| 1263 | "Header to insert in BibTeX files generated by RefTeX." | ||
| 1264 | :group 'reftex-citation-support | ||
| 1265 | :type 'string) | ||
| 1266 | |||
| 1267 | (defcustom reftex-create-bibtex-footer nil | ||
| 1268 | "Footer to insert in BibTeX files generated by RefTeX." | ||
| 1269 | :group 'reftex-citation-support | ||
| 1270 | :type 'string) | ||
| 1271 | |||
| 1199 | ;; Index Support Configuration | 1272 | ;; Index Support Configuration |
| 1200 | 1273 | ||
| 1201 | (defgroup reftex-index-support nil | 1274 | (defgroup reftex-index-support nil |
| @@ -1223,7 +1296,9 @@ These correspond to the makeindex keywords LEVEL ENCAP ACTUAL QUOTE ESCAPE." | |||
| 1223 | (string :tag "ESCAPE char "))) | 1296 | (string :tag "ESCAPE char "))) |
| 1224 | 1297 | ||
| 1225 | (defcustom reftex-index-macros nil | 1298 | (defcustom reftex-index-macros nil |
| 1226 | "Macros which define index entries. The structure is | 1299 | "Macros which define index entries. |
| 1300 | |||
| 1301 | The structure is | ||
| 1227 | 1302 | ||
| 1228 | \(MACRO INDEX-TAG KEY PREFIX EXCLUDE REPEAT) | 1303 | \(MACRO INDEX-TAG KEY PREFIX EXCLUDE REPEAT) |
| 1229 | 1304 | ||
| @@ -1456,7 +1531,7 @@ This flag can be toggled from within the *Index* buffer with the `f' key." | |||
| 1456 | This is used when `reftex-view-crossref' is called with point in an | 1531 | This is used when `reftex-view-crossref' is called with point in an |
| 1457 | argument of a macro. Note that crossref viewing for citations, | 1532 | argument of a macro. Note that crossref viewing for citations, |
| 1458 | references (both ways) and index entries is hard-coded. This variable | 1533 | references (both ways) and index entries is hard-coded. This variable |
| 1459 | is only to configure additional structures for which crossreference | 1534 | is only to configure additional structures for which cross-reference |
| 1460 | viewing can be useful. Each entry has the structure | 1535 | viewing can be useful. Each entry has the structure |
| 1461 | 1536 | ||
| 1462 | \(MACRO-RE SEARCH-RE HIGHLIGHT). | 1537 | \(MACRO-RE SEARCH-RE HIGHLIGHT). |
| @@ -1499,15 +1574,17 @@ entries and for BibTeX database files with live associated buffers." | |||
| 1499 | :type 'boolean) | 1574 | :type 'boolean) |
| 1500 | 1575 | ||
| 1501 | (defcustom reftex-cache-cite-echo t | 1576 | (defcustom reftex-cache-cite-echo t |
| 1502 | "Non-nil means, the information displayed in the echo area for cite macros | 1577 | "Non-nil means, echoed information for cite macros is cached. |
| 1503 | is cached and even saved along with the parsing information. The cache | 1578 | The information displayed in the echo area for cite macros is |
| 1504 | survives document scans. In order to clear it, use M-x reftex-reset-mode." | 1579 | cached and even saved along with the parsing information. The |
| 1580 | cache survives document scans. In order to clear it, use M-x | ||
| 1581 | reftex-reset-mode <RET>." | ||
| 1505 | :group 'reftex-viewing-cross-references | 1582 | :group 'reftex-viewing-cross-references |
| 1506 | :type 'boolean) | 1583 | :type 'boolean) |
| 1507 | 1584 | ||
| 1508 | (defcustom reftex-display-copied-context-hook nil | 1585 | (defcustom reftex-display-copied-context-hook nil |
| 1509 | "Normal Hook which is run before context is displayed anywhere. Designed | 1586 | "Normal hook which is run before context is displayed anywhere. |
| 1510 | for X-Symbol, but may have other uses as well." | 1587 | Designed for X-Symbol, but may have other uses as well." |
| 1511 | :group 'reftex-viewing-cross-references | 1588 | :group 'reftex-viewing-cross-references |
| 1512 | :group 'reftex-referencing-labels | 1589 | :group 'reftex-referencing-labels |
| 1513 | :type 'hook) | 1590 | :type 'hook) |
| @@ -1690,7 +1767,7 @@ The file MASTER.rel in the same directory as MASTER.tex is used to save the | |||
| 1690 | information. When this variable is t, | 1767 | information. When this variable is t, |
| 1691 | - accessing the parsing information for the first time in an editing session | 1768 | - accessing the parsing information for the first time in an editing session |
| 1692 | will read that file (if available) instead of parsing the document. | 1769 | will read that file (if available) instead of parsing the document. |
| 1693 | - exiting Emacs or killing a buffer in reftex-mode will cause a new version | 1770 | - exiting Emacs or killing a buffer in `reftex-mode' will cause a new version |
| 1694 | of the file to be written." | 1771 | of the file to be written." |
| 1695 | :group 'reftex-optimizations-for-large-documents | 1772 | :group 'reftex-optimizations-for-large-documents |
| 1696 | :type 'boolean) | 1773 | :type 'boolean) |
| @@ -1855,22 +1932,13 @@ symbol indicating in what context the hook is called." | |||
| 1855 | 1932 | ||
| 1856 | (defcustom reftex-extra-bindings nil | 1933 | (defcustom reftex-extra-bindings nil |
| 1857 | "Non-nil means, make additional key bindings on startup. | 1934 | "Non-nil means, make additional key bindings on startup. |
| 1858 | These extra bindings are located in the | 1935 | These extra bindings are located in the users `C-c letter' map." |
| 1859 | `reftex-extra-bindings-map' map, bound to | ||
| 1860 | `reftex-extra-bindings-prefix'." | ||
| 1861 | :group 'reftex-miscellaneous-configurations | ||
| 1862 | :type 'boolean) | ||
| 1863 | |||
| 1864 | ;; below, default is C-c C-y because it is free in LaTeX mode. | ||
| 1865 | (defcustom reftex-extra-bindings-prefix "\C-c\C-y" | ||
| 1866 | "When `reftex-extra-bindings' is set to non-nil, use extra | ||
| 1867 | bindings with this prefix bound to `reftex-extra-bindings-map'." | ||
| 1868 | :group 'reftex-miscellaneous-configurations | 1936 | :group 'reftex-miscellaneous-configurations |
| 1869 | :type 'boolean) | 1937 | :type 'boolean) |
| 1870 | 1938 | ||
| 1871 | (defcustom reftex-plug-into-AUCTeX nil | 1939 | (defcustom reftex-plug-into-AUCTeX nil |
| 1872 | "Plug-in flags for AUCTeX interface. | 1940 | "Plug-in flags for AUCTeX interface. |
| 1873 | This variable is a list of 4 boolean flags. When a flag is non-nil, | 1941 | This variable is a list of 5 boolean flags. When a flag is non-nil, |
| 1874 | RefTeX will | 1942 | RefTeX will |
| 1875 | 1943 | ||
| 1876 | - supply labels in new sections and environments (flag 1) | 1944 | - supply labels in new sections and environments (flag 1) |
| @@ -1900,8 +1968,7 @@ may require a restart of Emacs in order to become effective." | |||
| 1900 | (boolean :tag "supply argument for macros like `\\label' ") | 1968 | (boolean :tag "supply argument for macros like `\\label' ") |
| 1901 | (boolean :tag "supply argument for macros like `\\ref' ") | 1969 | (boolean :tag "supply argument for macros like `\\ref' ") |
| 1902 | (boolean :tag "supply argument for macros like `\\cite' ") | 1970 | (boolean :tag "supply argument for macros like `\\cite' ") |
| 1903 | (boolean :tag "supply argument for macros like `\\index' ") | 1971 | (boolean :tag "supply argument for macros like `\\index' ")))) |
| 1904 | ))) | ||
| 1905 | 1972 | ||
| 1906 | (defcustom reftex-allow-detached-macro-args nil | 1973 | (defcustom reftex-allow-detached-macro-args nil |
| 1907 | "Non-nil means, allow arguments of macros to be detached by whitespace. | 1974 | "Non-nil means, allow arguments of macros to be detached by whitespace. |
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 8318dc0d5f3..7052dcf473e 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 4 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 5 | ;; Maintainer: auctex-devel@gnu.org | 5 | ;; Maintainer: auctex-devel@gnu.org |
| 6 | ;; Version: 4.31 | ||
| 7 | ;; Keywords: tex | 6 | ;; Keywords: tex |
| 8 | 7 | ||
| 9 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| @@ -21,10 +20,8 @@ | |||
| 21 | ;; You should have received a copy of the GNU General Public License | 20 | ;; You should have received a copy of the GNU General Public License |
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 23 | 22 | ||
| 24 | ;;--------------------------------------------------------------------------- | ||
| 25 | ;; | ||
| 26 | ;;; Commentary: | 23 | ;;; Commentary: |
| 27 | ;; | 24 | |
| 28 | ;; RefTeX is a minor mode with distinct support for \ref, \label, \cite, | 25 | ;; RefTeX is a minor mode with distinct support for \ref, \label, \cite, |
| 29 | ;; and \index commands in (multi-file) LaTeX documents. | 26 | ;; and \index commands in (multi-file) LaTeX documents. |
| 30 | ;; - A table of contents provides easy access to any part of a document. | 27 | ;; - A table of contents provides easy access to any part of a document. |
| @@ -34,243 +31,23 @@ | |||
| 34 | ;; - Text phrases can be collected in a file, for later global indexing. | 31 | ;; - Text phrases can be collected in a file, for later global indexing. |
| 35 | ;; - The index preview buffer helps to check and edit index entries. | 32 | ;; - The index preview buffer helps to check and edit index entries. |
| 36 | ;; | 33 | ;; |
| 37 | ;; | 34 | ;; There is an extensive Texinfo document describing RefTeX in detail. |
| 38 | ;; INSTALLATION | ||
| 39 | ;; ------------ | ||
| 40 | ;; | ||
| 41 | ;; - If this file is part of an X/Emacs distribution, it is installed. | ||
| 42 | ;; - For XEmacs 21.x, you need to install the RefTeX plug-in package | ||
| 43 | ;; available from the XEmacs distribution sites. | ||
| 44 | ;; - If you have downloaded this file from the maintainers webpage, follow | ||
| 45 | ;; the instructions in the INSTALL file of the distribution. | ||
| 46 | ;; | ||
| 47 | ;; To turn RefTeX Mode on and off in a buffer, use `M-x reftex-mode'. | ||
| 48 | ;; | ||
| 49 | ;; To turn on RefTeX Mode for all LaTeX files, add the following lines | ||
| 50 | ;; to your init file: | ||
| 51 | ;; | ||
| 52 | ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; AUCTeX LaTeX mode | ||
| 53 | ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; Emacs latex mode | ||
| 54 | ;; | ||
| 55 | ;; | ||
| 56 | ;; DOCUMENTATION | ||
| 57 | ;; ------------- | ||
| 58 | ;; | ||
| 59 | ;; See below for a short summary of how to use RefTeX. | ||
| 60 | ;; | ||
| 61 | ;; There is an extensive texinfo document describing RefTeX in detail. | ||
| 62 | ;; One way to view this documentation is `M-x reftex-info RET'. | 35 | ;; One way to view this documentation is `M-x reftex-info RET'. |
| 63 | ;; | 36 | ;; |
| 64 | ;; The documentation in various formats is also available at | 37 | ;; The documentation in various formats is also available at |
| 65 | ;; | 38 | ;; |
| 66 | ;; http://zon.astro.uva.nl/~dominik/Tools/ | 39 | ;; http://www.gnu.org/software/auctex/manual/reftex.index.html |
| 67 | ;; | ||
| 68 | ;;--------------------------------------------------------------------------- | ||
| 69 | ;; | ||
| 70 | ;; Introduction | ||
| 71 | ;; ************ | ||
| 72 | ;; | ||
| 73 | ;; RefTeX is a specialized package for support of labels, references, | ||
| 74 | ;; citations, and the index in LaTeX. RefTeX wraps itself round 4 LaTeX | ||
| 75 | ;; macros: `\label', `\ref', `\cite', and `\index'. Using these macros | ||
| 76 | ;; usually requires looking up different parts of the document and | ||
| 77 | ;; searching through BibTeX database files. RefTeX automates these | ||
| 78 | ;; time-consuming tasks almost entirely. It also provides functions to | ||
| 79 | ;; display the structure of a document and to move around in this | ||
| 80 | ;; structure quickly. | ||
| 81 | ;; | ||
| 82 | ;; *Note Imprint::, for information about who to contact for help, bug | ||
| 83 | ;; reports or suggestions. | ||
| 84 | ;; | ||
| 85 | ;; Environment | ||
| 86 | ;; =========== | ||
| 87 | ;; | ||
| 88 | ;; RefTeX needs to access all files which are part of a multifile | ||
| 89 | ;; document, and the BibTeX database files requested by the | ||
| 90 | ;; `\bibliography' command. To find these files, RefTeX will require a | ||
| 91 | ;; search path, i.e. a list of directories to check. Normally this list | ||
| 92 | ;; is stored in the environment variables `TEXINPUTS' and `BIBINPUTS' | ||
| 93 | ;; which are also used by RefTeX. However, on some systems these | ||
| 94 | ;; variables do not contain the full search path. If RefTeX does not work | ||
| 95 | ;; for you because it cannot find some files, read *Note Finding Files::. | ||
| 96 | ;; | ||
| 97 | ;; Entering RefTeX Mode | ||
| 98 | ;; ==================== | ||
| 99 | ;; | ||
| 100 | ;; To turn RefTeX Mode on and off in a particular buffer, use `M-x | ||
| 101 | ;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the | ||
| 102 | ;; following lines to your init file: | ||
| 103 | ;; | ||
| 104 | ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode | ||
| 105 | ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode | ||
| 106 | ;; | ||
| 107 | ;; RefTeX in a Nutshell | ||
| 108 | ;; ==================== | ||
| 109 | ;; | ||
| 110 | ;; 1. Table of Contents | ||
| 111 | ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the | ||
| 112 | ;; document. This buffer can display sections, labels and index | ||
| 113 | ;; entries defined in the document. From the buffer, you can jump | ||
| 114 | ;; quickly to every part of your document. Press `?' to get help. | ||
| 115 | ;; | ||
| 116 | ;; 2. Labels and References | ||
| 117 | ;; RefTeX helps to create unique labels and to find the correct key | ||
| 118 | ;; for references quickly. It distinguishes labels for different | ||
| 119 | ;; environments, knows about all standard environments (and many | ||
| 120 | ;; others), and can be configured to recognize any additional labeled | ||
| 121 | ;; environments you have defined yourself (variable | ||
| 122 | ;; `reftex-label-alist'). | ||
| 123 | ;; | ||
| 124 | ;; * Creating Labels | ||
| 125 | ;; Type `C-c (' (`reftex-label') to insert a label at point. | ||
| 126 | ;; RefTeX will either | ||
| 127 | ;; - derive a label from context (default for section labels) | ||
| 128 | ;; - prompt for a label string (default for figures and | ||
| 129 | ;; tables) or | ||
| 130 | ;; - insert a simple label made of a prefix and a number (all | ||
| 131 | ;; other environments) | ||
| 132 | ;; | ||
| 133 | ;; Which labels are created how is configurable with the variable | ||
| 134 | ;; `reftex-insert-label-flags'. | ||
| 135 | ;; | ||
| 136 | ;; * Referencing Labels | ||
| 137 | ;; To make a reference, type `C-c )' (`reftex-reference'). This | ||
| 138 | ;; shows an outline of the document with all labels of a certain | ||
| 139 | ;; type (figure, equation,...) and some label context. | ||
| 140 | ;; Selecting a label inserts a `\ref{LABEL}' macro into the | ||
| 141 | ;; original buffer. | ||
| 142 | ;; | ||
| 143 | ;; 3. Citations | ||
| 144 | ;; Typing `C-c [' (`reftex-citation') will let you specify a regular | ||
| 145 | ;; expression to search in current BibTeX database files (as | ||
| 146 | ;; specified in the `\bibliography' command) and pull out a list of | ||
| 147 | ;; matches for you to choose from. The list is _formatted_ and | ||
| 148 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see | ||
| 149 | ;; the variable `reftex-cite-format' if you want to insert different | ||
| 150 | ;; macros). | ||
| 151 | ;; | ||
| 152 | ;; 4. Index Support | ||
| 153 | ;; RefTeX helps to enter index entries. It also compiles all entries | ||
| 154 | ;; into an alphabetically sorted `*Index*' buffer which you can use | ||
| 155 | ;; to check and edit the entries. RefTeX knows about the standard | ||
| 156 | ;; index macros and can be configured to recognize any additional | ||
| 157 | ;; macros you have defined (`reftex-index-macros'). Multiple indices | ||
| 158 | ;; are supported. | ||
| 159 | ;; | ||
| 160 | ;; * Creating Index Entries | ||
| 161 | ;; To index the current selection or the word at point, type | ||
| 162 | ;; `C-c /' (`reftex-index-selection-or-word'). The default macro | ||
| 163 | ;; `reftex-index-default-macro' will be used. For a more | ||
| 164 | ;; complex entry type `C-c <' (`reftex-index'), select any of | ||
| 165 | ;; the index macros and enter the arguments with completion. | ||
| 166 | ;; | ||
| 167 | ;; * The Index Phrases File (Delayed Indexing) | ||
| 168 | ;; Type `C-c \' (`reftex-index-phrase-selection-or-word') to add | ||
| 169 | ;; the current word or selection to a special _index phrase | ||
| 170 | ;; file_. RefTeX can later search the document for occurrences | ||
| 171 | ;; of these phrases and let you interactively index the matches. | ||
| 172 | ;; | ||
| 173 | ;; * Displaying and Editing the Index | ||
| 174 | ;; To display the compiled index in a special buffer, type `C-c | ||
| 175 | ;; >' (`reftex-display-index'). From that buffer you can check | ||
| 176 | ;; and edit all entries. | ||
| 177 | ;; | ||
| 178 | ;; 5. Viewing Cross-References | ||
| 179 | ;; When point is on the KEY argument of a cross-referencing macro | ||
| 180 | ;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations) | ||
| 181 | ;; or inside a BibTeX database entry, you can press `C-c &' | ||
| 182 | ;; (`reftex-view-crossref') to display corresponding locations in the | ||
| 183 | ;; document and associated BibTeX database files. | ||
| 184 | ;; When the enclosing macro is `\cite' or `\ref' and no other message | ||
| 185 | ;; occupies the echo area, information about the citation or label | ||
| 186 | ;; will automatically be displayed in the echo area. | ||
| 187 | ;; | ||
| 188 | ;; 6. Multifile Documents | ||
| 189 | ;; Multifile Documents are fully supported. The included files must | ||
| 190 | ;; have a file variable `TeX-master' or `tex-main-file' pointing to | ||
| 191 | ;; the master file. RefTeX provides cross-referencing information | ||
| 192 | ;; from all parts of the document, and across document borders | ||
| 193 | ;; (`xr.sty'). | ||
| 194 | ;; | ||
| 195 | ;; 7. Document Parsing | ||
| 196 | ;; RefTeX needs to parse the document in order to find labels and | ||
| 197 | ;; other information. It does it automatically once and updates its | ||
| 198 | ;; list internally when `reftex-label' and `reftex-index' are used. | ||
| 199 | ;; To enforce reparsing, call any of the commands described above | ||
| 200 | ;; with a raw `C-u' prefix, or press the `r' key in the label | ||
| 201 | ;; selection buffer, the table of contents buffer, or the index | ||
| 202 | ;; buffer. | ||
| 203 | ;; | ||
| 204 | ;; 8. AUCTeX | ||
| 205 | ;; If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it | ||
| 206 | ;; (see variable `reftex-plug-into-AUCTeX'). AUCTeX contains style | ||
| 207 | ;; files which trigger appropriate settings in RefTeX, so that for | ||
| 208 | ;; many of the popular LaTeX packages no additional customizations | ||
| 209 | ;; will be necessary. | ||
| 210 | ;; | ||
| 211 | ;; 9. Useful Settings | ||
| 212 | ;; To make RefTeX faster for large documents, try these: | ||
| 213 | ;; (setq reftex-enable-partial-scans t) | ||
| 214 | ;; (setq reftex-save-parse-info t) | ||
| 215 | ;; (setq reftex-use-multiple-selection-buffers t) | ||
| 216 | ;; | ||
| 217 | ;; To integrate with AUCTeX, use | ||
| 218 | ;; (setq reftex-plug-into-AUCTeX t) | ||
| 219 | ;; | ||
| 220 | ;; To make your own LaTeX macro definitions known to RefTeX, | ||
| 221 | ;; customize the variables | ||
| 222 | ;; `reftex-label-alist' (for label macros/environments) | ||
| 223 | ;; `reftex-section-levels' (for sectioning commands) | ||
| 224 | ;; `reftex-cite-format' (for `\cite'-like macros) | ||
| 225 | ;; `reftex-index-macros' (for `\index'-like macros) | ||
| 226 | ;; `reftex-index-default-macro' (to set the default macro) | ||
| 227 | ;; If you have a large number of macros defined, you may want to write | ||
| 228 | ;; an AUCTeX style file to support them with both AUCTeX and RefTeX. | ||
| 229 | ;; | ||
| 230 | ;; 10. Where Next? | ||
| 231 | ;; Go ahead and use RefTeX. Use its menus until you have picked up | ||
| 232 | ;; the key bindings. For an overview of what you can do in each of | ||
| 233 | ;; the different special buffers, press `?'. Read the manual if you | ||
| 234 | ;; get stuck, of if you are curious what else might be available. | ||
| 235 | ;; The first part of the manual explains in a tutorial way how to use | ||
| 236 | ;; and customize RefTeX. The second part is a command and variable | ||
| 237 | ;; reference. | ||
| 238 | ;; | ||
| 239 | ;;--------------------------------------------------------------------------- | ||
| 240 | ;; | ||
| 241 | ;; AUTHOR | ||
| 242 | ;; ====== | ||
| 243 | ;; | ||
| 244 | ;; Carsten Dominik <dominik@science.uva.nl> | ||
| 245 | ;; | ||
| 246 | ;; with contributions from Stephen Eglen | ||
| 247 | ;; | 40 | ;; |
| 248 | ;; RefTeX is bundled with Emacs and available as a plug-in package for | 41 | ;; RefTeX is bundled with Emacs and available as a plug-in package for |
| 249 | ;; XEmacs 21.x. If you need to install it yourself, you can find a | 42 | ;; XEmacs 21.x. If you need to install it yourself, you can find a |
| 250 | ;; distribution at | 43 | ;; distribution at |
| 251 | ;; | 44 | ;; |
| 252 | ;; http://zon.astro.uva.nl/~dominik/Tools/ | 45 | ;; http://www.gnu.org/software/auctex/reftex.html |
| 253 | ;; | 46 | ;; |
| 254 | ;; THANKS TO: | 47 | ;; RefTeX was written by Carsten Dominik <dominik@science.uva.nl> with |
| 255 | ;; --------- | 48 | ;; contributions from Stephen Eglen. It is currently maintained by |
| 256 | ;; Thanks to the people on the Net who have used RefTeX and helped | 49 | ;; the AUCTeX project. |
| 257 | ;; developing it with their reports. In particular thanks to | 50 | |
| 258 | ;; | ||
| 259 | ;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, | ||
| 260 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann, | ||
| 261 | ;; Frank Harrell, Adrian Lanz, Rory Molinari, Stefan Monnier, | ||
| 262 | ;; Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, Robin Socha, | ||
| 263 | ;; Richard Stanton, Allan Strand, Jan Vroonhof, Christoph Wedler, | ||
| 264 | ;; Alan Williams. | ||
| 265 | ;; | ||
| 266 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into | ||
| 267 | ;; supporting LaTeX labels and references with an editor (which was | ||
| 268 | ;; MicroEmacs at the time). | ||
| 269 | ;; | ||
| 270 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 271 | ;; | ||
| 272 | ;;;;;; | ||
| 273 | |||
| 274 | ;;; Code: | 51 | ;;; Code: |
| 275 | 52 | ||
| 276 | (eval-when-compile (require 'cl)) | 53 | (eval-when-compile (require 'cl)) |
| @@ -289,52 +66,13 @@ | |||
| 289 | (set symbol value))) | 66 | (set symbol value))) |
| 290 | 67 | ||
| 291 | 68 | ||
| 292 | ;;; ========================================================================= | 69 | ;; Configuration variables |
| 293 | ;;; | ||
| 294 | ;;; Configuration variables | ||
| 295 | |||
| 296 | (require 'reftex-vars) | 70 | (require 'reftex-vars) |
| 297 | 71 | ||
| 298 | 72 | ||
| 299 | ;;; ========================================================================= | 73 | ;;; Autoloads |
| 300 | ;;; | ||
| 301 | ;;; Define the formal stuff for a minor mode named RefTeX. | ||
| 302 | ;;; | ||
| 303 | |||
| 304 | (defconst reftex-version "RefTeX version 4.31" | ||
| 305 | "Version string for RefTeX.") | ||
| 306 | |||
| 307 | (defvar reftex-mode-map (make-sparse-keymap) | ||
| 308 | "Keymap for RefTeX mode.") | ||
| 309 | |||
| 310 | (defvar reftex-mode-menu nil) | ||
| 311 | (defvar reftex-syntax-table nil) | ||
| 312 | (defvar reftex-syntax-table-for-bib nil) | ||
| 313 | |||
| 314 | (unless reftex-syntax-table | ||
| 315 | (setq reftex-syntax-table (copy-syntax-table)) | ||
| 316 | (modify-syntax-entry ?\( "." reftex-syntax-table) | ||
| 317 | (modify-syntax-entry ?\) "." reftex-syntax-table)) | ||
| 318 | |||
| 319 | (unless reftex-syntax-table-for-bib | ||
| 320 | (setq reftex-syntax-table-for-bib | ||
| 321 | (copy-syntax-table reftex-syntax-table)) | ||
| 322 | (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) | ||
| 323 | (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) | ||
| 324 | (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) | ||
| 325 | (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)) | ||
| 326 | |||
| 327 | ;; The following definitions are out of place, but I need them here | ||
| 328 | ;; to make the compilation of reftex-mode not complain. | ||
| 329 | (defvar reftex-auto-view-crossref-timer nil | ||
| 330 | "The timer used for auto-view-crossref.") | ||
| 331 | (defvar reftex-toc-auto-recenter-timer nil | ||
| 332 | "The idle timer used to recenter the toc window.") | ||
| 333 | |||
| 334 | ;;; ========================================================================= | ||
| 335 | ;;; | ||
| 336 | ;;; Parser functions | ||
| 337 | 74 | ||
| 75 | ;; Parser functions | ||
| 338 | (autoload 'reftex-parse-one "reftex-parse" | 76 | (autoload 'reftex-parse-one "reftex-parse" |
| 339 | "Re-parse this file." t) | 77 | "Re-parse this file." t) |
| 340 | (autoload 'reftex-parse-all "reftex-parse" | 78 | (autoload 'reftex-parse-all "reftex-parse" |
| @@ -358,11 +96,7 @@ | |||
| 358 | (autoload 'reftex-ensure-index-support "reftex-parse") | 96 | (autoload 'reftex-ensure-index-support "reftex-parse") |
| 359 | (autoload 'reftex-everything-regexp "reftex-parse") | 97 | (autoload 'reftex-everything-regexp "reftex-parse") |
| 360 | 98 | ||
| 361 | 99 | ;; Labels and References | |
| 362 | ;;; ========================================================================= | ||
| 363 | ;;; | ||
| 364 | ;;; Labels and References | ||
| 365 | |||
| 366 | (autoload 'reftex-label-location "reftex-ref") | 100 | (autoload 'reftex-label-location "reftex-ref") |
| 367 | (autoload 'reftex-label-info-update "reftex-ref") | 101 | (autoload 'reftex-label-info-update "reftex-ref") |
| 368 | (autoload 'reftex-label-info "reftex-ref") | 102 | (autoload 'reftex-label-info "reftex-ref") |
| @@ -381,10 +115,7 @@ | |||
| 381 | (autoload 'reftex-goto-label "reftex-ref" | 115 | (autoload 'reftex-goto-label "reftex-ref" |
| 382 | "Prompt for label name and go to that location." t) | 116 | "Prompt for label name and go to that location." t) |
| 383 | 117 | ||
| 384 | ;;; ========================================================================= | 118 | ;; Table of contents |
| 385 | ;;; | ||
| 386 | ;;; Table of contents | ||
| 387 | |||
| 388 | (autoload 'reftex-toc "reftex-toc" | 119 | (autoload 'reftex-toc "reftex-toc" |
| 389 | "Show the table of contents for the current document." t) | 120 | "Show the table of contents for the current document." t) |
| 390 | (autoload 'reftex-toc-recenter "reftex-toc" | 121 | (autoload 'reftex-toc-recenter "reftex-toc" |
| @@ -392,10 +123,7 @@ | |||
| 392 | (autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" | 123 | (autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" |
| 393 | "Toggle automatic recentering of TOC window." t) | 124 | "Toggle automatic recentering of TOC window." t) |
| 394 | 125 | ||
| 395 | ;;; ========================================================================= | 126 | ;; BibTeX citations. |
| 396 | ;;; | ||
| 397 | ;;; BibTeX citations. | ||
| 398 | |||
| 399 | (autoload 'reftex-citep "reftex-cite") | 127 | (autoload 'reftex-citep "reftex-cite") |
| 400 | (autoload 'reftex-citet "reftex-cite") | 128 | (autoload 'reftex-citet "reftex-cite") |
| 401 | (autoload 'reftex-make-cite-echo-string "reftex-cite") | 129 | (autoload 'reftex-make-cite-echo-string "reftex-cite") |
| @@ -409,10 +137,7 @@ | |||
| 409 | (autoload 'reftex-bib-or-thebib "reftex-cite") | 137 | (autoload 'reftex-bib-or-thebib "reftex-cite") |
| 410 | (autoload 'reftex-create-bibtex-file "reftex-cite") | 138 | (autoload 'reftex-create-bibtex-file "reftex-cite") |
| 411 | 139 | ||
| 412 | ;;; ========================================================================= | 140 | ;; Selection |
| 413 | ;;; | ||
| 414 | ;;; Selection | ||
| 415 | |||
| 416 | (autoload 'reftex-select-label-mode "reftex-sel") | 141 | (autoload 'reftex-select-label-mode "reftex-sel") |
| 417 | (autoload 'reftex-select-bib-mode "reftex-sel") | 142 | (autoload 'reftex-select-bib-mode "reftex-sel") |
| 418 | (autoload 'reftex-find-start-point "reftex-sel") | 143 | (autoload 'reftex-find-start-point "reftex-sel") |
| @@ -420,11 +145,7 @@ | |||
| 420 | (autoload 'reftex-get-offset "reftex-sel") | 145 | (autoload 'reftex-get-offset "reftex-sel") |
| 421 | (autoload 'reftex-select-item "reftex-sel") | 146 | (autoload 'reftex-select-item "reftex-sel") |
| 422 | 147 | ||
| 423 | 148 | ;; Index support | |
| 424 | ;;; ========================================================================= | ||
| 425 | ;;; | ||
| 426 | ;;; Index support | ||
| 427 | |||
| 428 | (autoload 'reftex-index "reftex-index" | 149 | (autoload 'reftex-index "reftex-index" |
| 429 | "Query for an index macro and insert it along with its arguments." t) | 150 | "Query for an index macro and insert it along with its arguments." t) |
| 430 | (autoload 'reftex-index-selection-or-word "reftex-index" | 151 | (autoload 'reftex-index-selection-or-word "reftex-index" |
| @@ -442,11 +163,7 @@ | |||
| 442 | (autoload 'reftex-index-show-entry "reftex-index") | 163 | (autoload 'reftex-index-show-entry "reftex-index") |
| 443 | (autoload 'reftex-index-select-tag "reftex-index") | 164 | (autoload 'reftex-index-select-tag "reftex-index") |
| 444 | 165 | ||
| 445 | 166 | ;; View cross references | |
| 446 | ;;; ========================================================================= | ||
| 447 | ;;; | ||
| 448 | ;;; View cross references | ||
| 449 | |||
| 450 | (autoload 'reftex-view-crossref "reftex-dcr" | 167 | (autoload 'reftex-view-crossref "reftex-dcr" |
| 451 | "View cross reference of \\ref or \\cite macro at point." t) | 168 | "View cross reference of \\ref or \\cite macro at point." t) |
| 452 | (autoload 'reftex-mouse-view-crossref "reftex-dcr" | 169 | (autoload 'reftex-mouse-view-crossref "reftex-dcr" |
| @@ -455,11 +172,7 @@ | |||
| 455 | (autoload 'reftex-view-crossref-from-bibtex "reftex-dcr" | 172 | (autoload 'reftex-view-crossref-from-bibtex "reftex-dcr" |
| 456 | "View location in a LaTeX document which cites the BibTeX entry at point." t) | 173 | "View location in a LaTeX document which cites the BibTeX entry at point." t) |
| 457 | 174 | ||
| 458 | 175 | ;; Operations on entire Multifile documents | |
| 459 | ;;; ========================================================================= | ||
| 460 | ;;; | ||
| 461 | ;;; Operations on entire Multifile documents | ||
| 462 | |||
| 463 | (autoload 'reftex-create-tags-file "reftex-global" | 176 | (autoload 'reftex-create-tags-file "reftex-global" |
| 464 | "Create TAGS file by running `etags' on the current document." t) | 177 | "Create TAGS file by running `etags' on the current document." t) |
| 465 | (autoload 'reftex-grep-document "reftex-global" | 178 | (autoload 'reftex-grep-document "reftex-global" |
| @@ -477,11 +190,7 @@ | |||
| 477 | (autoload 'reftex-save-all-document-buffers "reftex-global" | 190 | (autoload 'reftex-save-all-document-buffers "reftex-global" |
| 478 | "Save all documents associated with the current document." t) | 191 | "Save all documents associated with the current document." t) |
| 479 | 192 | ||
| 480 | 193 | ;; AUCTeX Interface | |
| 481 | ;;; ========================================================================= | ||
| 482 | ;;; | ||
| 483 | ;;; AUCTeX Interface | ||
| 484 | |||
| 485 | (autoload 'reftex-arg-label "reftex-auc") | 194 | (autoload 'reftex-arg-label "reftex-auc") |
| 486 | (autoload 'reftex-arg-cite "reftex-auc") | 195 | (autoload 'reftex-arg-cite "reftex-auc") |
| 487 | (autoload 'reftex-arg-index-tag "reftex-auc") | 196 | (autoload 'reftex-arg-index-tag "reftex-auc") |
| @@ -494,6 +203,41 @@ | |||
| 494 | (autoload 'reftex-add-section-levels "reftex-auc") | 203 | (autoload 'reftex-add-section-levels "reftex-auc") |
| 495 | (autoload 'reftex-notice-new-section "reftex-auc") | 204 | (autoload 'reftex-notice-new-section "reftex-auc") |
| 496 | 205 | ||
| 206 | |||
| 207 | ;;; ========================================================================= | ||
| 208 | ;;; | ||
| 209 | ;;; Define the formal stuff for a minor mode named RefTeX. | ||
| 210 | ;;; | ||
| 211 | |||
| 212 | (defconst reftex-version emacs-version | ||
| 213 | "Version string for RefTeX.") | ||
| 214 | |||
| 215 | (defvar reftex-mode-map (make-sparse-keymap) | ||
| 216 | "Keymap for RefTeX mode.") | ||
| 217 | |||
| 218 | (defvar reftex-mode-menu nil) | ||
| 219 | (defvar reftex-syntax-table nil) | ||
| 220 | (defvar reftex-syntax-table-for-bib nil) | ||
| 221 | |||
| 222 | (unless reftex-syntax-table | ||
| 223 | (setq reftex-syntax-table (copy-syntax-table)) | ||
| 224 | (modify-syntax-entry ?\( "." reftex-syntax-table) | ||
| 225 | (modify-syntax-entry ?\) "." reftex-syntax-table)) | ||
| 226 | |||
| 227 | (unless reftex-syntax-table-for-bib | ||
| 228 | (setq reftex-syntax-table-for-bib (copy-syntax-table)) | ||
| 229 | (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) | ||
| 230 | (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) | ||
| 231 | (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) | ||
| 232 | (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)) | ||
| 233 | |||
| 234 | ;; The following definitions are out of place, but I need them here | ||
| 235 | ;; to make the compilation of reftex-mode not complain. | ||
| 236 | (defvar reftex-auto-view-crossref-timer nil | ||
| 237 | "The timer used for auto-view-crossref.") | ||
| 238 | (defvar reftex-toc-auto-recenter-timer nil | ||
| 239 | "The idle timer used to recenter the toc window.") | ||
| 240 | |||
| 497 | ;;;###autoload | 241 | ;;;###autoload |
| 498 | (defun turn-on-reftex () | 242 | (defun turn-on-reftex () |
| 499 | "Turn on RefTeX mode." | 243 | "Turn on RefTeX mode." |
| @@ -503,13 +247,7 @@ | |||
| 503 | (put 'reftex-mode :menu-tag "RefTeX Mode") | 247 | (put 'reftex-mode :menu-tag "RefTeX Mode") |
| 504 | ;;;###autoload | 248 | ;;;###autoload |
| 505 | (define-minor-mode reftex-mode | 249 | (define-minor-mode reftex-mode |
| 506 | "Toggle RefTeX mode. | 250 | "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX. |
| 507 | With a prefix argument ARG, enable RefTeX mode if ARG is | ||
| 508 | positive, and disable it otherwise. If called from Lisp, enable | ||
| 509 | the mode if ARG is omitted or nil. | ||
| 510 | |||
| 511 | RefTeX mode is a buffer-local minor mode with distinct support | ||
| 512 | for \\label, \\ref and \\cite in LaTeX. | ||
| 513 | 251 | ||
| 514 | \\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing | 252 | \\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing |
| 515 | capabilities is available with `\\[reftex-toc]'. | 253 | capabilities is available with `\\[reftex-toc]'. |
| @@ -559,8 +297,7 @@ on the menu bar. | |||
| 559 | (modify-syntax-entry ?\( "." reftex-syntax-table) | 297 | (modify-syntax-entry ?\( "." reftex-syntax-table) |
| 560 | (modify-syntax-entry ?\) "." reftex-syntax-table) | 298 | (modify-syntax-entry ?\) "." reftex-syntax-table) |
| 561 | 299 | ||
| 562 | (setq reftex-syntax-table-for-bib | 300 | (setq reftex-syntax-table-for-bib (copy-syntax-table)) |
| 563 | (copy-syntax-table reftex-syntax-table)) | ||
| 564 | (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) | 301 | (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) |
| 565 | (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) | 302 | (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) |
| 566 | (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) | 303 | (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) |
| @@ -635,16 +372,15 @@ on the menu bar. | |||
| 635 | (incf reftex-multifile-index)) | 372 | (incf reftex-multifile-index)) |
| 636 | 373 | ||
| 637 | (defun reftex-tie-multifile-symbols () | 374 | (defun reftex-tie-multifile-symbols () |
| 638 | ;; Tie the buffer-local symbols to globals connected with the master file. | 375 | "Tie the buffer-local symbols to globals connected with the master file. |
| 639 | ;; If the symbols for the current master file do not exist, they are created. | 376 | If the symbols for the current master file do not exist, they are created." |
| 640 | |||
| 641 | (let* ((master (file-truename (reftex-TeX-master-file))) | 377 | (let* ((master (file-truename (reftex-TeX-master-file))) |
| 642 | (index (assoc master reftex-master-index-list)) | 378 | (index (assoc master reftex-master-index-list)) |
| 643 | (symlist reftex-multifile-symbols) | 379 | (symlist reftex-multifile-symbols) |
| 644 | symbol symname newflag) | 380 | symbol symname newflag) |
| 645 | ;; Find the correct index. | 381 | ;; Find the correct index. |
| 646 | (if index | 382 | (if index |
| 647 | ;; symbols do exist | 383 | ;; Symbols do exist |
| 648 | (setq index (cdr index)) | 384 | (setq index (cdr index)) |
| 649 | ;; Get a new index and add info to the alist. | 385 | ;; Get a new index and add info to the alist. |
| 650 | (setq index (reftex-next-multifile-index) | 386 | (setq index (reftex-next-multifile-index) |
| @@ -661,13 +397,15 @@ on the menu bar. | |||
| 661 | ;; Initialize if new symbols. | 397 | ;; Initialize if new symbols. |
| 662 | (when newflag | 398 | (when newflag |
| 663 | (set (symbol-value symbol) nil) | 399 | (set (symbol-value symbol) nil) |
| 664 | (put (symbol-value symbol) 'reftex-index-macros-style '(default)))) | 400 | (put (symbol-value symbol) 'reftex-index-macros-style '(default)) |
| 401 | (put (symbol-value symbol) 'reftex-ref-style-list | ||
| 402 | reftex-ref-style-default-list))) | ||
| 665 | 403 | ||
| 666 | ;; Return t if the symbols did already exist, nil when we've made them. | 404 | ;; Return t if the symbols did already exist, nil when we've made them. |
| 667 | (not newflag))) | 405 | (not newflag))) |
| 668 | 406 | ||
| 669 | (defun reftex-untie-multifile-symbols () | 407 | (defun reftex-untie-multifile-symbols () |
| 670 | ;; Remove ties from multifile symbols, so that next use makes new ones. | 408 | "Remove ties from multifile symbols, so that next use makes new ones." |
| 671 | (let ((symlist reftex-multifile-symbols) | 409 | (let ((symlist reftex-multifile-symbols) |
| 672 | (symbol nil)) | 410 | (symbol nil)) |
| 673 | (while symlist | 411 | (while symlist |
| @@ -761,7 +499,7 @@ for details. | |||
| 761 | This function makes it possible to support RefTeX from AUCTeX style files. | 499 | This function makes it possible to support RefTeX from AUCTeX style files. |
| 762 | The entries in ENTRY-LIST will be processed after the user settings in | 500 | The entries in ENTRY-LIST will be processed after the user settings in |
| 763 | `reftex-index-entries', and before the defaults. Any changes made to | 501 | `reftex-index-entries', and before the defaults. Any changes made to |
| 764 | `reftex-label-alist-style' will raise a flag to the effect that | 502 | `reftex-index-macros-style' will raise a flag to the effect that |
| 765 | the label information is recompiled on next use." | 503 | the label information is recompiled on next use." |
| 766 | (unless reftex-docstruct-symbol | 504 | (unless reftex-docstruct-symbol |
| 767 | (reftex-tie-multifile-symbols)) | 505 | (reftex-tie-multifile-symbols)) |
| @@ -783,6 +521,52 @@ the label information is recompiled on next use." | |||
| 783 | (when changed | 521 | (when changed |
| 784 | (put reftex-docstruct-symbol 'reftex-index-macros-style list))))) | 522 | (put reftex-docstruct-symbol 'reftex-index-macros-style list))))) |
| 785 | 523 | ||
| 524 | (defun reftex-ref-style-activate (style) | ||
| 525 | "Activate the referencing style STYLE." | ||
| 526 | (reftex-ref-style-toggle style 'activate)) | ||
| 527 | |||
| 528 | (defun reftex-ref-style-toggle (style &optional action) | ||
| 529 | "Activate or deactivate the referencing style STYLE. | ||
| 530 | With the optional argument ACTION a certain action can be forced. | ||
| 531 | The symbol `activate' will activate the style and `deactivate' | ||
| 532 | will deactivate it." | ||
| 533 | (unless reftex-docstruct-symbol | ||
| 534 | (reftex-tie-multifile-symbols)) | ||
| 535 | (when (and reftex-docstruct-symbol | ||
| 536 | (symbolp reftex-docstruct-symbol)) | ||
| 537 | (let ((list (get reftex-docstruct-symbol 'reftex-ref-style-list)) | ||
| 538 | changed) | ||
| 539 | (cond ((eq action 'activate) | ||
| 540 | (unless (member style list) | ||
| 541 | (setq reftex-tables-dirty t | ||
| 542 | changed t) | ||
| 543 | (add-to-list 'list style t))) | ||
| 544 | ((eq action 'deactivate) | ||
| 545 | (when (member style list) | ||
| 546 | (setq reftex-tables-dirty t | ||
| 547 | changed t) | ||
| 548 | (delete style list))) | ||
| 549 | (t | ||
| 550 | (if (member style list) | ||
| 551 | (delete style list) | ||
| 552 | (add-to-list 'list style t)) | ||
| 553 | (setq reftex-tables-dirty t | ||
| 554 | changed t))) | ||
| 555 | (when changed | ||
| 556 | (put reftex-docstruct-symbol 'reftex-ref-style-list list))))) | ||
| 557 | |||
| 558 | (defun reftex-ref-style-list () | ||
| 559 | "Return the list of referencing styles to be active at the moment." | ||
| 560 | ;; Initialize the value of `reftex-ref-style-list' and tie it to the | ||
| 561 | ;; docstruct symbol if necessary. | ||
| 562 | (unless reftex-docstruct-symbol | ||
| 563 | (reftex-tie-multifile-symbols)) | ||
| 564 | (if (and reftex-docstruct-symbol | ||
| 565 | (symbolp reftex-docstruct-symbol) | ||
| 566 | (get reftex-docstruct-symbol 'reftex-ref-style-list)) | ||
| 567 | (get reftex-docstruct-symbol 'reftex-ref-style-list) | ||
| 568 | reftex-ref-style-default-list)) | ||
| 569 | |||
| 786 | ;;; ========================================================================= | 570 | ;;; ========================================================================= |
| 787 | ;;; | 571 | ;;; |
| 788 | ;;; Functions to compile the tables, reset the mode etc. | 572 | ;;; Functions to compile the tables, reset the mode etc. |
| @@ -1282,8 +1066,8 @@ This enforces rescanning the buffer on next use." | |||
| 1282 | ;; Calculate the regular expressions | 1066 | ;; Calculate the regular expressions |
| 1283 | (let* ( | 1067 | (let* ( |
| 1284 | ; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*") | 1068 | ; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*") |
| 1285 | (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because | 1069 | (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because |
| 1286 | ;;; because match number are hard coded | 1070 | ; match numbers are hard coded |
| 1287 | (label-re (concat "\\(?:" | 1071 | (label-re (concat "\\(?:" |
| 1288 | ;; Normal \label{...} | 1072 | ;; Normal \label{...} |
| 1289 | "\\\\label{\\([^}]*\\)}" | 1073 | "\\\\label{\\([^}]*\\)}" |
| @@ -1299,10 +1083,16 @@ This enforces rescanning the buffer on next use." | |||
| 1299 | reftex-include-file-commands "\\|") | 1083 | reftex-include-file-commands "\\|") |
| 1300 | "\\)[{ \t]+\\([^} \t\n\r]+\\)")) | 1084 | "\\)[{ \t]+\\([^} \t\n\r]+\\)")) |
| 1301 | (section-re | 1085 | (section-re |
| 1086 | ;; Including `\' as a character to be matched at the end | ||
| 1087 | ;; of the regexp will allow stuff like | ||
| 1088 | ;; \begin{foo}\label{bar} to be matched. This will make | ||
| 1089 | ;; the parser to advance one char too much. Therefore | ||
| 1090 | ;; `reftex-parse-from-file' will step one char back if a | ||
| 1091 | ;; section is found. | ||
| 1302 | (concat wbol "\\\\\\(" | 1092 | (concat wbol "\\\\\\(" |
| 1303 | (mapconcat (lambda (x) (regexp-quote (car x))) | 1093 | (mapconcat (lambda (x) (regexp-quote (car x))) |
| 1304 | reftex-section-levels-all "\\|") | 1094 | reftex-section-levels-all "\\|") |
| 1305 | "\\)\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n]")) | 1095 | "\\)\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n\\]")) |
| 1306 | (appendix-re (concat wbol "\\(\\\\appendix\\)")) | 1096 | (appendix-re (concat wbol "\\(\\\\appendix\\)")) |
| 1307 | (macro-re | 1097 | (macro-re |
| 1308 | (if macros-with-labels | 1098 | (if macros-with-labels |
| @@ -1780,9 +1570,18 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1780 | "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]")))) | 1570 | "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]")))) |
| 1781 | 1571 | ||
| 1782 | (defun reftex-in-comment () | 1572 | (defun reftex-in-comment () |
| 1573 | "Return non-nil if point is in a comment." | ||
| 1783 | (save-excursion | 1574 | (save-excursion |
| 1784 | (skip-chars-backward "^%\n\r") | 1575 | (save-match-data |
| 1785 | (eq (preceding-char) ?%))) | 1576 | (let ((pos (point))) |
| 1577 | (beginning-of-line) | ||
| 1578 | (re-search-forward | ||
| 1579 | (or comment-start-skip | ||
| 1580 | ;; The parser may open files in fundamental mode if | ||
| 1581 | ;; `reftex-initialize-temporary-buffers' is nil, so here | ||
| 1582 | ;; is a default suitable for plain TeX and LaTeX. | ||
| 1583 | "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+[ \t]*\\)") | ||
| 1584 | pos t))))) | ||
| 1786 | 1585 | ||
| 1787 | (defun reftex-no-props (string) | 1586 | (defun reftex-no-props (string) |
| 1788 | ;; Return STRING with all text properties removed | 1587 | ;; Return STRING with all text properties removed |
| @@ -1996,6 +1795,7 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1996 | (condition-case nil (scroll-down) (error nil)) | 1795 | (condition-case nil (scroll-down) (error nil)) |
| 1997 | (message "%s" prompt)) | 1796 | (message "%s" prompt)) |
| 1998 | (t (message "") | 1797 | (t (message "") |
| 1798 | (reftex-kill-buffer "*RefTeX Select*") | ||
| 1999 | (throw 'exit char))) | 1799 | (throw 'exit char))) |
| 2000 | (setq char (read-char-exclusive))))))) | 1800 | (setq char (read-char-exclusive))))))) |
| 2001 | 1801 | ||
| @@ -2123,25 +1923,95 @@ When DIE is non-nil, throw an error if file not found." | |||
| 2123 | (setq list (cdr list))) | 1923 | (setq list (cdr list))) |
| 2124 | (nreverse rtn))) | 1924 | (nreverse rtn))) |
| 2125 | 1925 | ||
| 2126 | (defun reftex-uniquify (list) | 1926 | (defun reftex-uniquify (list &optional sort) |
| 2127 | ;; Return a list of all elements in LIST, but each only once, keeping order | 1927 | ;; Return a list of all strings in LIST, but each only once, keeping order |
| 2128 | (let (new elm) | 1928 | ;; unless SORT is set (faster!). |
| 2129 | (while list | 1929 | (setq list (copy-sequence list)) |
| 2130 | (setq elm (pop list)) | 1930 | (if sort |
| 2131 | (unless (member elm new) | 1931 | (progn |
| 2132 | (push elm new))) | 1932 | (setq list (sort list 'string<)) |
| 2133 | (nreverse new))) | 1933 | (let ((p list)) |
| 2134 | 1934 | (while (cdr p) | |
| 2135 | (defun reftex-uniquify-by-car (alist &optional keep-list) | 1935 | (if (string= (car p) (car (cdr p))) |
| 1936 | (setcdr p (cdr (cdr p))) | ||
| 1937 | (setq p (cdr p))))) | ||
| 1938 | list) | ||
| 1939 | (let ((p list) lst elt) | ||
| 1940 | ;; push all sublists into lst in reverse(!) order | ||
| 1941 | (while p | ||
| 1942 | (push p lst) | ||
| 1943 | (setq p (cdr p))) | ||
| 1944 | ;; sort all sublists | ||
| 1945 | (setq lst (sort lst (lambda (x1 x2) (string< (car x1) (car x2))))) | ||
| 1946 | (while (cdr lst) | ||
| 1947 | (setq elt (car (car lst))) | ||
| 1948 | ;; for equal elements in the sorted sublist, replace the | ||
| 1949 | ;; last(!) original list member with nil | ||
| 1950 | (when (string= elt (car (cadr lst))) | ||
| 1951 | (setcar (pop lst) nil) | ||
| 1952 | (while (and (cdr lst) (string= elt (car (cadr lst)))) | ||
| 1953 | (setcar (pop lst) nil))) | ||
| 1954 | (pop lst))) | ||
| 1955 | ;; weed out all nils and return. | ||
| 1956 | (delq nil list))) | ||
| 1957 | |||
| 1958 | (defun reftex-uniquify-by-car (alist &optional keep-list sort) | ||
| 2136 | ;; Return a list of all elements in ALIST, but each car only once. | 1959 | ;; Return a list of all elements in ALIST, but each car only once. |
| 2137 | ;; Elements of KEEP-LIST are not removed even if duplicate. | 1960 | ;; Elements of KEEP-LIST are not removed even if duplicate. |
| 2138 | (let (new elm) | 1961 | ;; The order is kept unless SORT is set (faster!). |
| 2139 | (while alist | 1962 | (setq keep-list (sort (copy-sequence keep-list) #'string<) |
| 2140 | (setq elm (pop alist)) | 1963 | alist (copy-sequence alist)) |
| 2141 | (if (or (member (car elm) keep-list) | 1964 | (if sort |
| 2142 | (not (assoc (car elm) new))) | 1965 | (let (lst elt) |
| 2143 | (push elm new))) | 1966 | (setq alist (sort alist (lambda(a b) (string< (car a) (car b))))) |
| 2144 | (nreverse new))) | 1967 | (setq lst alist) |
| 1968 | (while (cdr lst) | ||
| 1969 | (setq elt (car (car lst))) | ||
| 1970 | (when (string= elt (car (cadr lst))) | ||
| 1971 | (while (and keep-list (string< (car keep-list) elt)) | ||
| 1972 | (pop keep-list)) | ||
| 1973 | (if (and keep-list (string= elt (car keep-list))) | ||
| 1974 | (progn | ||
| 1975 | (pop lst) | ||
| 1976 | (while (and (cdr lst) | ||
| 1977 | (string= elt (car (cadr lst)))) | ||
| 1978 | (pop lst))) | ||
| 1979 | (setcdr lst (cdr (cdr lst))) | ||
| 1980 | (while (and (cdr lst) | ||
| 1981 | (string= elt (car (cadr lst)))) | ||
| 1982 | (setcdr lst (cdr (cdr lst)))))) | ||
| 1983 | (pop lst)) | ||
| 1984 | alist) | ||
| 1985 | (let ((p alist) lst elt) | ||
| 1986 | (while p | ||
| 1987 | (push p lst) | ||
| 1988 | (setq p (cdr p))) | ||
| 1989 | (setq lst (sort lst (lambda(a b) (string< (car (car a)) | ||
| 1990 | (car (car b)))))) | ||
| 1991 | (while (cdr lst) | ||
| 1992 | (setq elt (car (car (car lst)))) | ||
| 1993 | (when (string= elt (car (car (cadr lst)))) | ||
| 1994 | (while (and keep-list (string< (car keep-list) elt)) | ||
| 1995 | (pop keep-list)) | ||
| 1996 | (if (and keep-list (string= elt (car keep-list))) | ||
| 1997 | (progn | ||
| 1998 | (pop lst) | ||
| 1999 | (while (and (cdr lst) | ||
| 2000 | (string= elt (car (car (cadr lst))))) | ||
| 2001 | (pop lst))) | ||
| 2002 | (setcar (pop lst) nil) | ||
| 2003 | (while (and (cdr lst) | ||
| 2004 | (string= elt (car (car (cadr lst))))) | ||
| 2005 | (setcar (pop lst) nil)))) | ||
| 2006 | (pop lst))) | ||
| 2007 | (delq nil alist))) | ||
| 2008 | |||
| 2009 | (defun reftex-remove-if (predicate list) | ||
| 2010 | "Nondestructively remove all items from LIST which satisfy PREDICATE." | ||
| 2011 | (let (result) | ||
| 2012 | (dolist (elt list (nreverse result)) | ||
| 2013 | (unless (funcall predicate elt) | ||
| 2014 | (push elt result))))) | ||
| 2145 | 2015 | ||
| 2146 | (defun reftex-abbreviate-title (string) | 2016 | (defun reftex-abbreviate-title (string) |
| 2147 | (reftex-convert-string string "[-~ \t\n\r,;]" nil t t | 2017 | (reftex-convert-string string "[-~ \t\n\r,;]" nil t t |
| @@ -2243,6 +2113,7 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2243 | ((= (length text) 0) (make-string 1 ?\ )) | 2113 | ((= (length text) 0) (make-string 1 ?\ )) |
| 2244 | (t text))) | 2114 | (t text))) |
| 2245 | 2115 | ||
| 2116 | |||
| 2246 | ;;; ========================================================================= | 2117 | ;;; ========================================================================= |
| 2247 | ;;; | 2118 | ;;; |
| 2248 | ;;; Fontification and Highlighting | 2119 | ;;; Fontification and Highlighting |
| @@ -2390,28 +2261,20 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2390 | "bibtex" | 2261 | "bibtex" |
| 2391 | '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex)) | 2262 | '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex)) |
| 2392 | 2263 | ||
| 2393 | ;; If the user requests so, she can have a few more bindings: | ||
| 2394 | ;; For most of these commands there are already bindings in place. | 2264 | ;; For most of these commands there are already bindings in place. |
| 2395 | ;; Setting `reftex-extra-bindings' really is only there to spare users | 2265 | ;; Setting `reftex-extra-bindings' really is only there to spare users |
| 2396 | ;; the hassle of defining bindings in the user space themselves. This | 2266 | ;; the hassle of defining bindings in the user space themselves. This |
| 2397 | ;; is why they violate the key binding recommendations. | 2267 | ;; is why they violate the key binding recommendations. |
| 2398 | (defvar reftex-extra-bindings-map | ||
| 2399 | (let ((map (make-sparse-keymap))) | ||
| 2400 | (define-key map "t" 'reftex-toc) | ||
| 2401 | (define-key map "l" 'reftex-label) | ||
| 2402 | (define-key map "r" 'reftex-reference) | ||
| 2403 | (define-key map "c" 'reftex-citation) | ||
| 2404 | (define-key map "v" 'reftex-view-crossref) | ||
| 2405 | (define-key map "g" 'reftex-grep-document) | ||
| 2406 | (define-key map "s" 'reftex-search-document) | ||
| 2407 | map) | ||
| 2408 | "Reftex extra bindings map") | ||
| 2409 | |||
| 2410 | (when reftex-extra-bindings | 2268 | (when reftex-extra-bindings |
| 2411 | (define-key reftex-mode-map | 2269 | (loop for x in |
| 2412 | reftex-extra-bindings-prefix | 2270 | '(("\C-ct" . reftex-toc) |
| 2413 | reftex-extra-bindings-map)) | 2271 | ("\C-cl" . reftex-label) |
| 2414 | 2272 | ("\C-cr" . reftex-reference) | |
| 2273 | ("\C-cc" . reftex-citation) | ||
| 2274 | ("\C-cv" . reftex-view-crossref) | ||
| 2275 | ("\C-cg" . reftex-grep-document) | ||
| 2276 | ("\C-cs" . reftex-search-document)) | ||
| 2277 | do (define-key reftex-mode-map (car x) (cdr x)))) | ||
| 2415 | 2278 | ||
| 2416 | ;;; ========================================================================= | 2279 | ;;; ========================================================================= |
| 2417 | ;;; | 2280 | ;;; |
| @@ -2488,21 +2351,22 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2488 | :style radio :selected (eq reftex-auto-view-crossref 'window)] | 2351 | :style radio :selected (eq reftex-auto-view-crossref 'window)] |
| 2489 | "--" | 2352 | "--" |
| 2490 | "MISC" | 2353 | "MISC" |
| 2491 | ["AUC TeX Interface" reftex-toggle-plug-into-AUCTeX | 2354 | ["AUCTeX Interface" reftex-toggle-plug-into-AUCTeX |
| 2492 | :style toggle :selected reftex-plug-into-AUCTeX] | 2355 | :style toggle :selected reftex-plug-into-AUCTeX] |
| 2493 | ["isearch whole document" reftex-isearch-minor-mode | 2356 | ["isearch whole document" reftex-isearch-minor-mode |
| 2494 | :style toggle :selected reftex-isearch-minor-mode]) | 2357 | :style toggle :selected reftex-isearch-minor-mode]) |
| 2495 | ("Reference Style" | 2358 | ("Reference Style" |
| 2496 | ["Default" (setq reftex-vref-is-default nil | 2359 | ,@(let (list item) |
| 2497 | reftex-fref-is-default nil) | 2360 | (dolist (elt reftex-ref-style-alist) |
| 2498 | :style radio :selected (not (or reftex-vref-is-default | 2361 | (setq elt (car elt) |
| 2499 | reftex-fref-is-default))] | 2362 | item (vector |
| 2500 | ["Varioref" (setq reftex-vref-is-default t | 2363 | elt |
| 2501 | reftex-fref-is-default nil) | 2364 | `(reftex-ref-style-toggle ,elt) |
| 2502 | :style radio :selected reftex-vref-is-default] | 2365 | :style 'toggle |
| 2503 | ["Fancyref" (setq reftex-fref-is-default t | 2366 | :selected `(member ,elt (reftex-ref-style-list)))) |
| 2504 | reftex-vref-is-default nil) | 2367 | (unless (member item list) |
| 2505 | :style radio :selected reftex-fref-is-default]) | 2368 | (add-to-list 'list item t))) |
| 2369 | list)) | ||
| 2506 | ("Citation Style" | 2370 | ("Citation Style" |
| 2507 | ,@(mapcar | 2371 | ,@(mapcar |
| 2508 | (lambda (x) | 2372 | (lambda (x) |
| @@ -2568,6 +2432,9 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2568 | (message "\"Ref\"-menu now contains full customization menu")) | 2432 | (message "\"Ref\"-menu now contains full customization menu")) |
| 2569 | (error "Cannot expand menu (outdated version of cus-edit.el)"))) | 2433 | (error "Cannot expand menu (outdated version of cus-edit.el)"))) |
| 2570 | 2434 | ||
| 2435 | |||
| 2436 | ;;; Misc | ||
| 2437 | |||
| 2571 | (defun reftex-show-commentary () | 2438 | (defun reftex-show-commentary () |
| 2572 | "Use the finder to view the file documentation from `reftex.el'." | 2439 | "Use the finder to view the file documentation from `reftex.el'." |
| 2573 | (interactive) | 2440 | (interactive) |
| @@ -2579,6 +2446,36 @@ With optional NODE, go directly to that node." | |||
| 2579 | (interactive) | 2446 | (interactive) |
| 2580 | (info (format "(reftex)%s" (or node "")))) | 2447 | (info (format "(reftex)%s" (or node "")))) |
| 2581 | 2448 | ||
| 2449 | (defun reftex-report-bug () | ||
| 2450 | "Report a bug in RefTeX. | ||
| 2451 | |||
| 2452 | Don't hesitate to report any problems or inaccurate documentation. | ||
| 2453 | |||
| 2454 | If you don't have setup sending mail from (X)Emacs, please copy the | ||
| 2455 | output buffer into your mail program, as it gives us important | ||
| 2456 | information about your RefTeX version and configuration." | ||
| 2457 | (interactive) | ||
| 2458 | (require 'reporter) | ||
| 2459 | (let ((reporter-prompt-for-summary-p "Bug report subject: ")) | ||
| 2460 | (reporter-submit-bug-report | ||
| 2461 | "bug-auctex@gnu.org" | ||
| 2462 | reftex-version | ||
| 2463 | (list 'window-system | ||
| 2464 | 'reftex-plug-into-AUCTeX) | ||
| 2465 | nil nil | ||
| 2466 | "Remember to cover the basics, that is, what you expected to happen and | ||
| 2467 | what in fact did happen. | ||
| 2468 | |||
| 2469 | Check if the bug is reproducable with an up-to-date version of | ||
| 2470 | RefTeX available from http://www.gnu.org/software/auctex/. | ||
| 2471 | |||
| 2472 | If the bug is triggered by a specific \(La\)TeX file, you should try | ||
| 2473 | to produce a minimal sample file showing the problem and include it | ||
| 2474 | in your report. | ||
| 2475 | |||
| 2476 | Your bug report will be posted to the AUCTeX bug reporting list. | ||
| 2477 | ------------------------------------------------------------------------"))) | ||
| 2478 | |||
| 2582 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ | 2479 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ |
| 2583 | 2480 | ||
| 2584 | (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook) | 2481 | (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook) |
| @@ -2594,6 +2491,4 @@ With optional NODE, go directly to that node." | |||
| 2594 | (setq reftex-tables-dirty t) ; in case this file is evaluated by hand | 2491 | (setq reftex-tables-dirty t) ; in case this file is evaluated by hand |
| 2595 | (provide 'reftex) | 2492 | (provide 'reftex) |
| 2596 | 2493 | ||
| 2597 | ;;;============================================================================ | ||
| 2598 | |||
| 2599 | ;;; reftex.el ends here | 2494 | ;;; reftex.el ends here |