diff options
| author | Carsten Dominik | 1999-12-15 17:02:38 +0000 |
|---|---|---|
| committer | Carsten Dominik | 1999-12-15 17:02:38 +0000 |
| commit | 7c4d13cca61958bc3387b200450779cd50fdda11 (patch) | |
| tree | 430544f1c955f8ecc64f3cf9e6d155579e6fbdda | |
| parent | cfad01b4c177361ecacff4f7ffb28154985e7483 (diff) | |
| download | emacs-7c4d13cca61958bc3387b200450779cd50fdda11.tar.gz emacs-7c4d13cca61958bc3387b200450779cd50fdda11.zip | |
* reftex.el (reftex-compile-variables): respect new structure of
`reftex-index-macro'
(reftex-compile-variables): Use the changed structure of
`reftex-label-alist'.
* reftex-vars.el (reftex-index-math-format,
(reftex-toc-max-level): New option.
reftex-index-phrases-search-whole-words,
reftex-index-phrases-case-fold-search,
reftex-index-phrases-skip-indexed-matches,
reftex-index-phrases-wrap-long-lines,
reftex-index-phrases-sort-prefers-entry,
reftex-index-phrases-sort-in-blocks): New options.
(reftex-index-macros): Option structure changed.
(reftex-index-macros-builtin): Added `repeat' item to each entry.
(reftex-label-alist): Additional item in each entry to specify if
the environment should be listed in the TOC.
(eval-when-compile (require 'cl)) added.
* reftex-index.el (reftex-index-selection-or-word): No longer
deals with "repeat".
(reftex-index): "repeat property in `reftex-index-macro-alist' is
now used.
(reftex-index-phrases-comment-regexp,
reftex-index-phrases-macrodef-regexp,
reftex-index-phrases-phrase-regexp1,
reftex-index-phrases-phrase-regexp2,
reftex-index-phrases-phrase-regexp12, reftex-index-phrases-help):
New constants.
(reftex-index-phrases-macro-data, reftex-index-phrases-files,
reftex-index-phrases-font-lock-keywords,
reftex-index-phrases-font-lock-defaults, reftex-index-phrases-map,
reftex-index-phrases-restrict-file): New variables.
(reftex-index-phrase-selection-or-word,
reftex-index-visit-phrases-buffer,
reftex-index-initialize-phrases-buffer,
reftex-index-phrases-save-and-return, reftex-index-phrases-mode,
reftex-index-next-phrase, reftex-index-this-phrase,
reftex-index-all-phrases, reftex-index-region-phrases,
reftex-index-phrases-parse-header,
reftex-index-phrases-toggle-restricted, reftex-index-new-phrase,
reftex-index-find-next-conflict-phrase, reftex-index-phrases-info,
reftex-index-phrases-set-macro-key, reftex-index-sort-phrases,
reftex-compare-phrase-lines, reftex-index-make-phrase-regexp,
reftex-index-simplify-phrase, reftex-index-phrases-find-dup-re,
reftex-index-make-replace-string,
reftex-query-index-phrase-globally, reftex-query-index-phrase,
reftex-index-phrase-match-is-indexed,
reftex-index-phrases-fixup-line,
reftex-index-phrases-replace-space,
reftex-index-select-phrases-macro): New functions.
(reftex-index-globalize, reftex-index-globally): functions removed
(eval-when-compile (require 'cl)) added.
* reftex-toc.el (reftex-toc-mode): Create new indicator for max
level.
(reftex-toc-max-level-indicator): New variable.
(reftex-toc-max-level): New command.
(reftex-toc-map): New keybinding `t'.
(reftex-toc-help): Constant updated.
(eval-when-compile (require 'cl)) added.
* reftex-ref.el (reftex-offer-label-menu): Prefix to `t' command key
can change `reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-sel (reftex-insert-docstruct): Respect
`reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-auc.el (eval-when-compile (require 'cl)) added.
* reftex-vcr.el (eval-when-compile (require 'cl)) added.
* reftex-cite.el (reftex-citep, reftex-citet): New commands.
(reftex-citation, reftex-do-citation,
reftex-figure-out-cite-format): Additional argument FORMAT-KEY to
preselect a citation format.
(eval-when-compile (require 'cl)) added.
* reftex-parse.el (reftex-context-substring): Optional parameter
to-end
(reftex-section-info): Deal with environment matches.
(eval-when-compile (require 'cl)) added.
* reftex-global.el (eval-when-compile (require 'cl)) added.
| -rw-r--r-- | lisp/textmodes/reftex-auc.el | 3 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-cite.el | 42 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-global.el | 5 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-index.el | 1118 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-parse.el | 45 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-ref.el | 10 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-sel.el | 6 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-toc.el | 25 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-vars.el | 146 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-vcr.el | 3 | ||||
| -rw-r--r-- | lisp/textmodes/reftex.el | 170 |
11 files changed, 1318 insertions, 255 deletions
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el index 0e6ad5f5059..8324357b2b4 100644 --- a/lisp/textmodes/reftex-auc.el +++ b/lisp/textmodes/reftex-auc.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-auc.el - RefTeX's interface to AUC TeX | 1 | ;;; reftex-auc.el - RefTeX's interface to AUC TeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-auc) | 7 | (provide 'reftex-auc) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index d528b54540e..ae42e7a932c 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-cite.el - Creating citations with RefTeX | 1 | ;;; reftex-cite.el - Creating citations with RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-cite) | 7 | (provide 'reftex-cite) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -501,7 +502,7 @@ | |||
| 501 | ;; Make a citation | 502 | ;; Make a citation |
| 502 | 503 | ||
| 503 | ;;;###autoload | 504 | ;;;###autoload |
| 504 | (defun reftex-citation (&optional no-insert) | 505 | (defun reftex-citation (&optional no-insert format-key) |
| 505 | "Make a citation using BibTeX database files. | 506 | "Make a citation using BibTeX database files. |
| 506 | After prompting for a regular expression, scans the buffers with | 507 | After prompting for a regular expression, scans the buffers with |
| 507 | bibtex entries (taken from the \\bibliography command) and offers the | 508 | bibtex entries (taken from the \\bibliography command) and offers the |
| @@ -510,6 +511,8 @@ to `reftex-cite-format' and inserted into the buffer. | |||
| 510 | 511 | ||
| 511 | If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. | 512 | If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. |
| 512 | 513 | ||
| 514 | FORAT-KEY can be used to pre-select a citation format. | ||
| 515 | |||
| 513 | When called with one or two `C-u' prefixes, first rescans the document. | 516 | When called with one or two `C-u' prefixes, first rescans the document. |
| 514 | When called with a numeric prefix, make that many citations. When | 517 | When called with a numeric prefix, make that many citations. When |
| 515 | called with point inside the braces of a `\cite' command, it will | 518 | called with point inside the braces of a `\cite' command, it will |
| @@ -533,13 +536,13 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 533 | 536 | ||
| 534 | ;; Call reftex-do-citation, but protected | 537 | ;; Call reftex-do-citation, but protected |
| 535 | (unwind-protect | 538 | (unwind-protect |
| 536 | (reftex-do-citation current-prefix-arg no-insert) | 539 | (reftex-do-citation current-prefix-arg no-insert format-key) |
| 537 | (reftex-kill-temporary-buffers))) | 540 | (reftex-kill-temporary-buffers))) |
| 538 | 541 | ||
| 539 | (defun reftex-do-citation (&optional arg no-insert) | 542 | (defun reftex-do-citation (&optional arg no-insert format-key) |
| 540 | ;; This really does the work of reftex-citation. | 543 | ;; This really does the work of reftex-citation. |
| 541 | 544 | ||
| 542 | (let* ((format (reftex-figure-out-cite-format arg no-insert)) | 545 | (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) |
| 543 | (docstruct-symbol reftex-docstruct-symbol) | 546 | (docstruct-symbol reftex-docstruct-symbol) |
| 544 | (selected-entries (reftex-offer-bib-menu)) | 547 | (selected-entries (reftex-offer-bib-menu)) |
| 545 | (insert-entries selected-entries) | 548 | (insert-entries selected-entries) |
| @@ -610,7 +613,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 610 | ;; Return the citation key | 613 | ;; Return the citation key |
| 611 | (car (car selected-entries)))) | 614 | (car (car selected-entries)))) |
| 612 | 615 | ||
| 613 | (defun reftex-figure-out-cite-format (arg no-insert) | 616 | (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) |
| 614 | ;; Check if there is already a cite command at point and change cite format | 617 | ;; Check if there is already a cite command at point and change cite format |
| 615 | ;; in order to only add another reference in the same cite command. | 618 | ;; in order to only add another reference in the same cite command. |
| 616 | (let ((macro (car (reftex-what-macro 1))) | 619 | (let ((macro (car (reftex-what-macro 1))) |
| @@ -640,19 +643,30 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 640 | cite-format-value)) | 643 | cite-format-value)) |
| 641 | (when (listp format) | 644 | (when (listp format) |
| 642 | (setq key | 645 | (setq key |
| 643 | (reftex-select-with-char | 646 | (or format-key |
| 644 | "" (concat "SELECT A CITATION FORMAT\n\n" | 647 | (reftex-select-with-char |
| 645 | (mapconcat | 648 | "" (concat "SELECT A CITATION FORMAT\n\n" |
| 646 | (lambda (x) | 649 | (mapconcat |
| 647 | (format "[%c] %s %s" (car x) | 650 | (lambda (x) |
| 648 | (if (> (car x) 31) " " "") | 651 | (format "[%c] %s %s" (car x) |
| 649 | (cdr x))) | 652 | (if (> (car x) 31) " " "") |
| 650 | format "\n")))) | 653 | (cdr x))) |
| 654 | format "\n"))))) | ||
| 651 | (if (assq key format) | 655 | (if (assq key format) |
| 652 | (setq format (cdr (assq key format))) | 656 | (setq format (cdr (assq key format))) |
| 653 | (error "No citation format associated with key `%c'" key))))) | 657 | (error "No citation format associated with key `%c'" key))))) |
| 654 | format)) | 658 | format)) |
| 655 | 659 | ||
| 660 | (defun reftex-citep () | ||
| 661 | "Call `reftex-citation' with a format selector `?p'." | ||
| 662 | (interactive) | ||
| 663 | (reftex-citation nil ?p)) | ||
| 664 | |||
| 665 | (defun reftex-citet () | ||
| 666 | "Call `reftex-citation' with a format selector `?t'." | ||
| 667 | (interactive) | ||
| 668 | (reftex-citation nil ?t)) | ||
| 669 | |||
| 656 | (defvar reftex-select-bib-map) | 670 | (defvar reftex-select-bib-map) |
| 657 | (defun reftex-offer-bib-menu () | 671 | (defun reftex-offer-bib-menu () |
| 658 | ;; Offer bib menu and return list of selected items | 672 | ;; Offer bib menu and return list of selected items |
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el index d484f5f0365..c62a555ac17 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-global.el - Operations on entire documents with RefTeX | 1 | ;;; reftex-global.el - Operations on entire documents with RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-global) | 7 | (provide 'reftex-global) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -191,7 +192,7 @@ one with the `xr' package." | |||
| 191 | (if (assoc label translate-alist) | 192 | (if (assoc label translate-alist) |
| 192 | (error "Duplicate label %s" label)) | 193 | (error "Duplicate label %s" label)) |
| 193 | (setq new-label (concat (match-string 1 (car entry)) | 194 | (setq new-label (concat (match-string 1 (car entry)) |
| 194 | (incf (cdr nr-cell)))) | 195 | (int-to-string (incf (cdr nr-cell))))) |
| 195 | (push (cons label new-label) translate-alist) | 196 | (push (cons label new-label) translate-alist) |
| 196 | (or (string= label new-label) (setq changed-sequence t)))) | 197 | (or (string= label new-label) (setq changed-sequence t)))) |
| 197 | 198 | ||
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index 64ee50046d6..0c020f6bf06 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-index.el - Index support with RefTeX | 1 | ;;; reftex-index.el - Index support with RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-index) | 7 | (provide 'reftex-index) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -10,7 +11,7 @@ | |||
| 10 | (defvar mark-active) | 11 | (defvar mark-active) |
| 11 | (defvar zmacs-regions) | 12 | (defvar zmacs-regions) |
| 12 | (defvar transient-mark-mode) | 13 | (defvar transient-mark-mode) |
| 13 | (defun reftex-index-selection-or-word (&optional arg) | 14 | (defun reftex-index-selection-or-word (&optional arg phrase) |
| 14 | "Put selection or the word near point into the default index macro. | 15 | "Put selection or the word near point into the default index macro. |
| 15 | This uses the information in `reftex-index-default-macro' to make an index | 16 | This uses the information in `reftex-index-default-macro' to make an index |
| 16 | entry. The phrase indexed is the current selection or the word near point. | 17 | entry. The phrase indexed is the current selection or the word near point. |
| @@ -37,33 +38,34 @@ which is part of AUCTeX, the string is first processed with the | |||
| 37 | (sel (buffer-substring beg end)) | 38 | (sel (buffer-substring beg end)) |
| 38 | (mathp (condition-case nil (texmathp) (error nil))) | 39 | (mathp (condition-case nil (texmathp) (error nil))) |
| 39 | (current-prefix-arg nil) ; we want to call reftex-index without prefix. | 40 | (current-prefix-arg nil) ; we want to call reftex-index without prefix. |
| 40 | key def-char def-tag full-entry repeat-word) | 41 | key def-char def-tag full-entry) |
| 41 | |||
| 42 | (if (equal sel "") | ||
| 43 | ;; Nothing selecte, no word, so use full reftex-index command | ||
| 44 | (reftex-index) | ||
| 45 | ;; OK, we have something to index here. | ||
| 46 | ;; Add the dollars when necessary | ||
| 47 | (setq key (if mathp | ||
| 48 | (format reftex-index-math-format sel) | ||
| 49 | sel)) | ||
| 50 | ;; Get info from `reftex-index-default-macro' | ||
| 51 | (setq def-char (if use-default (car reftex-index-default-macro))) | ||
| 52 | (setq def-tag (if use-default (nth 1 reftex-index-default-macro))) | ||
| 53 | ;; Does the user want to edit the entry? | ||
| 54 | (setq full-entry (if arg | ||
| 55 | (reftex-index-complete-key | ||
| 56 | def-tag nil (cons key 0)) | ||
| 57 | key)) | ||
| 58 | ;; Do we neet to repeat the word outside the macro? | ||
| 59 | (setq repeat-word (if use-default | ||
| 60 | (nth 2 reftex-index-default-macro) | ||
| 61 | (y-or-n-p "Repeat phrase outside macro? "))) | ||
| 62 | ;; Delete what is in the buffer and make the index entry | ||
| 63 | (delete-region beg end) | ||
| 64 | (reftex-index def-char full-entry def-tag (if repeat-word sel nil))))) | ||
| 65 | 42 | ||
| 66 | (defun reftex-index (&optional char key tag postfix no-insert) | 43 | (if phrase |
| 44 | (progn | ||
| 45 | (reftex-index-visit-phrases-buffer) | ||
| 46 | (reftex-index-new-phrase sel)) | ||
| 47 | |||
| 48 | (if (equal sel "") | ||
| 49 | ;; Nothing selected, no word, so use full reftex-index command | ||
| 50 | (reftex-index) | ||
| 51 | ;; OK, we have something to index here. | ||
| 52 | ;; Add the dollars when necessary | ||
| 53 | (setq key (if mathp | ||
| 54 | (format reftex-index-math-format sel) | ||
| 55 | sel)) | ||
| 56 | ;; Get info from `reftex-index-default-macro' | ||
| 57 | (setq def-char (if use-default (car reftex-index-default-macro))) | ||
| 58 | (setq def-tag (if use-default (nth 1 reftex-index-default-macro))) | ||
| 59 | ;; Does the user want to edit the entry? | ||
| 60 | (setq full-entry (if arg | ||
| 61 | (reftex-index-complete-key | ||
| 62 | def-tag nil (cons key 0)) | ||
| 63 | key)) | ||
| 64 | ;; Delete what is in the buffer and make the index entry | ||
| 65 | (delete-region beg end) | ||
| 66 | (reftex-index def-char full-entry def-tag sel))))) | ||
| 67 | |||
| 68 | (defun reftex-index (&optional char key tag sel no-insert) | ||
| 67 | "Query for an index macro and insert it along with its argments. | 69 | "Query for an index macro and insert it along with its argments. |
| 68 | The index macros available are those defined in `reftex-index-macro' or | 70 | The index macros available are those defined in `reftex-index-macro' or |
| 69 | by a call to `reftex-add-index-macros', typically from an AUCTeX style file. | 71 | by a call to `reftex-add-index-macros', typically from an AUCTeX style file. |
| @@ -88,6 +90,7 @@ will prompt for other arguments." | |||
| 88 | (nargs (nth 4 entry)) | 90 | (nargs (nth 4 entry)) |
| 89 | (nindex (nth 5 entry)) | 91 | (nindex (nth 5 entry)) |
| 90 | (opt-args (nth 6 entry)) | 92 | (opt-args (nth 6 entry)) |
| 93 | (repeat (nth 7 entry)) | ||
| 91 | opt tag1 value) | 94 | opt tag1 value) |
| 92 | 95 | ||
| 93 | ;; Get the supported arguments | 96 | ;; Get the supported arguments |
| @@ -111,7 +114,7 @@ will prompt for other arguments." | |||
| 111 | ": "))))) | 114 | ": "))))) |
| 112 | (unless (and opt (string= value "")) | 115 | (unless (and opt (string= value "")) |
| 113 | (insert (if opt "[" "{") value (if opt "]" "}")))) | 116 | (insert (if opt "[" "{") value (if opt "]" "}")))) |
| 114 | (and (stringp postfix) (insert postfix)) | 117 | (and repeat (stringp sel) (insert sel)) |
| 115 | (and key reftex-plug-into-AUCTeX (fboundp 'LaTeX-add-index-entries) | 118 | (and key reftex-plug-into-AUCTeX (fboundp 'LaTeX-add-index-entries) |
| 116 | (LaTeX-add-index-entries key)) | 119 | (LaTeX-add-index-entries key)) |
| 117 | (reftex-index-update-taglist tag1) | 120 | (reftex-index-update-taglist tag1) |
| @@ -236,98 +239,6 @@ will prompt for other arguments." | |||
| 236 | (and newtag (cdr cell) (not (member newtag (cdr cell))) | 239 | (and newtag (cdr cell) (not (member newtag (cdr cell))) |
| 237 | (push newtag (cdr cell))))) | 240 | (push newtag (cdr cell))))) |
| 238 | 241 | ||
| 239 | (defvar reftex-last-index-file) | ||
| 240 | (defun reftex-index-globally (&optional data call-file) | ||
| 241 | "Index a word with a global search and replace. | ||
| 242 | This works very much like `reftex-query-replace-document', but the | ||
| 243 | defaults for the search and replace strings are derived from | ||
| 244 | local context. | ||
| 245 | When there is an index entry, we try to index similar words. The word | ||
| 246 | to search for is either a word in direct contact with the index macro | ||
| 247 | (like `\\index{WORD}WORD' or `WORD\\index{WORD}') or the index key. | ||
| 248 | The replacement text is the index macro with all its arguments and the | ||
| 249 | attached word. | ||
| 250 | When there is no index entry at point, we search for the word near point | ||
| 251 | and propose to index it like this: `\\index{word}word'. | ||
| 252 | You get a chance to edit the search and replacement strings. | ||
| 253 | DATA can be a docstruct entry describing an index entry, and then the | ||
| 254 | defaults will be derived from it. | ||
| 255 | CALL-FILE may be the file from where to call the global search command." | ||
| 256 | (interactive) | ||
| 257 | (let* ((call-file (cond (call-file call-file) | ||
| 258 | (reftex-mode (buffer-file-name)) | ||
| 259 | ((eq major-mode 'reftex-index-mode) | ||
| 260 | reftex-last-index-file) | ||
| 261 | (t (error "Need a call file here")))) | ||
| 262 | (pos (point)) | ||
| 263 | (data (cond | ||
| 264 | (data data) | ||
| 265 | ((and reftex-mode | ||
| 266 | (save-excursion | ||
| 267 | (forward-char 20) | ||
| 268 | (re-search-backward reftex-everything-regexp nil t) | ||
| 269 | (< (count-lines (min pos (point)) (max pos (point))) | ||
| 270 | 2))) | ||
| 271 | (reftex-index-info (buffer-file-name))) | ||
| 272 | (t nil))) | ||
| 273 | (ksep (car reftex-index-special-chars)) | ||
| 274 | (words-include-escapes t) | ||
| 275 | (case-replace nil) | ||
| 276 | (case-fold-search t) | ||
| 277 | word rpl start analyze-list pre key attr actual post) | ||
| 278 | |||
| 279 | ;; Find the word and construct the replacement string | ||
| 280 | (if (and data (eq (car data) 'index)) | ||
| 281 | ;; OK, we have an index entry | ||
| 282 | (progn | ||
| 283 | (setq analyze-list (reftex-index-analyze-entry data) | ||
| 284 | pre (car analyze-list) | ||
| 285 | key (nth 1 analyze-list) | ||
| 286 | attr (nth 2 analyze-list) | ||
| 287 | actual (nth 3 analyze-list) | ||
| 288 | post (nth 4 analyze-list)) | ||
| 289 | (when (string-match (concat "\\<\\(\\sw+\\)" reftex-index-re) pre) | ||
| 290 | (setq word (match-string 1 pre) | ||
| 291 | pre (concat "<<<1>>>" (substring pre (match-end 1))) | ||
| 292 | rpl (concat pre key attr actual post))) | ||
| 293 | (when (string-match "}\\(\\sw+\\)\\>[^}]*\\'" post) | ||
| 294 | (setq word (match-string 1 post) | ||
| 295 | post (concat (substring post 0 (match-beginning 1)) | ||
| 296 | "<<<1>>>") | ||
| 297 | rpl (concat pre key attr actual post))) | ||
| 298 | (when (and (not word) key) | ||
| 299 | (if (string-match (concat ".*" (regexp-quote ksep)) key) | ||
| 300 | (setq word (substring key (match-end 0))) | ||
| 301 | (setq word key)) | ||
| 302 | (setq rpl (concat pre key attr actual post)))) | ||
| 303 | ;; No index entry, just use local word. | ||
| 304 | (setq word (save-excursion | ||
| 305 | (buffer-substring-no-properties | ||
| 306 | (progn (skip-syntax-backward "w") (point)) | ||
| 307 | (progn (skip-syntax-forward "w") (point)))) | ||
| 308 | rpl (concat "\\index{" word "}<<<1>>>"))) | ||
| 309 | ;; Quote what is necessary | ||
| 310 | (setq word (regexp-quote (downcase word))) | ||
| 311 | (setq start 0) | ||
| 312 | (while (setq start (string-match "\\\\" rpl start)) | ||
| 313 | (setq rpl (replace-match "\\\\" t t rpl) | ||
| 314 | start (+ 2 start))) | ||
| 315 | ;; We used <<<1>>> instead of \1 to avoid the quoting. Fix this now. | ||
| 316 | (if (string-match "<<<1>>>" rpl) | ||
| 317 | (setq rpl (replace-match "\\1" t t rpl))) | ||
| 318 | |||
| 319 | ;; Give the user a chance to edit the strings | ||
| 320 | (setq word (read-string "Search: " | ||
| 321 | (if word (format "\\<\\(%s\\)\\>" word))) | ||
| 322 | rpl (read-string "Replace with: " rpl)) | ||
| 323 | |||
| 324 | ;; Execute the command | ||
| 325 | (save-excursion | ||
| 326 | (switch-to-buffer (get-file-buffer call-file)) | ||
| 327 | (condition-case nil | ||
| 328 | (reftex-query-replace-document word rpl) | ||
| 329 | (error nil))))) | ||
| 330 | |||
| 331 | (defvar reftex-index-map (make-sparse-keymap) | 242 | (defvar reftex-index-map (make-sparse-keymap) |
| 332 | "Keymap used for *Index* buffers.") | 243 | "Keymap used for *Index* buffers.") |
| 333 | 244 | ||
| @@ -392,7 +303,6 @@ e / C-k Edit/Kill the entry. | |||
| 392 | With prefix: kill that part. | 303 | With prefix: kill that part. |
| 393 | ( ) Toggle entry's beginning/end of page range property. | 304 | ( ) Toggle entry's beginning/end of page range property. |
| 394 | _ ^ Add/Remove parent key (to make this item a subitem). | 305 | _ ^ Add/Remove parent key (to make this item a subitem). |
| 395 | & Index the same word everywhere in the document. | ||
| 396 | } / { Restrict Index to a single document section / Widen. | 306 | } / { Restrict Index to a single document section / Widen. |
| 397 | < / > When restricted, move restriction to previous/next section.") | 307 | < / > When restricted, move restriction to previous/next section.") |
| 398 | 308 | ||
| @@ -918,22 +828,6 @@ When index is restricted, select the previous section as restriction criterion." | |||
| 918 | (post (substring context eoa))) | 828 | (post (substring context eoa))) |
| 919 | (list pre key attr actual post))) | 829 | (list pre key attr actual post))) |
| 920 | 830 | ||
| 921 | (defun reftex-index-globalize (&optional arg) | ||
| 922 | "Globalize the current index entry. | ||
| 923 | This starts a global search and replace to index the same word | ||
| 924 | at other places in the document. After this function completes, you | ||
| 925 | need to rescan the document with `r' or `C-u r' in order to get the | ||
| 926 | entries into the index buffer. | ||
| 927 | Defaults for the search and replace strings are derived from | ||
| 928 | the current entry. See the command `reftex-index-globally'." | ||
| 929 | (interactive) | ||
| 930 | (let* ((data (get-text-property (point) :data)) | ||
| 931 | (buf (current-buffer))) | ||
| 932 | (unless data | ||
| 933 | (error "No index entry at point")) | ||
| 934 | (reftex-index-globally data) | ||
| 935 | (switch-to-buffer buf))) | ||
| 936 | |||
| 937 | (defun reftex-index-edit () | 831 | (defun reftex-index-edit () |
| 938 | "Edit the index entry at point." | 832 | "Edit the index entry at point." |
| 939 | (interactive) | 833 | (interactive) |
| @@ -964,7 +858,7 @@ the current entry. See the command `reftex-index-globally'." | |||
| 964 | "Toggle the page-range-end attribute `|)'." | 858 | "Toggle the page-range-end attribute `|)'." |
| 965 | (interactive) | 859 | (interactive) |
| 966 | (let* ((data (get-text-property (point) :data)) | 860 | (let* ((data (get-text-property (point) :data)) |
| 967 | (eor (concat (nth 1 reftex-index-special-chars) "(")) | 861 | (eor (concat (nth 1 reftex-index-special-chars) ")")) |
| 968 | new analyze attr) | 862 | new analyze attr) |
| 969 | (unless data (error "Don't know which index entry to edit")) | 863 | (unless data (error "Don't know which index entry to edit")) |
| 970 | (setq analyze (reftex-index-analyze-entry data) | 864 | (setq analyze (reftex-index-analyze-entry data) |
| @@ -1138,7 +1032,6 @@ the current entry. See the command `reftex-index-globally'." | |||
| 1138 | ("|" . reftex-index-edit-attribute) | 1032 | ("|" . reftex-index-edit-attribute) |
| 1139 | ("@" . reftex-index-edit-visual) | 1033 | ("@" . reftex-index-edit-visual) |
| 1140 | ("*" . reftex-index-edit-key) | 1034 | ("*" . reftex-index-edit-key) |
| 1141 | ("&" . reftex-index-globalize) | ||
| 1142 | ("\C-c=". reftex-index-goto-toc) | 1035 | ("\C-c=". reftex-index-goto-toc) |
| 1143 | ("c" . reftex-index-toggle-context)) | 1036 | ("c" . reftex-index-toggle-context)) |
| 1144 | do (define-key reftex-index-map (car x) (cdr x))) | 1037 | do (define-key reftex-index-map (car x) (cdr x))) |
| @@ -1164,8 +1057,11 @@ the current entry. See the command `reftex-index-globally'." | |||
| 1164 | (recenter 0) | 1057 | (recenter 0) |
| 1165 | (reftex-index-next)) | 1058 | (reftex-index-next)) |
| 1166 | (goto-char pos) | 1059 | (goto-char pos) |
| 1167 | (error "This <%s> index does not contain entries starting with `%c'" | 1060 | (if (eq char ?!) |
| 1168 | reftex-index-tag char)))) | 1061 | (error "This <%s> index does not contain entries sorted before the letters" |
| 1062 | reftex-index-tag) | ||
| 1063 | (error "This <%s> index does not contain entries starting with `%c'" | ||
| 1064 | reftex-index-tag char))))) | ||
| 1169 | 1065 | ||
| 1170 | (easy-menu-define | 1066 | (easy-menu-define |
| 1171 | reftex-index-menu reftex-index-map | 1067 | reftex-index-menu reftex-index-map |
| @@ -1204,7 +1100,6 @@ the current entry. See the command `reftex-index-globally'." | |||
| 1204 | ["Make Start-of-Range" reftex-index-toggle-range-beginning t] | 1100 | ["Make Start-of-Range" reftex-index-toggle-range-beginning t] |
| 1205 | ["Make End-of-Range" reftex-index-toggle-range-end t] | 1101 | ["Make End-of-Range" reftex-index-toggle-range-end t] |
| 1206 | "--" | 1102 | "--" |
| 1207 | ["Globalize" reftex-index-globalize t] | ||
| 1208 | ["Kill Entry" reftex-index-kill nil] | 1103 | ["Kill Entry" reftex-index-kill nil] |
| 1209 | "--" | 1104 | "--" |
| 1210 | ["Undo" reftex-index-undo nil]) | 1105 | ["Undo" reftex-index-undo nil]) |
| @@ -1217,4 +1112,941 @@ the current entry. See the command `reftex-index-globally'." | |||
| 1217 | "--" | 1112 | "--" |
| 1218 | ["Help" reftex-index-show-help t])) | 1113 | ["Help" reftex-index-show-help t])) |
| 1219 | 1114 | ||
| 1115 | |||
| 1116 | ;;---------------------------------------------------------------------- | ||
| 1117 | ;; The Index Phrases File | ||
| 1118 | |||
| 1119 | ;; Some constants and variables | ||
| 1120 | (defconst reftex-index-phrases-comment-regexp "^[ \t]*%.*" | ||
| 1121 | "Regular expression to match comment lines in phrases buffer") | ||
| 1122 | (defconst reftex-index-phrases-macrodef-regexp | ||
| 1123 | "^\\(>>>INDEX_MACRO_DEFINITION:\\)[ \t]+\\(\\S-\\)\\( *\t[ \t]*\\)\\([^\t]*[^ \t]\\)\\( *\t[ \t]*\\)\\(\\S-+\\)" | ||
| 1124 | "Regular expression to match macro definition lines the phrases buffer.") | ||
| 1125 | ;(defconst reftex-index-phrases-macrodef-regexp | ||
| 1126 | ; "^\\(>>>INDEX_MACRO_DEFINITION:\\)[ \t]+\\(\\S-\\)\\([ \t]*\\)\\([^\t]*[^ \t]\\)\\([ \t]*\\)\\(nil\\|t\\)[ \t]*$" | ||
| 1127 | ; "Regular expression to match macro definition lines the phrases buffer. | ||
| 1128 | ;This version would allow just spaces as separators.") | ||
| 1129 | (defconst reftex-index-phrases-phrase-regexp1 | ||
| 1130 | "^\\(\\S-?\\)\\(\t\\)\\([^\t\n]*\\S-\\)\\([ \t]*\\)$" | ||
| 1131 | "Regular expression matching phrases which have no separate index key.") | ||
| 1132 | (defconst reftex-index-phrases-phrase-regexp2 | ||
| 1133 | "^\\(\\S-?\\)\\(\t\\)\\([^\t]*\\S-\\)\\(\t[ \t]*\\)\\([^\n\t]*\\S-\\)[ \t]*$" | ||
| 1134 | "Regular expression matching phrases which have a separate index key.") | ||
| 1135 | (defconst reftex-index-phrases-phrase-regexp12 | ||
| 1136 | "^\\(\\S-?\\)\\(\t\\)\\([^\n\t]*\\S-\\)\\(\\(\t[ \t]*\\)\\([^\n\t]*\\S-\\)\\)?[ \t]*$" | ||
| 1137 | "Regular expression matching all types of phrase lines.") | ||
| 1138 | (defvar reftex-index-phrases-macro-data nil | ||
| 1139 | "Alist containing the information taken from the macro definition lines. | ||
| 1140 | This gets refreshed in every phrases command.") | ||
| 1141 | (defvar reftex-index-phrases-files nil | ||
| 1142 | "List of document files relevant for the phrases file.") | ||
| 1143 | |||
| 1144 | (defvar reftex-index-phrases-font-lock-keywords nil | ||
| 1145 | "Font lock keywords for reftex-index-phrases-mode.") | ||
| 1146 | (defvar reftex-index-phrases-font-lock-defaults nil | ||
| 1147 | "Font lock defaults for reftex-index-phrases-mode.") | ||
| 1148 | (defvar reftex-index-phrases-map (make-sparse-keymap) | ||
| 1149 | "Keymap used for *toc* buffer.") | ||
| 1150 | |||
| 1151 | |||
| 1152 | (defun reftex-index-phrase-selection-or-word (arg) | ||
| 1153 | "Add current selection or word at point to the phrases buffer. | ||
| 1154 | When you are in transient-mark-mode and the region is active, the | ||
| 1155 | selection will be used - otherwise the word at point. | ||
| 1156 | You get a chance to edit the entry in the phrases buffer - finish with | ||
| 1157 | `C-c C-c'." | ||
| 1158 | (interactive "P") | ||
| 1159 | (set-marker reftex-index-return-marker (point)) | ||
| 1160 | (reftex-index-selection-or-word arg 'phrase) | ||
| 1161 | (if (eq major-mode 'reftex-index-phrases-mode) | ||
| 1162 | (message | ||
| 1163 | (substitute-command-keys | ||
| 1164 | "Return to LaTeX with \\[reftex-index-phrases-save-and-return]")))) | ||
| 1165 | |||
| 1166 | (defun reftex-index-visit-phrases-buffer () | ||
| 1167 | "Switch to the phrases buffer, initialize if empty." | ||
| 1168 | (interactive) | ||
| 1169 | (reftex-access-scan-info) | ||
| 1170 | (let* ((master (reftex-TeX-master-file)) | ||
| 1171 | (name (concat (file-name-sans-extension master) ".rip"))) | ||
| 1172 | (find-file name) | ||
| 1173 | (unless (eq major-mode 'reftex-index-phrases-mode) | ||
| 1174 | (reftex-index-phrases-mode)) | ||
| 1175 | (if (= (buffer-size) 0) | ||
| 1176 | (reftex-index-initialize-phrases-buffer master)))) | ||
| 1177 | |||
| 1178 | (defun reftex-index-initialize-phrases-buffer (&optional master) | ||
| 1179 | "Initialize the phrases buffer by creating the header. | ||
| 1180 | If the buffer is non-empty, delete the old header first." | ||
| 1181 | (interactive) | ||
| 1182 | (let* ((case-fold-search t) | ||
| 1183 | (default-key (car reftex-index-default-macro)) | ||
| 1184 | (default-macro (nth 1 (assoc default-key | ||
| 1185 | reftex-key-to-index-macro-alist))) | ||
| 1186 | (macro-alist | ||
| 1187 | (sort (copy-sequence reftex-index-macro-alist) | ||
| 1188 | (lambda (a b) (equal (car a) default-macro)))) | ||
| 1189 | macro entry key repeat) | ||
| 1190 | |||
| 1191 | (if master (set (make-local-variable 'TeX-master) | ||
| 1192 | (file-name-nondirectory master))) | ||
| 1193 | |||
| 1194 | (when (> (buffer-size) 0) | ||
| 1195 | (goto-char 1) | ||
| 1196 | (set-mark (point)) | ||
| 1197 | (while (re-search-forward reftex-index-phrases-macrodef-regexp nil t) | ||
| 1198 | (end-of-line)) | ||
| 1199 | (beginning-of-line 2) | ||
| 1200 | (if (looking-at reftex-index-phrases-comment-regexp) | ||
| 1201 | (beginning-of-line 2)) | ||
| 1202 | (while (looking-at "^[ \t]*$") | ||
| 1203 | (beginning-of-line 2)) | ||
| 1204 | (cond ((fboundp 'zmacs-activate-region) (zmacs-activate-region)) | ||
| 1205 | ((boundp 'make-active) (setq mark-active t))) | ||
| 1206 | (if (yes-or-no-p "Delete and rebuilt header ") | ||
| 1207 | (delete-region (point-min) (point)))) | ||
| 1208 | |||
| 1209 | ;; Insert the mode line | ||
| 1210 | (insert | ||
| 1211 | (format "%% -*- mode: reftex-index-phrases; TeX-master: \"%s\" -*-\n" | ||
| 1212 | (file-name-nondirectory (reftex-index-phrase-tex-master)))) | ||
| 1213 | ;; Insert the macro definitions | ||
| 1214 | (insert "% Key Macro Format Repeat\n") | ||
| 1215 | (insert "%---------------------------------------------------------------------\n") | ||
| 1216 | (while (setq entry (pop macro-alist)) | ||
| 1217 | (setq macro (car entry) | ||
| 1218 | repeat (nth 7 entry) | ||
| 1219 | key (car (delq nil (mapcar (lambda (x) (if (equal (nth 1 x) macro) | ||
| 1220 | (car x) | ||
| 1221 | nil)) | ||
| 1222 | reftex-key-to-index-macro-alist)))) | ||
| 1223 | (insert (format ">>>INDEX_MACRO_DEFINITION:\t%s\t%-20s\t%s\n" | ||
| 1224 | (char-to-string key) (concat macro "{%s}") | ||
| 1225 | (if repeat "t" "nil")))) | ||
| 1226 | (insert "%---------------------------------------------------------------------\n\n\n"))) | ||
| 1227 | |||
| 1228 | (defvar TeX-master) | ||
| 1229 | (defun reftex-index-phrase-tex-master (&optional dir) | ||
| 1230 | "Return the name of the master file associated with a phrase buffer." | ||
| 1231 | (if (and (boundp 'TeX-master) | ||
| 1232 | (local-variable-p 'TeX-master (current-buffer)) | ||
| 1233 | (stringp TeX-master)) | ||
| 1234 | ;; We have a local variable which tells us which file to use | ||
| 1235 | (expand-file-name TeX-master dir) | ||
| 1236 | ;; have to guess | ||
| 1237 | (concat (file-name-sans-extension (buffer-file-name)) ".tex"))) | ||
| 1238 | |||
| 1239 | (defun reftex-index-phrases-save-and-return () | ||
| 1240 | "Return to where the `reftex-index-phrase-selection-or-word' was called." | ||
| 1241 | (interactive) | ||
| 1242 | (save-buffer) | ||
| 1243 | (switch-to-buffer (marker-buffer reftex-index-return-marker)) | ||
| 1244 | (goto-char (or (marker-position reftex-index-return-marker) (point)))) | ||
| 1245 | |||
| 1246 | |||
| 1247 | (defvar reftex-index-phrases-menu) | ||
| 1248 | (defvar reftex-index-phrases-restrict-file nil) | ||
| 1249 | ;;;###autoload | ||
| 1250 | (defun reftex-index-phrases-mode () | ||
| 1251 | "Major mode for managing the Index phrases of a LaTeX document. | ||
| 1252 | This buffer was created with RefTeX. | ||
| 1253 | |||
| 1254 | To insert new phrases, use | ||
| 1255 | - `C-c \\' in the LaTeX document to copy selection or word | ||
| 1256 | - `\\[reftex-index-new-phrase]' in the phrases buffer. | ||
| 1257 | |||
| 1258 | To index phrases use one of: | ||
| 1259 | |||
| 1260 | \\[reftex-index-this-phrase] index current phrase | ||
| 1261 | \\[reftex-index-next-phrase] index next phrase (or N with prefix arg) | ||
| 1262 | \\[reftex-index-all-phrases] index all phrases | ||
| 1263 | \\[reftex-index-remaining-phrases] index current and following phrases | ||
| 1264 | \\[reftex-index-region-phrases] index the phrases in the region | ||
| 1265 | |||
| 1266 | You can sort the phrases in this buffer with \\[reftex-index-sort-phrases]. | ||
| 1267 | To display information about the phrase at point, use \\[reftex-index-phrases-info]. | ||
| 1268 | |||
| 1269 | For more information see the RefTeX User Manual. | ||
| 1270 | |||
| 1271 | Here are all local bindings. | ||
| 1272 | |||
| 1273 | \\{reftex-index-phrases-map}" | ||
| 1274 | (interactive) | ||
| 1275 | (kill-all-local-variables) | ||
| 1276 | (setq major-mode 'reftex-index-phrases-mode | ||
| 1277 | mode-name "Phrases") | ||
| 1278 | (use-local-map reftex-index-phrases-map) | ||
| 1279 | (set (make-local-variable 'font-lock-defaults) | ||
| 1280 | reftex-index-phrases-font-lock-defaults) | ||
| 1281 | (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-map) | ||
| 1282 | (set (make-local-variable 'reftex-index-phrases-marker) (make-marker)) | ||
| 1283 | (run-hooks 'reftex-index-phrases-mode-hook)) | ||
| 1284 | (add-hook 'reftex-index-phrases-mode-hook 'turn-on-font-lock) | ||
| 1285 | |||
| 1286 | ;; Font Locking stuff | ||
| 1287 | (let ((ss (if (featurep 'xemacs) 'secondary-selection ''secondary-selection))) | ||
| 1288 | (setq reftex-index-phrases-font-lock-keywords | ||
| 1289 | (list | ||
| 1290 | (cons reftex-index-phrases-comment-regexp 'font-lock-comment-face) | ||
| 1291 | (list reftex-index-phrases-macrodef-regexp | ||
| 1292 | '(1 font-lock-type-face) | ||
| 1293 | '(2 font-lock-keyword-face) | ||
| 1294 | (list 3 ss) | ||
| 1295 | '(4 font-lock-function-name-face) | ||
| 1296 | (list 5 ss) | ||
| 1297 | '(6 font-lock-string-face)) | ||
| 1298 | (list reftex-index-phrases-phrase-regexp1 | ||
| 1299 | '(1 font-lock-keyword-face) | ||
| 1300 | (list 2 ss) | ||
| 1301 | '(3 font-lock-string-face) | ||
| 1302 | (list 4 ss)) | ||
| 1303 | (list reftex-index-phrases-phrase-regexp2 | ||
| 1304 | '(1 font-lock-keyword-face) | ||
| 1305 | (list 2 ss) | ||
| 1306 | '(3 font-lock-string-face) | ||
| 1307 | (list 4 ss) | ||
| 1308 | '(5 font-lock-function-name-face)) | ||
| 1309 | (cons "^\t$" ss))) | ||
| 1310 | (setq reftex-index-phrases-font-lock-defaults | ||
| 1311 | '((reftex-index-phrases-font-lock-keywords) | ||
| 1312 | nil t nil beginning-of-line)) | ||
| 1313 | (put 'reftex-index-phrases-mode 'font-lock-defaults | ||
| 1314 | reftex-index-phrases-font-lock-defaults) ; XEmacs | ||
| 1315 | ) | ||
| 1316 | |||
| 1317 | (defvar reftex-index-phrases-marker) | ||
| 1318 | (defun reftex-index-next-phrase (&optional arg) | ||
| 1319 | "Index the next ARG phrases in the phrases buffer." | ||
| 1320 | (interactive "p") | ||
| 1321 | (reftex-index-phrases-parse-header t) | ||
| 1322 | (while (> arg 0) | ||
| 1323 | (decf arg) | ||
| 1324 | (end-of-line) | ||
| 1325 | (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t) | ||
| 1326 | (progn | ||
| 1327 | (goto-char (match-beginning 0)) | ||
| 1328 | (reftex-index-this-phrase)) | ||
| 1329 | (error "No more phrase lines after point")))) | ||
| 1330 | |||
| 1331 | (defun reftex-index-this-phrase () | ||
| 1332 | "Index the phrase in the current line. | ||
| 1333 | Does a global search and replace in the entire document. At each | ||
| 1334 | match, the user will be asked to confirm the replacement." | ||
| 1335 | (interactive) | ||
| 1336 | (if (interactive-p) (reftex-index-phrases-parse-header t)) | ||
| 1337 | (save-excursion | ||
| 1338 | (beginning-of-line) | ||
| 1339 | (cond ((looking-at reftex-index-phrases-comment-regexp) | ||
| 1340 | (if (interactive-p) (error "Comment line"))) | ||
| 1341 | ((looking-at "^[ \t]*$") | ||
| 1342 | (if (interactive-p) (error "Empty line"))) | ||
| 1343 | ((looking-at reftex-index-phrases-macrodef-regexp) | ||
| 1344 | (if (interactive-p) (error "Macro definition line"))) | ||
| 1345 | ((looking-at reftex-index-phrases-phrase-regexp12) | ||
| 1346 | ;; This is a phrase | ||
| 1347 | (let* ((char (if (not (equal (match-string 1) "")) | ||
| 1348 | (string-to-char (match-string 1)))) | ||
| 1349 | (phrase (match-string 3)) | ||
| 1350 | (index-key (match-string 6)) | ||
| 1351 | (macro-data (cdr (if (null char) | ||
| 1352 | (car reftex-index-phrases-macro-data) | ||
| 1353 | (assoc char reftex-index-phrases-macro-data)))) | ||
| 1354 | (macro-fmt (car macro-data)) | ||
| 1355 | (repeat (nth 1 macro-data)) | ||
| 1356 | (files | ||
| 1357 | (cond ((and (stringp reftex-index-phrases-restrict-file) | ||
| 1358 | (file-regular-p reftex-index-phrases-restrict-file)) | ||
| 1359 | (list reftex-index-phrases-restrict-file)) | ||
| 1360 | ((stringp reftex-index-phrases-restrict-file) | ||
| 1361 | (error "Illegal restriction file %s" | ||
| 1362 | reftex-index-phrases-restrict-file)) | ||
| 1363 | (t reftex-index-phrases-files))) | ||
| 1364 | (as-words reftex-index-phrases-search-whole-words)) | ||
| 1365 | (unless macro-data | ||
| 1366 | (error "No macro associated with key %c" char)) | ||
| 1367 | (unwind-protect | ||
| 1368 | (let ((overlay-arrow-string "=>") | ||
| 1369 | (overlay-arrow-position | ||
| 1370 | reftex-index-phrases-marker) | ||
| 1371 | (replace-count 0)) | ||
| 1372 | ;; Show the overlay arrow | ||
| 1373 | (move-marker reftex-index-phrases-marker | ||
| 1374 | (match-beginning 0) (current-buffer)) | ||
| 1375 | ;; Start the query-replace | ||
| 1376 | (reftex-query-index-phrase-globally | ||
| 1377 | files phrase macro-fmt | ||
| 1378 | index-key repeat as-words) | ||
| 1379 | (message "%s replaced" | ||
| 1380 | (reftex-number replace-count "occurrence")))))) | ||
| 1381 | (t (error "Cannot parse this line"))))) | ||
| 1382 | |||
| 1383 | (defun reftex-index-all-phrases () | ||
| 1384 | "Index all phrases in the phrases buffer. | ||
| 1385 | Calls `reftex-index-this-phrase' on each line in the buffer." | ||
| 1386 | (interactive) | ||
| 1387 | (reftex-index-region-phrases (point-min) (point-max))) | ||
| 1388 | |||
| 1389 | (defun reftex-index-remaining-phrases () | ||
| 1390 | "Index all phrases in the phrases buffer. | ||
| 1391 | Calls `reftex-index-this-phrase' on each line ay and below point in | ||
| 1392 | the buffer." | ||
| 1393 | (interactive) | ||
| 1394 | (beginning-of-line) | ||
| 1395 | (reftex-index-region-phrases (point) (point-max))) | ||
| 1396 | |||
| 1397 | (defun reftex-index-region-phrases (beg end) | ||
| 1398 | "Index all phrases in the phrases buffer. | ||
| 1399 | Calls `reftex-index-this-phrase' on each line in the region." | ||
| 1400 | (interactive "r") | ||
| 1401 | (reftex-index-phrases-parse-header t) | ||
| 1402 | (goto-char beg) | ||
| 1403 | (while (not (or (eobp) | ||
| 1404 | (>= (point) end))) | ||
| 1405 | (save-excursion (reftex-index-this-phrase)) | ||
| 1406 | (beginning-of-line 2))) | ||
| 1407 | |||
| 1408 | (defun reftex-index-phrases-parse-header (&optional get-files) | ||
| 1409 | "Parse the header of a phrases file to extract the macro definitions. | ||
| 1410 | The definitions get stored in `reftex-index-phrases-macro-data'. | ||
| 1411 | Also switches to the LaTeX document to find out which files belong to | ||
| 1412 | the document and stores the list in `reftex-index-phrases-files'." | ||
| 1413 | (let* ((master (reftex-index-phrase-tex-master)) | ||
| 1414 | buf) | ||
| 1415 | (if get-files | ||
| 1416 | ;; Get the file list | ||
| 1417 | (save-excursion | ||
| 1418 | (setq buf (reftex-get-file-buffer-force master)) | ||
| 1419 | (unless buf (error "Master file %s not found" master)) | ||
| 1420 | (set-buffer buf) | ||
| 1421 | (reftex-access-scan-info) | ||
| 1422 | (setq reftex-index-phrases-files | ||
| 1423 | (reftex-all-document-files)))) | ||
| 1424 | ;; Parse the files header for macro definitions | ||
| 1425 | (setq reftex-index-phrases-macro-data nil) | ||
| 1426 | (save-excursion | ||
| 1427 | (goto-char (point-min)) | ||
| 1428 | (while (re-search-forward reftex-index-phrases-macrodef-regexp nil t) | ||
| 1429 | (push (list | ||
| 1430 | (string-to-char (match-string 2)) | ||
| 1431 | (match-string 4) | ||
| 1432 | (equal (match-string 6) "t")) | ||
| 1433 | reftex-index-phrases-macro-data)) | ||
| 1434 | ;; Reverse the list, so that the first macro is first | ||
| 1435 | (if (null reftex-index-phrases-macro-data) | ||
| 1436 | (error "No valid MACRO DEFINITION line in .rip file (make sure to use TAB separators)")) | ||
| 1437 | (setq reftex-index-phrases-macro-data | ||
| 1438 | (nreverse reftex-index-phrases-macro-data)) | ||
| 1439 | (goto-char (point-min))))) | ||
| 1440 | |||
| 1441 | (defun reftex-index-phrases-apply-to-region (beg end) | ||
| 1442 | "Index all index phrases in the current region. | ||
| 1443 | This works exactly like global indexing from the index phrases buffer, | ||
| 1444 | but operation is restricted to the current region. This is useful if | ||
| 1445 | you need to add/change text in an already indexed document and want to | ||
| 1446 | index the new part without having to go over the unchanged parts again." | ||
| 1447 | (interactive "r") | ||
| 1448 | (let ((win-conf (current-window-configuration)) | ||
| 1449 | (reftex-index-phrases-restrict-file (buffer-file-name))) | ||
| 1450 | (save-excursion | ||
| 1451 | (save-restriction | ||
| 1452 | (narrow-to-region beg end) | ||
| 1453 | (unwind-protect | ||
| 1454 | (progn | ||
| 1455 | ;; Hide the region highlighting | ||
| 1456 | (cond ((fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region)) | ||
| 1457 | ((fboundp 'deactivate-mark) (deactivate-mark))) | ||
| 1458 | (delete-other-windows) | ||
| 1459 | (reftex-index-visit-phrases-buffer) | ||
| 1460 | (reftex-index-all-phrases)) | ||
| 1461 | (set-window-configuration win-conf)))))) | ||
| 1462 | |||
| 1463 | (defun reftex-index-new-phrase (&optional text) | ||
| 1464 | "Open a new line in the phrases buffer, insert TEXT." | ||
| 1465 | (interactive) | ||
| 1466 | (if (and text (stringp text)) | ||
| 1467 | (progn | ||
| 1468 | ;; Check if the phrase is already in the buffer | ||
| 1469 | (setq text (reftex-index-simplify-phrase text)) | ||
| 1470 | (goto-char (point-min)) | ||
| 1471 | (if (re-search-forward | ||
| 1472 | (concat "^\\(\\S-*\\)\t\\(" (regexp-quote text) | ||
| 1473 | "\\) *[\t\n]") nil t) | ||
| 1474 | (progn | ||
| 1475 | (goto-char (match-end 2)) | ||
| 1476 | (error "Phrase is already in phrases buffer"))))) | ||
| 1477 | ;; Add the new phrase line after the last in the buffer | ||
| 1478 | (goto-char (point-max)) | ||
| 1479 | (if (re-search-backward reftex-index-phrases-phrase-regexp12 nil t) | ||
| 1480 | (end-of-line)) | ||
| 1481 | (if (not (bolp)) | ||
| 1482 | (insert "\n")) | ||
| 1483 | (insert "\t") | ||
| 1484 | (if (and text (stringp text)) | ||
| 1485 | (insert text))) | ||
| 1486 | |||
| 1487 | (defun reftex-index-find-next-conflict-phrase (&optional arg) | ||
| 1488 | "Find the next a phrase which is has conflicts in the phrase buffer. | ||
| 1489 | The command helps to find possible conflicts in the phrase indexing process. | ||
| 1490 | It searches downward from point for a phrase which is repeated elsewhere | ||
| 1491 | in the buffer, or which is a subphrase of another phrase. If such a | ||
| 1492 | phrase is found, the phrase info is displayed. | ||
| 1493 | To check the whole buffer, start at the beginning and continue by calling | ||
| 1494 | this function repeatedly." | ||
| 1495 | (interactive "P") | ||
| 1496 | (if (catch 'exit | ||
| 1497 | (while (re-search-forward reftex-index-phrases-phrase-regexp12 nil t) | ||
| 1498 | (goto-char (match-beginning 3)) | ||
| 1499 | (let* ((phrase (match-string 3)) | ||
| 1500 | (case-fold-search reftex-index-phrases-case-fold-search) | ||
| 1501 | (re (reftex-index-phrases-find-dup-re phrase t))) | ||
| 1502 | (if (save-excursion | ||
| 1503 | (goto-char (point-min)) | ||
| 1504 | (and (re-search-forward re nil t) | ||
| 1505 | (re-search-forward re nil t))) | ||
| 1506 | (throw 'exit t))))) | ||
| 1507 | (progn | ||
| 1508 | (reftex-index-phrases-info) | ||
| 1509 | (message "Phrase with match conflict discovered")) | ||
| 1510 | (goto-char (point-max)) | ||
| 1511 | (error "No further problematic phrases found"))) | ||
| 1512 | |||
| 1513 | (defun reftex-index-phrases-info () | ||
| 1514 | "Display information about the phrase at point." | ||
| 1515 | (interactive) | ||
| 1516 | (save-excursion | ||
| 1517 | (beginning-of-line) | ||
| 1518 | (unless (looking-at reftex-index-phrases-phrase-regexp12) | ||
| 1519 | (error "Not a phrase line")) | ||
| 1520 | (save-match-data (reftex-index-phrases-parse-header t)) | ||
| 1521 | (let* ((char (if (not (equal (match-string 1) "")) | ||
| 1522 | (string-to-char (match-string 1)))) | ||
| 1523 | (phrase (match-string 3)) | ||
| 1524 | (index-key (match-string 6)) | ||
| 1525 | (index-keys (split-string | ||
| 1526 | (or index-key phrase) | ||
| 1527 | reftex-index-phrases-logical-or-regexp)) | ||
| 1528 | (macro-data (cdr (if (null char) | ||
| 1529 | (car reftex-index-phrases-macro-data) | ||
| 1530 | (assoc char reftex-index-phrases-macro-data)))) | ||
| 1531 | (macro-fmt (car macro-data)) | ||
| 1532 | (repeat (nth 1 macro-data)) | ||
| 1533 | (as-words reftex-index-phrases-search-whole-words) | ||
| 1534 | (example (reftex-index-make-replace-string | ||
| 1535 | macro-fmt (downcase phrase) (car index-keys) repeat)) | ||
| 1536 | (re (reftex-index-make-phrase-regexp phrase as-words t)) | ||
| 1537 | (re1 (reftex-index-phrases-find-dup-re phrase)) | ||
| 1538 | (re2 (reftex-index-phrases-find-dup-re phrase 'sub)) | ||
| 1539 | superphrases | ||
| 1540 | (nmatches 0) | ||
| 1541 | (ntimes1 0) | ||
| 1542 | (ntimes2 0) | ||
| 1543 | (case-fold-search reftex-index-phrases-case-fold-search) | ||
| 1544 | file files buf) | ||
| 1545 | (setq files reftex-index-phrases-files) | ||
| 1546 | (save-excursion | ||
| 1547 | (save-restriction | ||
| 1548 | (widen) | ||
| 1549 | (goto-char (point-min)) | ||
| 1550 | (while (re-search-forward re1 nil t) | ||
| 1551 | (incf ntimes1)) | ||
| 1552 | (goto-char (point-min)) | ||
| 1553 | (while (re-search-forward re2 nil t) | ||
| 1554 | (push (cons (count-lines 1 (point)) (match-string 1)) superphrases) | ||
| 1555 | (incf ntimes2)))) | ||
| 1556 | (save-excursion | ||
| 1557 | (while (setq file (pop files)) | ||
| 1558 | (setq buf (reftex-get-file-buffer-force file)) | ||
| 1559 | (when buf | ||
| 1560 | (set-buffer buf) | ||
| 1561 | (save-excursion | ||
| 1562 | (save-restriction | ||
| 1563 | (widen) | ||
| 1564 | (goto-char (point-min)) | ||
| 1565 | (let ((case-fold-search reftex-index-phrases-case-fold-search)) | ||
| 1566 | (while (re-search-forward re nil t) | ||
| 1567 | (or (reftex-in-comment) | ||
| 1568 | (incf nmatches))))))))) | ||
| 1569 | (with-output-to-temp-buffer "*Help*" | ||
| 1570 | (princ (format " Phrase: %s\n" phrase)) | ||
| 1571 | (princ (format " Macro key: %s\n" char)) | ||
| 1572 | (princ (format " Macro format: %s\n" macro-fmt)) | ||
| 1573 | (princ (format " Repeat: %s\n" repeat)) | ||
| 1574 | (cond | ||
| 1575 | (index-key | ||
| 1576 | (let ((iks index-keys) (cnt 0) ik) | ||
| 1577 | (while (setq ik (pop iks)) | ||
| 1578 | (princ (format "Index entry %d: %s\n" (incf cnt) ik))))) | ||
| 1579 | (repeat | ||
| 1580 | (princ (format " Index entry: %s\n" phrase))) | ||
| 1581 | (t | ||
| 1582 | (princ (format " Index key: <<Given by the match>>\n")))) | ||
| 1583 | (princ (format " Example: %s\n" example)) | ||
| 1584 | (terpri) | ||
| 1585 | (princ (format "Total matches: %s in %s\n" | ||
| 1586 | (reftex-number nmatches "match" "es") | ||
| 1587 | (reftex-number (length reftex-index-phrases-files) | ||
| 1588 | "LaTeX file"))) | ||
| 1589 | (princ (format " Uniqueness: Phrase occurs %s in phrase buffer\n" | ||
| 1590 | (reftex-number ntimes1 "time"))) | ||
| 1591 | (if (> ntimes2 1) | ||
| 1592 | (progn | ||
| 1593 | (princ (format " Superphrases: Phrase matches the following %s in the phrase buffer:\n" | ||
| 1594 | (reftex-number ntimes2 "line"))) | ||
| 1595 | (mapcar (lambda(x) | ||
| 1596 | (princ (format " Line %4d: %s\n" (car x) (cdr x)))) | ||
| 1597 | (nreverse superphrases)))))))) | ||
| 1598 | |||
| 1599 | (defun reftex-index-phrases-set-macro-key () | ||
| 1600 | "Change the macro key for the current line. | ||
| 1601 | Prompts for a macro key and insert is at the beginning of the line. | ||
| 1602 | If you reply with SPACE, the macro keyn will be removed, so that the | ||
| 1603 | default macro will be used. If you reply with `RET', just prints | ||
| 1604 | information about the currently selected macro." | ||
| 1605 | (interactive) | ||
| 1606 | (reftex-index-phrases-parse-header) | ||
| 1607 | (save-excursion | ||
| 1608 | (beginning-of-line) | ||
| 1609 | (unless (or (looking-at reftex-index-phrases-phrase-regexp12) | ||
| 1610 | (looking-at "\t")) | ||
| 1611 | (error "This is not a phrase line")) | ||
| 1612 | (let* ((nc (reftex-index-select-phrases-macro 0)) | ||
| 1613 | (macro-data (assoc nc reftex-index-phrases-macro-data)) | ||
| 1614 | macro-fmt repeat) | ||
| 1615 | (cond (macro-data) | ||
| 1616 | ((equal nc ?\ ) | ||
| 1617 | (setq nc "" | ||
| 1618 | macro-data (car reftex-index-phrases-macro-data))) | ||
| 1619 | ((equal nc ?\C-m) | ||
| 1620 | (setq nc (char-after (point))) | ||
| 1621 | (if (equal nc ?\t) | ||
| 1622 | (setq nc "" | ||
| 1623 | macro-data (car reftex-index-phrases-macro-data)) | ||
| 1624 | (setq macro-data (assoc nc reftex-index-phrases-macro-data)))) | ||
| 1625 | (t (error "No macro associated with %c" nc))) | ||
| 1626 | |||
| 1627 | (setq macro-fmt (nth 1 macro-data) | ||
| 1628 | repeat (nth 2 macro-data)) | ||
| 1629 | (if macro-data | ||
| 1630 | (progn | ||
| 1631 | (if (looking-at "[^\t]") (delete-char 1)) | ||
| 1632 | (insert nc) | ||
| 1633 | (message "Line will use %s %s repeat" macro-fmt | ||
| 1634 | (if repeat "with" "without"))) | ||
| 1635 | (error "Abort"))))) | ||
| 1636 | |||
| 1637 | (defun reftex-index-sort-phrases (&optional chars-first) | ||
| 1638 | "Sort the phrases lines in the buffer alphabetically. | ||
| 1639 | Normally, this looks only at the phrases. With a prefix arg CHARS-FIRST, | ||
| 1640 | it first compares the macro identifying chars and then the phrases." | ||
| 1641 | (interactive "P") | ||
| 1642 | ;; Remember the current line, so that we can return | ||
| 1643 | (let ((line (buffer-substring (progn (beginning-of-line) (point)) | ||
| 1644 | (progn (end-of-line) (point)))) | ||
| 1645 | beg end) | ||
| 1646 | (goto-char (point-min)) | ||
| 1647 | ;; Find first and last phrase line in buffer | ||
| 1648 | (setq beg | ||
| 1649 | (and (re-search-forward reftex-index-phrases-phrase-regexp12 nil t) | ||
| 1650 | (match-beginning 0))) | ||
| 1651 | (goto-char (point-max)) | ||
| 1652 | (setq end (re-search-backward reftex-index-phrases-phrase-regexp12 nil t)) | ||
| 1653 | (if end (setq end (progn (goto-char end) (end-of-line) (point)))) | ||
| 1654 | ;; Take the lines, sort them and re-insert. | ||
| 1655 | (if (and beg end) | ||
| 1656 | (progn | ||
| 1657 | (message "Sorting lines...") | ||
| 1658 | (let* ((lines (split-string (buffer-substring beg end) "\n")) | ||
| 1659 | (lines1 (sort lines 'reftex-compare-phrase-lines))) | ||
| 1660 | (message "Sorting lines...done") | ||
| 1661 | (let ((inhibit-quit t)) ;; make sure we do not loose lines | ||
| 1662 | (delete-region beg end) | ||
| 1663 | (insert (mapconcat 'identity lines1 "\n")))) | ||
| 1664 | (goto-char (point-max)) | ||
| 1665 | (re-search-backward (concat "^" (regexp-quote line) "$") nil t)) | ||
| 1666 | (error "Cannot find phrases lines to sort")))) | ||
| 1667 | |||
| 1668 | (defvar chars-first) | ||
| 1669 | (defun reftex-compare-phrase-lines (a b) | ||
| 1670 | "The comparison function used for sorting." | ||
| 1671 | (let (ca cb pa pb c-p p-p) | ||
| 1672 | (if (string-match reftex-index-phrases-phrase-regexp12 a) | ||
| 1673 | (progn | ||
| 1674 | ;; Extract macro char and phrase-or-key for a | ||
| 1675 | (setq ca (match-string 1 a) | ||
| 1676 | pa (downcase | ||
| 1677 | (or (and reftex-index-phrases-sort-prefers-entry | ||
| 1678 | (match-string 6 a)) | ||
| 1679 | (match-string 3 a)))) | ||
| 1680 | (if (string-match reftex-index-phrases-phrase-regexp12 b) | ||
| 1681 | (progn | ||
| 1682 | ;; Extract macro char and phrase-or-key for b | ||
| 1683 | (setq cb (match-string 1 b) | ||
| 1684 | pb (downcase | ||
| 1685 | (or (and reftex-index-phrases-sort-prefers-entry | ||
| 1686 | (match-string 6 b)) | ||
| 1687 | (match-string 3 b)))) | ||
| 1688 | (setq c-p (string< ca cb) | ||
| 1689 | p-p (string< pa pb)) | ||
| 1690 | ;; Do the right comparison, based on the value of `chars-first' | ||
| 1691 | ;; `chars-first' is bound locally in the calling function | ||
| 1692 | (if chars-first | ||
| 1693 | (if (string= ca cb) p-p c-p) | ||
| 1694 | (if (string= pa pb) c-p p-p))))) | ||
| 1695 | ;; If line a does not match, the answer we return determines | ||
| 1696 | ;; if non-matching lines are collected at the beginning. | ||
| 1697 | ;; When we return t here, non-matching lines form | ||
| 1698 | ;; block separators for searches. | ||
| 1699 | (not reftex-index-phrases-sort-in-blocks)))) | ||
| 1700 | |||
| 1701 | (defvar reftex-index-phrases-menu) | ||
| 1702 | (defun reftex-index-make-phrase-regexp (phrase &optional | ||
| 1703 | as-words allow-newline) | ||
| 1704 | "Return a regexp matching PHRASE, even if distributed over lines. | ||
| 1705 | With optional arg AS-WORDS, require word boundary at beginning and end. | ||
| 1706 | With optional arg ALLOW-NEWLINE, allow single newline between words." | ||
| 1707 | (let* ((words (split-string phrase)) | ||
| 1708 | (space-re (if allow-newline | ||
| 1709 | "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)" | ||
| 1710 | "\\([ \t]+\\)"))) | ||
| 1711 | (concat (if (and as-words (string-match "\\`\\w" (car words))) | ||
| 1712 | "\\<" "") | ||
| 1713 | (mapconcat (lambda (w) (regexp-quote (downcase w))) | ||
| 1714 | words space-re) | ||
| 1715 | (if (and as-words | ||
| 1716 | (string-match "\\w\\'" (nth (1- (length words)) words))) | ||
| 1717 | "\\>" "")))) | ||
| 1718 | |||
| 1719 | (defun reftex-index-simplify-phrase (phrase) | ||
| 1720 | "Make phrase single spaces and single line." | ||
| 1721 | (mapconcat 'identity (split-string phrase) " ")) | ||
| 1722 | |||
| 1723 | (defun reftex-index-phrases-find-dup-re (phrase &optional sub) | ||
| 1724 | "Return a regexp which matches variations of PHRASE (with additional space). | ||
| 1725 | When SUB ins non-nil, the regexp will also match when PHRASE is a subphrase | ||
| 1726 | of another phrase. The regexp works lonly in the phrase buffer." | ||
| 1727 | (concat (if sub "^\\S-?\t\\([^\t\n]*" "^\\S-?\t") | ||
| 1728 | (mapconcat 'regexp-quote (split-string phrase) " +") | ||
| 1729 | (if sub "[^\t\n]*\\)\\([\t\n]\\|$\\)" " *\\([\t\n]\\|$\\)"))) | ||
| 1730 | |||
| 1731 | (defun reftex-index-make-replace-string (macro-fmt match index-key | ||
| 1732 | &optional repeat mathp) | ||
| 1733 | "Return the string which can be used as replacement. | ||
| 1734 | Treats the logical `and' for index phrases." | ||
| 1735 | (let ((index-keys (split-string (or index-key match) | ||
| 1736 | reftex-index-phrases-logical-and-regexp))) | ||
| 1737 | (concat | ||
| 1738 | (mapconcat (lambda (x) | ||
| 1739 | (format macro-fmt | ||
| 1740 | (format (if mathp reftex-index-math-format "%s") x))) | ||
| 1741 | index-keys "") | ||
| 1742 | (if repeat (reftex-index-simplify-phrase match) "")))) | ||
| 1743 | |||
| 1744 | (defun reftex-query-index-phrase-globally (files &rest args) | ||
| 1745 | "Call `reftex-query-index-phrase' for all files in FILES." | ||
| 1746 | (let ((win-conf (current-window-configuration)) | ||
| 1747 | (file)) | ||
| 1748 | (unless files (error "No files")) | ||
| 1749 | (unwind-protect | ||
| 1750 | (progn | ||
| 1751 | (switch-to-buffer-other-window (reftex-get-file-buffer-force | ||
| 1752 | (car files))) | ||
| 1753 | (catch 'no-more-files | ||
| 1754 | (while (setq file (pop files)) | ||
| 1755 | (switch-to-buffer (reftex-get-file-buffer-force file)) | ||
| 1756 | (save-excursion | ||
| 1757 | (save-restriction | ||
| 1758 | (unless (stringp reftex-index-phrases-restrict-file) | ||
| 1759 | (widen)) | ||
| 1760 | (goto-char (point-min)) | ||
| 1761 | (apply 'reftex-query-index-phrase args)))))) | ||
| 1762 | (reftex-unhighlight 0) | ||
| 1763 | (set-window-configuration win-conf)))) | ||
| 1764 | |||
| 1765 | (defconst reftex-index-phrases-help | ||
| 1766 | " Keys for query-index search | ||
| 1767 | =========================== | ||
| 1768 | y Replace this match | ||
| 1769 | n Skip this match | ||
| 1770 | ! Replace this and all further matches in this file | ||
| 1771 | q / Q Skip match, start next file / start next phrase | ||
| 1772 | o Use a different indexing macro for this match | ||
| 1773 | 1 - 9 Select one of the multiple phrases | ||
| 1774 | e Edit the replacement text | ||
| 1775 | C-r Recursive edit. | ||
| 1776 | s / S Save this buffer / Save all document buffers | ||
| 1777 | C-g Abort" | ||
| 1778 | "The help string for indexing phrases.") | ||
| 1779 | |||
| 1780 | (defvar replace-count) | ||
| 1781 | (defun reftex-query-index-phrase (phrase macro-fmt &optional | ||
| 1782 | index-key repeat as-words) | ||
| 1783 | "Search through buffer for PHRASE, and offer to replace it with an indexed | ||
| 1784 | version. The index version is derived by applying `format' with MACRO-FMT | ||
| 1785 | to INDEX-KEY or PHRASE. When REPEAT is non-nil, the PHRASE is inserted | ||
| 1786 | again after the macro. | ||
| 1787 | AS-WORDS means, the search for PHRASE should require word boundaries at | ||
| 1788 | both ends." | ||
| 1789 | (let* ((re (reftex-index-make-phrase-regexp phrase as-words 'allow-newline)) | ||
| 1790 | (case-fold-search reftex-index-phrases-case-fold-search) | ||
| 1791 | (index-keys (split-string | ||
| 1792 | (or index-key phrase) | ||
| 1793 | reftex-index-phrases-logical-or-regexp)) | ||
| 1794 | (nkeys (length index-keys)) | ||
| 1795 | (ckey (nth 0 index-keys)) | ||
| 1796 | (all-yes nil) | ||
| 1797 | match rpl char beg end mathp) | ||
| 1798 | (unwind-protect | ||
| 1799 | (while (re-search-forward re nil t) | ||
| 1800 | (catch 'next-match | ||
| 1801 | (setq match (match-string 0)) | ||
| 1802 | (setq mathp | ||
| 1803 | (save-match-data | ||
| 1804 | (condition-case nil (texmathp) (error nil)))) | ||
| 1805 | (setq beg (car (match-data)) | ||
| 1806 | end (nth 1 (match-data))) | ||
| 1807 | (if (and reftex-index-phrases-skip-indexed-matches | ||
| 1808 | (save-match-data | ||
| 1809 | (reftex-index-phrase-match-is-indexed beg | ||
| 1810 | end))) | ||
| 1811 | (throw 'next-match nil)) | ||
| 1812 | (reftex-highlight 0 (match-beginning 0) (match-end 0)) | ||
| 1813 | (setq rpl | ||
| 1814 | (save-match-data | ||
| 1815 | (reftex-index-make-replace-string | ||
| 1816 | macro-fmt (match-string 0) ckey repeat mathp))) | ||
| 1817 | (while | ||
| 1818 | (not | ||
| 1819 | (catch 'loop | ||
| 1820 | (message "REPLACE: %s? (yn!qoe%s?)" | ||
| 1821 | rpl | ||
| 1822 | (if (> nkeys 1) | ||
| 1823 | (concat "1-" (int-to-string nkeys)) | ||
| 1824 | "")) | ||
| 1825 | (setq char (if all-yes ?y (read-char-exclusive))) | ||
| 1826 | (cond ((member char '(?y ?Y ?\ )) | ||
| 1827 | ;; Yes! | ||
| 1828 | (replace-match rpl t t) | ||
| 1829 | (incf replace-count) | ||
| 1830 | ;; See if we should insert newlines to shorten lines | ||
| 1831 | (and reftex-index-phrases-wrap-long-lines | ||
| 1832 | (reftex-index-phrases-fixup-line beg end)) | ||
| 1833 | (throw 'loop t)) | ||
| 1834 | ((member char '(?n ?N ?\C-h ?\C-?));; FIXME: DEL | ||
| 1835 | ;; No | ||
| 1836 | (throw 'loop t)) | ||
| 1837 | ((equal char ?!) | ||
| 1838 | ;; Yes for all in this buffer | ||
| 1839 | (setq all-yes t)) | ||
| 1840 | ((equal char ?q) | ||
| 1841 | ;; Stop this one in this file | ||
| 1842 | (goto-char (point-max)) | ||
| 1843 | (throw 'loop t)) | ||
| 1844 | ((equal char ?Q) | ||
| 1845 | ;; Stop this one | ||
| 1846 | (throw 'no-more-files t)) | ||
| 1847 | ((equal char ?s) | ||
| 1848 | (save-buffer)) | ||
| 1849 | ((equal char ?S) | ||
| 1850 | (reftex-save-all-document-buffers)) | ||
| 1851 | ((equal char ?\C-g) | ||
| 1852 | (keyboard-quit)) | ||
| 1853 | ((member char '(?o ?O)) | ||
| 1854 | ;; Select a differnt macro | ||
| 1855 | (let* ((nc (reftex-index-select-phrases-macro 2)) | ||
| 1856 | (macro-data | ||
| 1857 | (cdr (assoc nc reftex-index-phrases-macro-data))) | ||
| 1858 | (macro-fmt (car macro-data)) | ||
| 1859 | (repeat (nth 1 macro-data))) | ||
| 1860 | (if macro-data | ||
| 1861 | (setq rpl (save-match-data | ||
| 1862 | (reftex-index-make-replace-string | ||
| 1863 | macro-fmt match | ||
| 1864 | ckey repeat mathp))) | ||
| 1865 | (ding)))) | ||
| 1866 | ((equal char ?\?) | ||
| 1867 | ;; Help | ||
| 1868 | (with-output-to-temp-buffer "*Help*" | ||
| 1869 | (princ reftex-index-phrases-help))) | ||
| 1870 | ((equal char ?\C-r) | ||
| 1871 | ;; Recursive edit | ||
| 1872 | (save-match-data | ||
| 1873 | (save-excursion | ||
| 1874 | (message | ||
| 1875 | (substitute-command-keys | ||
| 1876 | "Recursive edit. Resume with \\[exit-recursive-edit]")) | ||
| 1877 | (recursive-edit)))) | ||
| 1878 | ((equal char ?e) | ||
| 1879 | (setq rpl (read-string "Edit: " rpl))) | ||
| 1880 | ((equal char ?0) | ||
| 1881 | (setq ckey (or index-key phrase) | ||
| 1882 | rpl (save-match-data | ||
| 1883 | (reftex-index-make-replace-string | ||
| 1884 | macro-fmt match ckey repeat mathp)))) | ||
| 1885 | ((and (> char ?0) | ||
| 1886 | (<= char (+ ?0 nkeys))) | ||
| 1887 | (setq ckey (nth (1- (- char ?0)) index-keys) | ||
| 1888 | rpl (save-match-data | ||
| 1889 | (reftex-index-make-replace-string | ||
| 1890 | macro-fmt match ckey repeat mathp)))) | ||
| 1891 | (t (ding))) | ||
| 1892 | nil))))) | ||
| 1893 | (message "") | ||
| 1894 | (setq all-yes nil) | ||
| 1895 | (reftex-unhighlight 0)))) | ||
| 1896 | |||
| 1897 | (defun reftex-index-phrase-match-is-indexed (beg end) | ||
| 1898 | (save-excursion | ||
| 1899 | (goto-char end) | ||
| 1900 | (let* ((this-macro (car (reftex-what-macro 1))) | ||
| 1901 | (before-char (char-before beg)) | ||
| 1902 | (after-char (char-after end)) | ||
| 1903 | (before-macro | ||
| 1904 | (and (> beg 2) | ||
| 1905 | (goto-char (1- beg)) | ||
| 1906 | (memq (char-after (point)) '(?\] ?\})) | ||
| 1907 | (car (reftex-what-macro 1)))) | ||
| 1908 | (after-macro | ||
| 1909 | (and (goto-char end) | ||
| 1910 | (looking-at "\\(\\\\[a-zA-Z]+\\*?\\)[[{]") | ||
| 1911 | (match-string 1)))) | ||
| 1912 | (or (and this-macro | ||
| 1913 | (member before-char '(?\{ ?\[)) | ||
| 1914 | (member after-char '(?\} ?\])) | ||
| 1915 | (member this-macro reftex-macros-with-index)) | ||
| 1916 | (and before-macro | ||
| 1917 | (member before-macro reftex-macros-with-index)) | ||
| 1918 | (and after-macro | ||
| 1919 | (member after-macro reftex-macros-with-index)))))) | ||
| 1920 | |||
| 1921 | |||
| 1922 | (defun reftex-index-phrases-fixup-line (beg end) | ||
| 1923 | "Insert newlines before BEG and/or after END to shorten line." | ||
| 1924 | (let (bol eol space1 space2) | ||
| 1925 | (save-excursion | ||
| 1926 | ;; Find line boundaries and possible line breaks near BEG and END | ||
| 1927 | (beginning-of-line) | ||
| 1928 | (setq bol (point)) | ||
| 1929 | (end-of-line) | ||
| 1930 | (setq eol (point)) | ||
| 1931 | (goto-char beg) | ||
| 1932 | (skip-chars-backward "^ \n") | ||
| 1933 | (if (and (equal (preceding-char) ?\ ) | ||
| 1934 | (string-match "\\S-" (buffer-substring bol (point)))) | ||
| 1935 | (setq space1 (1- (point)))) | ||
| 1936 | (goto-char end) | ||
| 1937 | (skip-chars-forward "^ \n") | ||
| 1938 | (if (and (equal (following-char) ?\ ) | ||
| 1939 | (string-match "\\S-" (buffer-substring (point) eol))) | ||
| 1940 | (setq space2 (point))) | ||
| 1941 | ;; Now check what we have and insert the newlines | ||
| 1942 | (if (<= (- eol bol) fill-column) | ||
| 1943 | ;; Line is already short | ||
| 1944 | nil | ||
| 1945 | (cond | ||
| 1946 | ((and (not space1) (not space2))) ; No spaces available | ||
| 1947 | ((not space2) ; Do space1 | ||
| 1948 | (reftex-index-phrases-replace-space space1)) | ||
| 1949 | ((not space1) ; Do space2 | ||
| 1950 | (reftex-index-phrases-replace-space space2)) | ||
| 1951 | (t ; We have both spaces | ||
| 1952 | (let ((l1 (- space1 bol)) | ||
| 1953 | (l2 (- space2 space1)) | ||
| 1954 | (l3 (- eol space2))) | ||
| 1955 | (if (> l2 fill-column) | ||
| 1956 | ;; The central part alone is more than one line | ||
| 1957 | (progn | ||
| 1958 | (reftex-index-phrases-replace-space space1) | ||
| 1959 | (reftex-index-phrases-replace-space space2)) | ||
| 1960 | (if (> (+ l1 l2) fill-column) | ||
| 1961 | ;; Need to split beginning | ||
| 1962 | (reftex-index-phrases-replace-space space1)) | ||
| 1963 | (if (> (+ l2 l3) fill-column) | ||
| 1964 | ;; Need to split end | ||
| 1965 | (reftex-index-phrases-replace-space space2)))))))))) | ||
| 1966 | |||
| 1967 | (defun reftex-index-phrases-replace-space (pos) | ||
| 1968 | "If there is a space at POS, replace it with a newline char. | ||
| 1969 | Does not do a save-excursion." | ||
| 1970 | (when (equal (char-after pos) ?\ ) | ||
| 1971 | (goto-char pos) | ||
| 1972 | (delete-char 1) | ||
| 1973 | (insert "\n"))) | ||
| 1974 | |||
| 1975 | (defun reftex-index-select-phrases-macro (&optional delay) | ||
| 1976 | "Offer a list of possible index macros and have the user select one." | ||
| 1977 | (let* ((prompt (concat "Select macro: [" | ||
| 1978 | (mapconcat (lambda (x) (char-to-string (car x))) | ||
| 1979 | reftex-index-phrases-macro-data "") | ||
| 1980 | "] ")) | ||
| 1981 | (help (concat "Select an indexing macro\n========================\n" | ||
| 1982 | (mapconcat (lambda (x) | ||
| 1983 | (format " [%c] %s" | ||
| 1984 | (car x) (nth 1 x))) | ||
| 1985 | reftex-index-phrases-macro-data "\n")))) | ||
| 1986 | (reftex-select-with-char prompt help delay))) | ||
| 1987 | |||
| 1988 | ;; Keybindings and Menu for phrases buffer | ||
| 1989 | |||
| 1990 | (loop for x in | ||
| 1991 | '(("\C-c\C-c" . reftex-index-phrases-save-and-return) | ||
| 1992 | ("\C-c\C-x" . reftex-index-this-phrase) | ||
| 1993 | ("\C-c\C-f" . reftex-index-next-phrase) | ||
| 1994 | ("\C-c\C-r" . reftex-index-region-phrases) | ||
| 1995 | ("\C-c\C-a" . reftex-index-all-phrases) | ||
| 1996 | ("\C-c\C-d" . reftex-index-remaining-phrases) | ||
| 1997 | ("\C-c\C-s" . reftex-index-sort-phrases) | ||
| 1998 | ("\C-c\C-n" . reftex-index-new-phrase) | ||
| 1999 | ("\C-c\C-m" . reftex-index-phrases-set-macro-key) | ||
| 2000 | ("\C-c\C-i" . reftex-index-phrases-info) | ||
| 2001 | ("\C-c\C-t" . reftex-index-find-next-conflict-phrase) | ||
| 2002 | ("\C-i" . self-insert-command)) | ||
| 2003 | do (define-key reftex-index-phrases-map (car x) (cdr x))) | ||
| 2004 | |||
| 2005 | (easy-menu-define | ||
| 2006 | reftex-index-phrases-menu reftex-index-phrases-map | ||
| 2007 | "Menu for Phrases buffer" | ||
| 2008 | '("Phrases" | ||
| 2009 | ["New Phrase" reftex-index-new-phrase t] | ||
| 2010 | ["Set Phrase Macro" reftex-index-phrases-set-macro-key t] | ||
| 2011 | ["Recreate File Header" reftex-index-initialize-phrases-buffer t] | ||
| 2012 | "--" | ||
| 2013 | ("Sort Phrases" | ||
| 2014 | ["Sort" reftex-index-sort-phrases t] | ||
| 2015 | "--" | ||
| 2016 | "Sort Options" | ||
| 2017 | ["by Search Phrase" (setq reftex-index-phrases-sort-prefers-entry nil) | ||
| 2018 | :style radio :selected (not reftex-index-phrases-sort-prefers-entry)] | ||
| 2019 | ["by Index Entry" (setq reftex-index-phrases-sort-prefers-entry t) | ||
| 2020 | :style radio :selected reftex-index-phrases-sort-prefers-entry] | ||
| 2021 | ["in Blocks" (setq reftex-index-phrases-sort-in-blocks | ||
| 2022 | (not reftex-index-phrases-sort-in-blocks)) | ||
| 2023 | :style toggle :selected reftex-index-phrases-sort-in-blocks]) | ||
| 2024 | ["Describe Phrase" reftex-index-phrases-info t] | ||
| 2025 | ["Next Phrase Conflict" reftex-index-find-next-conflict-phrase t] | ||
| 2026 | "--" | ||
| 2027 | ("Find and Index in Document" | ||
| 2028 | ["Current Phrase" reftex-index-this-phrase t] | ||
| 2029 | ["Next Phrase" reftex-index-next-phrase t] | ||
| 2030 | ["Current and Following" reftex-index-remaining-phrases t] | ||
| 2031 | ["Region Phrases" reftex-index-region-phrases t] | ||
| 2032 | ["All Phrases" reftex-index-all-phrases t] | ||
| 2033 | "--" | ||
| 2034 | "Options" | ||
| 2035 | ["Match Whole Words" (setq reftex-index-phrases-search-whole-words | ||
| 2036 | (not reftex-index-phrases-search-whole-words)) | ||
| 2037 | :style toggle :selected reftex-index-phrases-search-whole-words] | ||
| 2038 | ["Case Sensitive Search" (setq reftex-index-phrases-case-fold-search | ||
| 2039 | (not reftex-index-phrases-case-fold-search)) | ||
| 2040 | :style toggle :selected (not | ||
| 2041 | reftex-index-phrases-case-fold-search)] | ||
| 2042 | ["Wrap Long Lines" (setq reftex-index-phrases-wrap-long-lines | ||
| 2043 | (not reftex-index-phrases-wrap-long-lines)) | ||
| 2044 | :style toggle :selected reftex-index-phrases-wrap-long-lines] | ||
| 2045 | ["Skip Indexed Matches" (setq reftex-index-phrases-skip-indexed-matches | ||
| 2046 | (not reftex-index-phrases-skip-indexed-matches)) | ||
| 2047 | :style toggle :selected reftex-index-phrases-skip-indexed-matches]) | ||
| 2048 | "--" | ||
| 2049 | ["Save and Return" reftex-index-phrases-save-and-return t])) | ||
| 2050 | |||
| 2051 | |||
| 1220 | ;;; reftex-index.el ends here | 2052 | ;;; reftex-index.el ends here |
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index a6570bcc6cb..f38a02425aa 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-parse.el - Parser Functions for RefTeX | 1 | ;;; reftex-parse.el - Parser Functions for RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-parse) | 7 | (provide 'reftex-parse) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | 9 | ||
| @@ -216,16 +217,18 @@ of master file." | |||
| 216 | 217 | ||
| 217 | ;; Insert in List | 218 | ;; Insert in List |
| 218 | (setq toc-entry (reftex-section-info file)) | 219 | (setq toc-entry (reftex-section-info file)) |
| 219 | (setq level (nth 5 toc-entry)) | 220 | (when toc-entry |
| 220 | (setq highest-level (min highest-level level)) | 221 | ;; It can happen that section info returns nil |
| 221 | (if (= level highest-level) | 222 | (setq level (nth 5 toc-entry)) |
| 222 | (message | 223 | (setq highest-level (min highest-level level)) |
| 223 | "Scanning %s %s ..." | 224 | (if (= level highest-level) |
| 224 | (car (rassoc level reftex-section-levels-all)) | 225 | (message |
| 225 | (nth 6 toc-entry))) | 226 | "Scanning %s %s ..." |
| 226 | 227 | (car (rassoc level reftex-section-levels-all)) | |
| 227 | (push toc-entry docstruct) | 228 | (nth 6 toc-entry))) |
| 228 | (setq reftex-active-toc toc-entry)) | 229 | |
| 230 | (push toc-entry docstruct) | ||
| 231 | (setq reftex-active-toc toc-entry))) | ||
| 229 | 232 | ||
| 230 | ((match-end 7) | 233 | ((match-end 7) |
| 231 | ;; It's an include or input | 234 | ;; It's an include or input |
| @@ -355,6 +358,9 @@ of master file." | |||
| 355 | ;; Carefull: This function expects the match-data to be still in place! | 358 | ;; Carefull: This function expects the match-data to be still in place! |
| 356 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) | 359 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) |
| 357 | (macro (reftex-match-string 3)) | 360 | (macro (reftex-match-string 3)) |
| 361 | (prefix (save-match-data | ||
| 362 | (if (string-match "begin{\\([^}]+\\)}" macro) | ||
| 363 | (match-string 1 macro)))) | ||
| 358 | (level-exp (cdr (assoc macro reftex-section-levels-all))) | 364 | (level-exp (cdr (assoc macro reftex-section-levels-all))) |
| 359 | (level (if (symbolp level-exp) | 365 | (level (if (symbolp level-exp) |
| 360 | (save-match-data (funcall level-exp)) | 366 | (save-match-data (funcall level-exp)) |
| @@ -363,7 +369,9 @@ of master file." | |||
| 363 | (unnumbered (or star (< level 0))) | 369 | (unnumbered (or star (< level 0))) |
| 364 | (level (abs level)) | 370 | (level (abs level)) |
| 365 | (section-number (reftex-section-number level unnumbered)) | 371 | (section-number (reftex-section-number level unnumbered)) |
| 366 | (text1 (save-match-data (save-excursion (reftex-context-substring)))) | 372 | (text1 (save-match-data |
| 373 | (save-excursion | ||
| 374 | (reftex-context-substring prefix)))) | ||
| 367 | (literal (buffer-substring-no-properties | 375 | (literal (buffer-substring-no-properties |
| 368 | (1- (match-beginning 3)) | 376 | (1- (match-beginning 3)) |
| 369 | (min (point-max) (+ (match-end 0) (length text1) 1)))) | 377 | (min (point-max) (+ (match-end 0) (length text1) 1)))) |
| @@ -376,6 +384,7 @@ of master file." | |||
| 376 | (make-string (* reftex-level-indent level) ?\ ) | 384 | (make-string (* reftex-level-indent level) ?\ ) |
| 377 | (if (nth 1 reftex-label-menu-flags) ; section number flag | 385 | (if (nth 1 reftex-label-menu-flags) ; section number flag |
| 378 | (concat section-number " ")) | 386 | (concat section-number " ")) |
| 387 | (if prefix (concat (capitalize prefix) ": ") "") | ||
| 379 | text)) | 388 | text)) |
| 380 | (list 'toc "toc" text file marker level section-number | 389 | (list 'toc "toc" text file marker level section-number |
| 381 | literal (marker-position marker)))) | 390 | literal (marker-position marker)))) |
| @@ -908,10 +917,20 @@ of master file." | |||
| 908 | (forward-list 1)) | 917 | (forward-list 1)) |
| 909 | (error nil))) | 918 | (error nil))) |
| 910 | 919 | ||
| 911 | (defun reftex-context-substring () | 920 | (defun reftex-context-substring (&optional to-end) |
| 912 | ;; Return up to 150 chars from point | 921 | ;; Return up to 150 chars from point |
| 913 | ;; When point is just after a { or [, limit string to matching parenthesis | 922 | ;; When point is just after a { or [, limit string to matching parenthesis |
| 914 | (cond | 923 | (cond |
| 924 | (to-end | ||
| 925 | ;; Environment - find next \end | ||
| 926 | (buffer-substring-no-properties | ||
| 927 | (point) | ||
| 928 | (min (+ (point) 150) | ||
| 929 | (save-match-data | ||
| 930 | ;; FIXME: THis is not perfect | ||
| 931 | (if (re-search-forward "\\\\end{" nil t) | ||
| 932 | (match-beginning 0) | ||
| 933 | (point-max)))))) | ||
| 915 | ((or (= (preceding-char) ?\{) | 934 | ((or (= (preceding-char) ?\{) |
| 916 | (= (preceding-char) ?\[)) | 935 | (= (preceding-char) ?\[)) |
| 917 | ;; Inside a list - get only the list. | 936 | ;; Inside a list - get only the list. |
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index dc0ff9b1be3..5c9e8450544 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-ref.el - Code to create labels and references with RefTeX | 1 | ;;; reftex-ref.el - Code to create labels and references with RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-ref) | 7 | (provide 'reftex-ref) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -561,9 +562,12 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 561 | (setq here-I-am here-I-am1) | 562 | (setq here-I-am here-I-am1) |
| 562 | (setq typekey (reftex-query-label-type))) | 563 | (setq typekey (reftex-query-label-type))) |
| 563 | ((eq key ?t) | 564 | ((eq key ?t) |
| 564 | ;; toggle table of contents display | 565 | ;; toggle table of contents display, or change depth |
| 565 | (reftex-erase-buffer) | 566 | (reftex-erase-buffer) |
| 566 | (setq toc (not toc))) | 567 | (if current-prefix-arg |
| 568 | (setq reftex-toc-max-level (prefix-numeric-value | ||
| 569 | current-prefix-arg)) | ||
| 570 | (setq toc (not toc)))) | ||
| 567 | ((eq key ?F) | 571 | ((eq key ?F) |
| 568 | ;; toggle display of included file borders | 572 | ;; toggle display of included file borders |
| 569 | (reftex-erase-buffer) | 573 | (reftex-erase-buffer) |
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el index 703abe655d0..136186f31a0 100644 --- a/lisp/textmodes/reftex-sel.el +++ b/lisp/textmodes/reftex-sel.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-sel.el - The selection modes for RefTeX | 1 | ;;; reftex-sel.el - The selection modes for RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-sel) | 7 | (provide 'reftex-sel) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -180,7 +181,8 @@ During a selection process, these are the local bindings. | |||
| 180 | 181 | ||
| 181 | ((eq (car cell) 'toc) | 182 | ((eq (car cell) 'toc) |
| 182 | ;; a table of contents entry | 183 | ;; a table of contents entry |
| 183 | (when toc | 184 | (when (and toc |
| 185 | (<= (nth 5 cell) reftex-toc-max-level)) | ||
| 184 | (if (eq offset 'attention) (setq offset cell)) | 186 | (if (eq offset 'attention) (setq offset cell)) |
| 185 | (setq reftex-active-toc cell) | 187 | (setq reftex-active-toc cell) |
| 186 | (insert (concat toc-indent (nth 2 cell) "\n")) | 188 | (insert (concat toc-indent (nth 2 cell) "\n")) |
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 9a12856cfe1..ffbf05b3296 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-toc.el - RefTeX's table of contents mode | 1 | ;;; reftex-toc.el - RefTeX's table of contents mode |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-toc) | 7 | (provide 'reftex-toc) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
| @@ -27,12 +28,16 @@ Here are all local bindings. | |||
| 27 | (use-local-map reftex-toc-map) | 28 | (use-local-map reftex-toc-map) |
| 28 | (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert) | 29 | (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert) |
| 29 | (set (make-local-variable 'reftex-toc-include-labels-indicator) "") | 30 | (set (make-local-variable 'reftex-toc-include-labels-indicator) "") |
| 30 | (set (make-local-variable 'reftex-toc-include-index-indicator) "") | 31 | (set (make-local-variable 'reftex-toc-max-level-indicator) |
| 32 | (if (= reftex-toc-max-level 100) | ||
| 33 | "ALL" | ||
| 34 | (int-to-string reftex-toc-max-level))) | ||
| 31 | (setq mode-line-format | 35 | (setq mode-line-format |
| 32 | (list "---- " 'mode-line-buffer-identification | 36 | (list "---- " 'mode-line-buffer-identification |
| 33 | " " 'global-mode-string " (" mode-name ")" | 37 | " " 'global-mode-string " (" mode-name ")" |
| 34 | " L<" 'reftex-toc-include-labels-indicator ">" | 38 | " L<" 'reftex-toc-include-labels-indicator ">" |
| 35 | " I<" 'reftex-toc-include-index-indicator ">" | 39 | " I<" 'reftex-toc-include-index-indicator ">" |
| 40 | " T<" 'reftex-toc-max-level-indicator ">" | ||
| 36 | " -%-")) | 41 | " -%-")) |
| 37 | (setq truncate-lines t) | 42 | (setq truncate-lines t) |
| 38 | (make-local-hook 'post-command-hook) | 43 | (make-local-hook 'post-command-hook) |
| @@ -49,6 +54,7 @@ Here are all local bindings. | |||
| 49 | (defvar reftex-last-window-height nil) | 54 | (defvar reftex-last-window-height nil) |
| 50 | (defvar reftex-toc-include-labels-indicator nil) | 55 | (defvar reftex-toc-include-labels-indicator nil) |
| 51 | (defvar reftex-toc-include-index-indicator nil) | 56 | (defvar reftex-toc-include-index-indicator nil) |
| 57 | (defvar reftex-toc-max-level-indicator nil) | ||
| 52 | 58 | ||
| 53 | (defvar reftex-toc-return-marker (make-marker) | 59 | (defvar reftex-toc-return-marker (make-marker) |
| 54 | "Marker which makes it possible to return from toc to old position.") | 60 | "Marker which makes it possible to return from toc to old position.") |
| @@ -63,6 +69,7 @@ RET Goto the location and hide the *toc* window (also on mouse-2). | |||
| 63 | C-c > Display Index. With prefix arg, restrict index to current section. | 69 | C-c > Display Index. With prefix arg, restrict index to current section. |
| 64 | q / k Hide/Kill *toc* buffer, return to position of reftex-toc command. | 70 | q / k Hide/Kill *toc* buffer, return to position of reftex-toc command. |
| 65 | l i c F Toggle display of [l]abels, [i]ndex, [c]ontext, [F]ile borders. | 71 | l i c F Toggle display of [l]abels, [i]ndex, [c]ontext, [F]ile borders. |
| 72 | t Change maximum toc depth (e.g. `3 t' hides levels greater than 3). | ||
| 66 | f / g Toggle follow mode on and off / Refresh *toc* buffer. | 73 | f / g Toggle follow mode on and off / Refresh *toc* buffer. |
| 67 | r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document. | 74 | r / C-u r Reparse the LaTeX document / Reparse entire LaTeX document. |
| 68 | . In other window, show position from where `reftex-toc' was called. | 75 | . In other window, show position from where `reftex-toc' was called. |
| @@ -281,6 +288,17 @@ Label context is only displayed when the labels are there as well." | |||
| 281 | (interactive) | 288 | (interactive) |
| 282 | (setq reftex-toc-include-context (not reftex-toc-include-context)) | 289 | (setq reftex-toc-include-context (not reftex-toc-include-context)) |
| 283 | (reftex-toc-revert)) | 290 | (reftex-toc-revert)) |
| 291 | (defun reftex-toc-max-level (arg) | ||
| 292 | "Set the maximum level of toc lines in this buffer to value of prefix ARG. | ||
| 293 | When no prefix is given, set the max level to a large number, so that all | ||
| 294 | levels are shown. For eaxample, to set the level to 3, type `3 m'." | ||
| 295 | (interactive "P") | ||
| 296 | (setq reftex-toc-max-level (if arg | ||
| 297 | (prefix-numeric-value arg) | ||
| 298 | 100)) | ||
| 299 | (setq reftex-toc-max-level-indicator | ||
| 300 | (if arg (int-to-string reftex-toc-max-level) "ALL")) | ||
| 301 | (reftex-toc-revert)) | ||
| 284 | (defun reftex-toc-view-line () | 302 | (defun reftex-toc-view-line () |
| 285 | "View document location in other window." | 303 | "View document location in other window." |
| 286 | (interactive) | 304 | (interactive) |
| @@ -473,7 +491,7 @@ With prefix arg 1, restrict index to the section at point." | |||
| 473 | (car | 491 | (car |
| 474 | (rassq level | 492 | (rassq level |
| 475 | reftex-section-levels-all))) | 493 | reftex-section-levels-all))) |
| 476 | "[[{]")))) | 494 | "[[{]?")))) |
| 477 | ((or (not no-revisit) | 495 | ((or (not no-revisit) |
| 478 | (reftex-get-buffer-visiting file)) | 496 | (reftex-get-buffer-visiting file)) |
| 479 | ;; Marker is lost. Use the backup method. | 497 | ;; Marker is lost. Use the backup method. |
| @@ -535,6 +553,7 @@ With prefix arg 1, restrict index to the section at point." | |||
| 535 | ("F" . reftex-toc-toggle-file-boundary) | 553 | ("F" . reftex-toc-toggle-file-boundary) |
| 536 | ("i" . reftex-toc-toggle-index) | 554 | ("i" . reftex-toc-toggle-index) |
| 537 | ("l" . reftex-toc-toggle-labels) | 555 | ("l" . reftex-toc-toggle-labels) |
| 556 | ("t" . reftex-toc-max-level) | ||
| 538 | ("c" . reftex-toc-toggle-context) | 557 | ("c" . reftex-toc-toggle-context) |
| 539 | ("%" . reftex-toc-toggle-commented) | 558 | ("%" . reftex-toc-toggle-commented) |
| 540 | ("x" . reftex-toc-external) | 559 | ("x" . reftex-toc-external) |
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 40af81b9d86..b7fa158a2fc 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-vars.el - Configuration variables for RefTeX | 1 | ;;; reftex-vars.el - Configuration variables for RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-vars) | 7 | (provide 'reftex-vars) |
| 7 | 8 | ||
| 8 | ;; Define the two constants which are needed during compilation | 9 | ;; Define the two constants which are needed during compilation |
| @@ -151,18 +152,18 @@ The following conventions are valid for all alist entries: | |||
| 151 | 152 | ||
| 152 | (defconst reftex-index-macros-builtin | 153 | (defconst reftex-index-macros-builtin |
| 153 | '((default "Default \\index and \\glossary macros" | 154 | '((default "Default \\index and \\glossary macros" |
| 154 | (("\\index{*}" "idx" ?i "" nil) | 155 | (("\\index{*}" "idx" ?i "" nil t) |
| 155 | ("\\glossary{*}" "glo" ?g "" nil))) | 156 | ("\\glossary{*}" "glo" ?g "" nil t))) |
| 156 | (multind "The multind.sty package" | 157 | (multind "The multind.sty package" |
| 157 | (("\\index{}{*}" 1 ?i "" nil))) | 158 | (("\\index{}{*}" 1 ?i "" nil t))) |
| 158 | (index "The index.sty package" | 159 | (index "The index.sty package" |
| 159 | (("\\index[]{*}" 1 ?i "" nil) | 160 | (("\\index[]{*}" 1 ?i "" nil t) |
| 160 | ("\\index*[]{*}" 1 ?I "" nil))) | 161 | ("\\index*[]{*}" 1 ?I "" nil nil))) |
| 161 | (Index-Shortcut "index.sty with \\shortindexingon" | 162 | (Index-Shortcut "index.sty with \\shortindexingon" |
| 162 | (("\\index[]{*}" 1 ?i "" nil) | 163 | (("\\index[]{*}" 1 ?i "" nil t) |
| 163 | ("\\index*[]{*}" 1 ?I "" nil) | 164 | ("\\index*[]{*}" 1 ?I "" nil nil) |
| 164 | ("^[]{*}" 1 ?^ "" texmathp) | 165 | ("^[]{*}" 1 ?^ "" texmathp t) |
| 165 | ("_[]{*}" 1 ?_ "" texmathp)))) | 166 | ("_[]{*}" 1 ?_ "" texmathp nil)))) |
| 166 | "Builtin stuff for reftex-index-macros. | 167 | "Builtin stuff for reftex-index-macros. |
| 167 | Lower-case symbols correspond to a style file of the same name in the LaTeX | 168 | Lower-case symbols correspond to a style file of the same name in the LaTeX |
| 168 | distribution. Mixed-case symbols are convenience aliases.") | 169 | distribution. Mixed-case symbols are convenience aliases.") |
| @@ -186,6 +187,14 @@ distribution. Mixed-case symbols are convenience aliases.") | |||
| 186 | "A multifile table of contents browser." | 187 | "A multifile table of contents browser." |
| 187 | :group 'reftex) | 188 | :group 'reftex) |
| 188 | 189 | ||
| 190 | (defcustom reftex-toc-max-level 100 | ||
| 191 | "*The maximum level of toc entries which will be included in the TOC. | ||
| 192 | Section headings with a bigger level will be ignored. In RefTeX, chapters | ||
| 193 | are level 1, sections are level 2 etc. | ||
| 194 | This variable can be changed from within the *toc* buffer with the `t' key." | ||
| 195 | :group 'reftex-table-of-contents-browser | ||
| 196 | :type 'integer) | ||
| 197 | |||
| 189 | (defcustom reftex-toc-keep-other-windows t | 198 | (defcustom reftex-toc-keep-other-windows t |
| 190 | "*Non-nil means, split the selected window to display the *toc* buffer. | 199 | "*Non-nil means, split the selected window to display the *toc* buffer. |
| 191 | This helps to keep the window configuration, but makes the *toc* small. | 200 | This helps to keep the window configuration, but makes the *toc* small. |
| @@ -284,7 +293,7 @@ The value of the variable must be a list of items. Each item is a list | |||
| 284 | itself and has the following structure: | 293 | itself and has the following structure: |
| 285 | 294 | ||
| 286 | (ENV-OR-MACRO TYPE-KEY LABEL-PREFIX REFERENCE-FORMAT CONTEXT-METHOD | 295 | (ENV-OR-MACRO TYPE-KEY LABEL-PREFIX REFERENCE-FORMAT CONTEXT-METHOD |
| 287 | (MAGIC-WORD ... )) | 296 | (MAGIC-WORD ... ) TOC-LEVEL) |
| 288 | 297 | ||
| 289 | Each list entry describes either an environment carrying a counter for use | 298 | Each list entry describes either an environment carrying a counter for use |
| 290 | with \\label and \\ref, or a LaTeX macro defining a label as (or inside) | 299 | with \\label and \\ref, or a LaTeX macro defining a label as (or inside) |
| @@ -385,6 +394,14 @@ MAGIC-WORDS | |||
| 385 | strings are interpreted as regular expressions. RefTeX will add | 394 | strings are interpreted as regular expressions. RefTeX will add |
| 386 | a \"\\\\W\" to the beginning and other stuff to the end of the regexp. | 395 | a \"\\\\W\" to the beginning and other stuff to the end of the regexp. |
| 387 | 396 | ||
| 397 | TOC-LEVEL | ||
| 398 | The integer level at which this environment should be added to the | ||
| 399 | table of contents. See also `reftex-section-levels'. A positive | ||
| 400 | value will number the entries mixed with the sectioning commands of | ||
| 401 | the same level. A negative value will make unnumbered entries. | ||
| 402 | Useful only for theorem-like environments, will be ignored for macros. | ||
| 403 | When omitted or nil, no TOC entries will be made. | ||
| 404 | |||
| 388 | If the type indicator characters of two or more entries are the same, RefTeX | 405 | If the type indicator characters of two or more entries are the same, RefTeX |
| 389 | will use | 406 | will use |
| 390 | - the first non-nil format and prefix | 407 | - the first non-nil format and prefix |
| @@ -425,7 +442,10 @@ list. However, builtin defaults should normally be set with the variable | |||
| 425 | (const :tag "Eqnarray-like" eqnarray-like) | 442 | (const :tag "Eqnarray-like" eqnarray-like) |
| 426 | (const :tag "Alignat-like" alignat-like) | 443 | (const :tag "Alignat-like" alignat-like) |
| 427 | (symbol :tag "Function" my-func)) | 444 | (symbol :tag "Function" my-func)) |
| 428 | (repeat :tag "Magic words" :extra-offset 2 (string))) | 445 | (repeat :tag "Magic words" :extra-offset 2 (string)) |
| 446 | (option (choice :tag "Make TOC entry " | ||
| 447 | (const :tag "No entry" nil) | ||
| 448 | (integer :tag "Level" :value -3)))) | ||
| 429 | (choice | 449 | (choice |
| 430 | :tag "Package" | 450 | :tag "Package" |
| 431 | :value AMSTeX | 451 | :value AMSTeX |
| @@ -982,7 +1002,7 @@ These correspond to the makeindex keywords LEVEL ENCAP ACTUAL QUOTE ESCAPE." | |||
| 982 | (defcustom reftex-index-macros nil | 1002 | (defcustom reftex-index-macros nil |
| 983 | "Macros which define index entries. The structure is | 1003 | "Macros which define index entries. The structure is |
| 984 | 1004 | ||
| 985 | (MACRO INDEX-TAG KEY PREFIX EXCLUDE) | 1005 | (MACRO INDEX-TAG KEY PREFIX EXCLUDE REPEAT) |
| 986 | 1006 | ||
| 987 | MACRO is the macro. Arguments should be denoted by empty braces like | 1007 | MACRO is the macro. Arguments should be denoted by empty braces like |
| 988 | \\index[]{*}. Use square brackets to denote optional arguments. The star | 1008 | \\index[]{*}. Use square brackets to denote optional arguments. The star |
| @@ -1004,6 +1024,11 @@ EXCLUDE can be a function. If this function exists and returns a non-nil | |||
| 1004 | value, the index entry at point is ignored. This was implemented to support | 1024 | value, the index entry at point is ignored. This was implemented to support |
| 1005 | the (deprecated) `^' and `_' shortcuts in the LaTeX2e `index' package. | 1025 | the (deprecated) `^' and `_' shortcuts in the LaTeX2e `index' package. |
| 1006 | 1026 | ||
| 1027 | REPEAT, if non-nil, means the index macro does not typeset the entry in | ||
| 1028 | the text, so that the text has to be repeated outside the index macro. | ||
| 1029 | Needed for `reftex-index-selection-or-word' and for indexing from the | ||
| 1030 | phrase buffer. | ||
| 1031 | |||
| 1007 | The final entry may also be a symbol if this entry has a association | 1032 | The final entry may also be a symbol if this entry has a association |
| 1008 | in the variable `reftex-index-macros-builtin' to specify the main | 1033 | in the variable `reftex-index-macros-builtin' to specify the main |
| 1009 | indexing package you are using. Legal values are currently | 1034 | indexing package you are using. Legal values are currently |
| @@ -1021,13 +1046,14 @@ package here." | |||
| 1021 | (repeat | 1046 | (repeat |
| 1022 | :inline t | 1047 | :inline t |
| 1023 | (list :value ("" "idx" ?a "" nil) | 1048 | (list :value ("" "idx" ?a "" nil) |
| 1024 | (string :tag "Macro with args") | 1049 | (string :tag "Macro with args") |
| 1025 | (choice :tag "Index Tag " | 1050 | (choice :tag "Index Tag " |
| 1026 | (string) | 1051 | (string) |
| 1027 | (integer :tag "Macro arg Nr" :value 1)) | 1052 | (integer :tag "Macro arg Nr" :value 1)) |
| 1028 | (character :tag "Access Key ") | 1053 | (character :tag "Access Key ") |
| 1029 | (string :tag "Key Prefix ") | 1054 | (string :tag "Key Prefix ") |
| 1030 | (symbol :tag "Exclusion hook "))) | 1055 | (symbol :tag "Exclusion hook ") |
| 1056 | (boolean :tag "Repeat Outside "))) | ||
| 1031 | (option | 1057 | (option |
| 1032 | :tag "Package:" | 1058 | :tag "Package:" |
| 1033 | (choice :tag "Package" | 1059 | (choice :tag "Package" |
| @@ -1039,25 +1065,21 @@ package here." | |||
| 1039 | (nth 0 x))) | 1065 | (nth 0 x))) |
| 1040 | reftex-index-macros-builtin))))) | 1066 | reftex-index-macros-builtin))))) |
| 1041 | 1067 | ||
| 1042 | (defcustom reftex-index-default-macro '(?i "idx" t) | 1068 | (defcustom reftex-index-default-macro '(?i "idx") |
| 1043 | "The default index macro for \\[reftex-index-selection-or-word]. | 1069 | "The default index macro for \\[reftex-index-selection-or-word]. |
| 1044 | This is a list with (MACRO-KEY DEFAULT-TAG REPEAT-WORD). | 1070 | This is a list with (MACRO-KEY DEFAULT-TAG). |
| 1045 | 1071 | ||
| 1046 | MACRO-KEY: Character identifying an index macro - see `reftex-index-macros'. | 1072 | MACRO-KEY: Character identifying an index macro - see `reftex-index-macros'. |
| 1047 | DEFAULT-TAG: This is the tag to be used if the macro requires a TAG argument. | 1073 | DEFAULT-TAG: This is the tag to be used if the macro requires a TAG argument. |
| 1048 | When this is nil and a TAG is needed, RefTeX will ask for it. | 1074 | When this is nil and a TAG is needed, RefTeX will ask for it. |
| 1049 | When this is the empty string and the TAG argument of the index | 1075 | When this is the empty string and the TAG argument of the index |
| 1050 | macro is optional, the TAG argument will be omitted. | 1076 | macro is optional, the TAG argument will be omitted." |
| 1051 | REPEAT-WORD: Non-nil means, the index macro does not typeset the entry in | ||
| 1052 | the text, so that the text has to be repeated outside the index | ||
| 1053 | macro." | ||
| 1054 | :group 'reftex-index-support | 1077 | :group 'reftex-index-support |
| 1055 | :type '(list | 1078 | :type '(list |
| 1056 | (character :tag "Character identifying default macro") | 1079 | (character :tag "Character identifying default macro") |
| 1057 | (choice :tag "Default index tag " | 1080 | (choice :tag "Default index tag " |
| 1058 | (const nil) | 1081 | (const nil) |
| 1059 | (string)) | 1082 | (string)))) |
| 1060 | (boolean :tag "Word needs to be repeated "))) | ||
| 1061 | 1083 | ||
| 1062 | (defcustom reftex-index-default-tag "idx" | 1084 | (defcustom reftex-index-default-tag "idx" |
| 1063 | "Default index tag. | 1085 | "Default index tag. |
| @@ -1085,6 +1107,80 @@ Requires the `texmathp.el' library which is part of AUCTeX." | |||
| 1085 | :group 'reftex-index-support | 1107 | :group 'reftex-index-support |
| 1086 | :type 'string) | 1108 | :type 'string) |
| 1087 | 1109 | ||
| 1110 | (defcustom reftex-index-phrases-logical-and-regexp " *&& *" | ||
| 1111 | "Regexp matching the `and' operator for index arguments in phrases file. | ||
| 1112 | When several index arguments in a phrase line are separated by this | ||
| 1113 | operator, each part will generate an index macro. So each match of | ||
| 1114 | the search phrase will produce *several* different index entries. | ||
| 1115 | |||
| 1116 | Note: make sure this does no match things which are not separators. | ||
| 1117 | This logical `and' has higher priority than the logical `or' specified in | ||
| 1118 | `reftex-index-phrases-logical-or-regexp'." | ||
| 1119 | :group 'reftex-index-support | ||
| 1120 | :type 'regexp) | ||
| 1121 | |||
| 1122 | (defcustom reftex-index-phrases-logical-or-regexp " *|| *" | ||
| 1123 | "Regexp matching the `or' operator for index arguments in phrases file. | ||
| 1124 | When several index arguments in a phrase line are separated by this | ||
| 1125 | operator, the user will be asked to select one of them at each match | ||
| 1126 | of the search phrase. The first index arg will be the default - a | ||
| 1127 | number key 1-9 must be pressed to switch to another. | ||
| 1128 | |||
| 1129 | Note: make sure this does no match things which are not separators. | ||
| 1130 | The logical `and' specified in `reftex-index-phrases-logical-or-regexp' | ||
| 1131 | has higher priority than this logical `or'." | ||
| 1132 | :group 'reftex-index-support | ||
| 1133 | :type 'regexp) | ||
| 1134 | |||
| 1135 | (defcustom reftex-index-phrases-search-whole-words t | ||
| 1136 | "*Non-nil means phrases search will look for whole words, not subwords. | ||
| 1137 | This works by requiring word boundaries at the beginning and end of | ||
| 1138 | the search string. When the search phrase already has a non-word-char | ||
| 1139 | at one of these points, no word boundary is required there." | ||
| 1140 | :group 'reftex-index-support | ||
| 1141 | :type 'boolean) | ||
| 1142 | |||
| 1143 | (defcustom reftex-index-phrases-case-fold-search t | ||
| 1144 | "*Non-nil means, searching for index phrases will ignore case." | ||
| 1145 | :group 'reftex-index-support | ||
| 1146 | :type 'boolean) | ||
| 1147 | |||
| 1148 | (defcustom reftex-index-phrases-skip-indexed-matches nil | ||
| 1149 | "*Non-nil means, skip matches which appear to be indexed already. | ||
| 1150 | When doing global indexing from the phrases buffer, searches for some | ||
| 1151 | phrases may match at places where that phrase was already indexed. In | ||
| 1152 | particular when indexing an already processed document again, this | ||
| 1153 | will even be the norm. When this variable is non-nil, RefTeX checks if | ||
| 1154 | the match is an index macro argument, or if an index macro is directly | ||
| 1155 | before or after the phrase. If that is the case, that match will | ||
| 1156 | be ignored." | ||
| 1157 | :group 'reftex-index-support | ||
| 1158 | :type 'boolean) | ||
| 1159 | |||
| 1160 | (defcustom reftex-index-phrases-wrap-long-lines nil | ||
| 1161 | "*Non-nil means, when indexing from the phrases buffer, wrap lines. | ||
| 1162 | Inserting indexing commands in a line makes the line longer - often | ||
| 1163 | so long that it does not fit onto the screen. When this variable is | ||
| 1164 | non-nil, newlines will be added as necessary before and/or after the | ||
| 1165 | indexing command to keep lines short. However, the matched text | ||
| 1166 | phrase and its index command will always end up on a single line.") | ||
| 1167 | |||
| 1168 | (defcustom reftex-index-phrases-sort-prefers-entry nil | ||
| 1169 | "*Non-nil means when sorting phrase lines, the explicit index entry is used. | ||
| 1170 | Phrase lines in the phrases buffer contain a search phrase, and | ||
| 1171 | sorting is normally based on these. Some phrase lines also have | ||
| 1172 | an explicit index argument specified. When this variable is non-nil, | ||
| 1173 | the index argument will be used for sorting." | ||
| 1174 | :group 'reftex-index-support | ||
| 1175 | :type 'boolean) | ||
| 1176 | |||
| 1177 | (defcustom reftex-index-phrases-sort-in-blocks t | ||
| 1178 | "*Non-nil means, empty and comment lines separate phrase buffer into blocks. | ||
| 1179 | Sorting will then preserve blocks, so that lines are re-arranged only | ||
| 1180 | within blocks." | ||
| 1181 | :group 'reftex-index-support | ||
| 1182 | :type 'boolean) | ||
| 1183 | |||
| 1088 | (defcustom reftex-index-section-letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 1184 | (defcustom reftex-index-section-letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 1089 | "The letters which denote sections in the index. | 1185 | "The letters which denote sections in the index. |
| 1090 | Usually these are all capital letters. Don't use any downcase letters. | 1186 | Usually these are all capital letters. Don't use any downcase letters. |
diff --git a/lisp/textmodes/reftex-vcr.el b/lisp/textmodes/reftex-vcr.el index 65442bb5931..7f56098b7ca 100644 --- a/lisp/textmodes/reftex-vcr.el +++ b/lisp/textmodes/reftex-vcr.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; reftex-vcr.el - Viewing cross references and citations with RefTeX | 1 | ;;; reftex-vcr.el - Viewing cross references and citations with RefTeX |
| 2 | ;;; Version: 4.6 | 2 | ;;; Version: 4.9 |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; See main file reftex.el for licensing information | 4 | ;;; See main file reftex.el for licensing information |
| 5 | 5 | ||
| 6 | (eval-when-compile (require 'cl)) | ||
| 6 | (provide 'reftex-vcr) | 7 | (provide 'reftex-vcr) |
| 7 | (require 'reftex) | 8 | (require 'reftex) |
| 8 | ;;; | 9 | ;;; |
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 07c1184ba54..481f4cdbe8c 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | ;; Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc. | 2 | ;; Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl> | 4 | ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl> |
| 5 | ;; Version: 4.6 | 5 | ;; Version: 4.9 |
| 6 | ;; Keywords: tex | 6 | ;; Keywords: tex |
| 7 | 7 | ||
| 8 | ;; This file is not part of GNU Emacs. | 8 | ;; This file is not part of GNU Emacs. |
| @@ -32,6 +32,7 @@ | |||
| 32 | ;; - Labels are created semi-automatically. | 32 | ;; - Labels are created semi-automatically. |
| 33 | ;; - Definition context of labels is provided when creating a reference. | 33 | ;; - Definition context of labels is provided when creating a reference. |
| 34 | ;; - Citations are simplified with efficient database lookup. | 34 | ;; - Citations are simplified with efficient database lookup. |
| 35 | ;; - Text phrases can be collected in a file, for later global indexing. | ||
| 35 | ;; - The index preview buffer helps to check and edit index entries. | 36 | ;; - The index preview buffer helps to check and edit index entries. |
| 36 | ;; | 37 | ;; |
| 37 | ;; | 38 | ;; |
| @@ -67,6 +68,43 @@ | |||
| 67 | ;; | 68 | ;; |
| 68 | ;;--------------------------------------------------------------------------- | 69 | ;;--------------------------------------------------------------------------- |
| 69 | ;; | 70 | ;; |
| 71 | ;; Introduction | ||
| 72 | ;; ************ | ||
| 73 | ;; | ||
| 74 | ;; RefTeX is a specialized package for support of labels, references, | ||
| 75 | ;; citations, and the index in LaTeX. RefTeX wraps itself round 4 LaTeX | ||
| 76 | ;; macros: `\label', `\ref', `\cite', and `\index'. Using these macros | ||
| 77 | ;; usually requires looking up different parts of the document and | ||
| 78 | ;; searching through BibTeX database files. RefTeX automates these | ||
| 79 | ;; time-consuming tasks almost entirely. It also provides functions to | ||
| 80 | ;; display the structure of a document and to move around in this | ||
| 81 | ;; structure quickly. | ||
| 82 | ;; | ||
| 83 | ;; *Note Imprint::, for information about who to contact for help, bug | ||
| 84 | ;; reports or suggestions. | ||
| 85 | ;; | ||
| 86 | ;; Environment | ||
| 87 | ;; =========== | ||
| 88 | ;; | ||
| 89 | ;; RefTeX needs to access all files which are part of a multifile | ||
| 90 | ;; document, and the BibTeX database files requested by the | ||
| 91 | ;; `\bibliography' command. To find these files, RefTeX will require a | ||
| 92 | ;; search path, i.e. a list of directories to check. Normally this list | ||
| 93 | ;; is stored in the environment variables `TEXINPUTS' and `BIBINPUTS' | ||
| 94 | ;; which are also used by RefTeX. However, on some systems these | ||
| 95 | ;; variables do not contain the full search path. If RefTeX does not work | ||
| 96 | ;; for you because it cannot find some files, read *Note Finding Files::. | ||
| 97 | ;; | ||
| 98 | ;; Entering RefTeX Mode | ||
| 99 | ;; ==================== | ||
| 100 | ;; | ||
| 101 | ;; To turn RefTeX Mode on and off in a particular buffer, use `M-x | ||
| 102 | ;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the | ||
| 103 | ;; following lines to your `.emacs' file: | ||
| 104 | ;; | ||
| 105 | ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode | ||
| 106 | ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode | ||
| 107 | ;; | ||
| 70 | ;; RefTeX in a Nutshell | 108 | ;; RefTeX in a Nutshell |
| 71 | ;; ==================== | 109 | ;; ==================== |
| 72 | ;; | 110 | ;; |
| @@ -107,7 +145,7 @@ | |||
| 107 | ;; Typing `C-c [' (`reftex-citation') will let you specify a regular | 145 | ;; Typing `C-c [' (`reftex-citation') will let you specify a regular |
| 108 | ;; expression to search in current BibTeX database files (as | 146 | ;; expression to search in current BibTeX database files (as |
| 109 | ;; specified in the `\bibliography' command) and pull out a list of | 147 | ;; specified in the `\bibliography' command) and pull out a list of |
| 110 | ;; matches for you to choose from. The list is *formatted* and | 148 | ;; matches for you to choose from. The list is _formatted_ and |
| 111 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see | 149 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see |
| 112 | ;; the variable `reftex-cite-format' if you want to insert different | 150 | ;; the variable `reftex-cite-format' if you want to insert different |
| 113 | ;; macros). | 151 | ;; macros). |
| @@ -121,21 +159,22 @@ | |||
| 121 | ;; are supported. | 159 | ;; are supported. |
| 122 | ;; | 160 | ;; |
| 123 | ;; * Creating Index Entries | 161 | ;; * Creating Index Entries |
| 124 | ;; Type `C-c /' (`reftex-index-selection-or-word') to index the | 162 | ;; To index the current selection or the word at point, type |
| 125 | ;; current selection or the word at the cursor with the default | 163 | ;; `C-c /' (`reftex-index-selection-or-word'). The default macro |
| 126 | ;; macro (see the variable `reftex-index-default-macro'). | 164 | ;; `reftex-index-default-macro' will be used. For a more |
| 127 | ;; Type `C-c <' (`reftex-index') to insert a general index macro. | 165 | ;; complex entry type `C-c <' (`reftex-index'), select any of |
| 128 | ;; RefTeX will offer a list of available macros and provide | 166 | ;; the index macros and enter the arguments with completion. |
| 129 | ;; completion for the index tag (used to identify one of | ||
| 130 | ;; multiple indices) and for the entry itself (useful with | ||
| 131 | ;; subentries). | ||
| 132 | ;; | 167 | ;; |
| 133 | ;; * Displaying the Index | 168 | ;; * The Index Phrases File (Delayed Indexing) |
| 169 | ;; Type `C-c \' (`reftex-index-phrase-selection-or-word') to add | ||
| 170 | ;; the current word or selection to a special _index phrase | ||
| 171 | ;; file_. RefTeX can later search the document for occurrences | ||
| 172 | ;; of these phrases and let you interactively index the matches. | ||
| 173 | ;; | ||
| 174 | ;; * Displaying and Editing the Index | ||
| 134 | ;; To display the compiled index in a special buffer, type `C-c | 175 | ;; To display the compiled index in a special buffer, type `C-c |
| 135 | ;; >' (`reftex-display-index'). From that buffer you can check | 176 | ;; >' (`reftex-display-index'). From that buffer you can check |
| 136 | ;; and edit all entries. The index can be restricted to those | 177 | ;; and edit all entries. |
| 137 | ;; entries defined in a single document section or in a user | ||
| 138 | ;; defined region. | ||
| 139 | ;; | 178 | ;; |
| 140 | ;; 5. Viewing Cross-References | 179 | ;; 5. Viewing Cross-References |
| 141 | ;; When point is on the KEY argument of a cross-referencing macro | 180 | ;; When point is on the KEY argument of a cross-referencing macro |
| @@ -193,9 +232,10 @@ | |||
| 193 | ;; Go ahead and use RefTeX. Use its menus until you have picked up | 232 | ;; Go ahead and use RefTeX. Use its menus until you have picked up |
| 194 | ;; the key bindings. For an overview of what you can do in each of | 233 | ;; the key bindings. For an overview of what you can do in each of |
| 195 | ;; the different special buffers, press `?'. Read the manual if you | 234 | ;; the different special buffers, press `?'. Read the manual if you |
| 196 | ;; get stuck. The first part of the manual explains in a tutorial | 235 | ;; get stuck, of if you are curious what else might be available. |
| 197 | ;; way how to use and customize RefTeX. The second part is a command | 236 | ;; The first part of the manual explains in a tutorial way how to use |
| 198 | ;; and variable reference. | 237 | ;; and customize RefTeX. The second part is a command and variable |
| 238 | ;; reference. | ||
| 199 | ;; | 239 | ;; |
| 200 | ;;--------------------------------------------------------------------------- | 240 | ;;--------------------------------------------------------------------------- |
| 201 | ;; | 241 | ;; |
| @@ -219,9 +259,10 @@ | |||
| 219 | ;; | 259 | ;; |
| 220 | ;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, | 260 | ;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, |
| 221 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann, | 261 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann, |
| 222 | ;; Adrian Lanz, Rory Molinari, Stefan Monnier, Laurent Mugnier, | 262 | ;; Frank Harrell, Adrian Lanz, Rory Molinari, Stefan Monnier, |
| 223 | ;; Sudeep Kumar Palat, Daniel Polani, Robin Socha, Richard Stanton, | 263 | ;; Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, Robin Socha, |
| 224 | ;; Allan Strand, Jan Vroonhof, Christoph Wedler, Alan Williams. | 264 | ;; Richard Stanton, Allan Strand, Jan Vroonhof, Christoph Wedler, |
| 265 | ;; Alan Williams. | ||
| 225 | ;; | 266 | ;; |
| 226 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into | 267 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into |
| 227 | ;; supporting LaTeX labels and references with an editor (which was | 268 | ;; supporting LaTeX labels and references with an editor (which was |
| @@ -259,7 +300,7 @@ | |||
| 259 | ;;; Define the formal stuff for a minor mode named RefTeX. | 300 | ;;; Define the formal stuff for a minor mode named RefTeX. |
| 260 | ;;; | 301 | ;;; |
| 261 | 302 | ||
| 262 | (defconst reftex-version "RefTeX version 4.6" | 303 | (defconst reftex-version "RefTeX version 4.9" |
| 263 | "Version string for RefTeX.") | 304 | "Version string for RefTeX.") |
| 264 | 305 | ||
| 265 | (defvar reftex-mode nil | 306 | (defvar reftex-mode nil |
| @@ -828,7 +869,7 @@ This enforces rescanning the buffer on next use." | |||
| 828 | entry env-or-mac typekeychar typekey prefix context word | 869 | entry env-or-mac typekeychar typekey prefix context word |
| 829 | fmt reffmt labelfmt wordlist qh-list macros-with-labels | 870 | fmt reffmt labelfmt wordlist qh-list macros-with-labels |
| 830 | nargs nlabel opt-args cell sum i | 871 | nargs nlabel opt-args cell sum i |
| 831 | macro verify nindex tag key) | 872 | macro verify repeat nindex tag key toc-level toc-levels) |
| 832 | 873 | ||
| 833 | (setq reftex-words-to-typekey-alist nil | 874 | (setq reftex-words-to-typekey-alist nil |
| 834 | reftex-typekey-list nil | 875 | reftex-typekey-list nil |
| @@ -856,7 +897,8 @@ This enforces rescanning the buffer on next use." | |||
| 856 | prefix (nth 1 entry) | 897 | prefix (nth 1 entry) |
| 857 | fmt (nth 2 entry) | 898 | fmt (nth 2 entry) |
| 858 | context (nth 3 entry) | 899 | context (nth 3 entry) |
| 859 | wordlist (nth 4 entry)) | 900 | wordlist (nth 4 entry) |
| 901 | toc-level (nth 5 entry)) | ||
| 860 | (if (stringp wordlist) | 902 | (if (stringp wordlist) |
| 861 | ;; This is before version 2.04 - convert to new format | 903 | ;; This is before version 2.04 - convert to new format |
| 862 | (setq wordlist (nthcdr 4 entry))) | 904 | (setq wordlist (nthcdr 4 entry))) |
| @@ -901,7 +943,11 @@ This enforces rescanning the buffer on next use." | |||
| 901 | ((string= env-or-mac "")) | 943 | ((string= env-or-mac "")) |
| 902 | ((string= env-or-mac "section")) | 944 | ((string= env-or-mac "section")) |
| 903 | (t | 945 | (t |
| 904 | (add-to-list 'reftex-label-env-list env-or-mac))))) | 946 | (add-to-list 'reftex-label-env-list env-or-mac) |
| 947 | (if toc-level | ||
| 948 | (let ((string (format "begin{%s}" env-or-mac))) | ||
| 949 | (or (assoc string toc-levels) | ||
| 950 | (push (cons string toc-level) toc-levels)))))))) | ||
| 905 | ;; Translate some special context cases | 951 | ;; Translate some special context cases |
| 906 | (when (assq context reftex-default-context-regexps) | 952 | (when (assq context reftex-default-context-regexps) |
| 907 | (setq context | 953 | (setq context |
| @@ -996,15 +1042,24 @@ This enforces rescanning the buffer on next use." | |||
| 996 | key (nth 2 entry) | 1042 | key (nth 2 entry) |
| 997 | prefix (or (nth 3 entry) "") | 1043 | prefix (or (nth 3 entry) "") |
| 998 | verify (nth 4 entry) | 1044 | verify (nth 4 entry) |
| 999 | all-index (cdr all-index)) | 1045 | ;; For repeat, we need to be compatible with older code |
| 1046 | ;; This information used to be given only for the default macro, | ||
| 1047 | ;; but later we required to have it for *every* index macro | ||
| 1048 | repeat (cond ((> (length entry) 5) (nth 5 entry)) | ||
| 1049 | ((and (eq key (car reftex-index-default-macro)) | ||
| 1050 | (> (length reftex-index-default-macro) 2)) | ||
| 1051 | ;; User has old setting - respect it | ||
| 1052 | (nth 2 reftex-index-default-macro)) | ||
| 1053 | (t t)) | ||
| 1054 | all-index (cdr all-index)) | ||
| 1000 | (let ((result (reftex-parse-args macro))) | 1055 | (let ((result (reftex-parse-args macro))) |
| 1001 | (setq macro (or (first result) macro) | 1056 | (setq macro (or (first result) macro) |
| 1002 | nargs (second result) | 1057 | nargs (second result) |
| 1003 | nindex (third result) | 1058 | nindex (third result) |
| 1004 | opt-args (fourth result)) | 1059 | opt-args (fourth result)) |
| 1005 | (unless (member macro reftex-macros-with-index) | 1060 | (unless (member macro reftex-macros-with-index) |
| 1006 | ;; 0 1 2 3 4 5 6 | 1061 | ;; 0 1 2 3 4 5 6 7 |
| 1007 | (push (list macro tag prefix verify nargs nindex opt-args) | 1062 | (push (list macro tag prefix verify nargs nindex opt-args repeat) |
| 1008 | reftex-index-macro-alist) | 1063 | reftex-index-macro-alist) |
| 1009 | (or (assoc key reftex-key-to-index-macro-alist) | 1064 | (or (assoc key reftex-key-to-index-macro-alist) |
| 1010 | (push (list key macro) reftex-key-to-index-macro-alist)) | 1065 | (push (list key macro) reftex-key-to-index-macro-alist)) |
| @@ -1030,7 +1085,8 @@ This enforces rescanning the buffer on next use." | |||
| 1030 | 1085 | ||
| 1031 | ;; Make the full list of section levels | 1086 | ;; Make the full list of section levels |
| 1032 | (setq reftex-section-levels-all | 1087 | (setq reftex-section-levels-all |
| 1033 | (append (get reftex-docstruct-symbol 'reftex-section-levels) | 1088 | (append toc-levels |
| 1089 | (get reftex-docstruct-symbol 'reftex-section-levels) | ||
| 1034 | reftex-section-levels)) | 1090 | reftex-section-levels)) |
| 1035 | 1091 | ||
| 1036 | ;; Calculate the regular expressions | 1092 | ;; Calculate the regular expressions |
| @@ -1040,7 +1096,7 @@ This enforces rescanning the buffer on next use." | |||
| 1040 | (section-re | 1096 | (section-re |
| 1041 | (concat wbol "\\\\\\(" | 1097 | (concat wbol "\\\\\\(" |
| 1042 | (mapconcat 'car reftex-section-levels-all "\\|") | 1098 | (mapconcat 'car reftex-section-levels-all "\\|") |
| 1043 | "\\)\\*?\\(\\[[^]]*\\]\\)?{")) | 1099 | "\\)\\*?\\(\\[[^]]*\\]\\)?{?")) |
| 1044 | (appendix-re (concat wbol "\\(\\\\appendix\\)")) | 1100 | (appendix-re (concat wbol "\\(\\\\appendix\\)")) |
| 1045 | (macro-re | 1101 | (macro-re |
| 1046 | (if macros-with-labels | 1102 | (if macros-with-labels |
| @@ -1581,10 +1637,14 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1581 | "Query for an index macro and insert it along with its argments." t) | 1637 | "Query for an index macro and insert it along with its argments." t) |
| 1582 | (autoload 'reftex-index-selection-or-word "reftex-index" | 1638 | (autoload 'reftex-index-selection-or-word "reftex-index" |
| 1583 | "Put selection or the word near point into the default index macro." t) | 1639 | "Put selection or the word near point into the default index macro." t) |
| 1584 | (autoload 'reftex-index-globally "reftex-index" | 1640 | (autoload 'reftex-index-phrase-selection-or-word "reftex-index" |
| 1585 | "Copy index entry at point to other occurrences of this word." t) | 1641 | "Put selection or the word near point into Index Phrases File." t) |
| 1586 | (autoload 'reftex-display-index "reftex-index" | 1642 | (autoload 'reftex-display-index "reftex-index" |
| 1587 | "Display a buffer with an index compiled from the current document." t) | 1643 | "Display a buffer with an index compiled from the current document." t) |
| 1644 | (autoload 'reftex-index-visit-phrases-buffer "reftex-index" | ||
| 1645 | "Visit the Index Phrases File." t) | ||
| 1646 | (autoload 'reftex-index-phrases-mode "reftex-index" | ||
| 1647 | "Major mode for managing the Index phrases of a LaTeX document." t) | ||
| 1588 | (autoload 'reftex-index-complete-tag "reftex-index") | 1648 | (autoload 'reftex-index-complete-tag "reftex-index") |
| 1589 | (autoload 'reftex-index-complete-key "reftex-index") | 1649 | (autoload 'reftex-index-complete-key "reftex-index") |
| 1590 | (autoload 'reftex-index-show-entry "reftex-index") | 1650 | (autoload 'reftex-index-show-entry "reftex-index") |
| @@ -1638,6 +1698,7 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1638 | (autoload 'reftex-toggle-plug-into-AUCTeX "reftex-auc" | 1698 | (autoload 'reftex-toggle-plug-into-AUCTeX "reftex-auc" |
| 1639 | "Toggle Interface between AUCTeX and RefTeX on and off." t) | 1699 | "Toggle Interface between AUCTeX and RefTeX on and off." t) |
| 1640 | (autoload 'reftex-add-label-environments "reftex-auc") | 1700 | (autoload 'reftex-add-label-environments "reftex-auc") |
| 1701 | (autoload 'reftex-add-to-label-alist "reftex-auc") | ||
| 1641 | (autoload 'reftex-add-section-levels "reftex-auc") | 1702 | (autoload 'reftex-add-section-levels "reftex-auc") |
| 1642 | (autoload 'reftex-notice-new-section "reftex-auc") | 1703 | (autoload 'reftex-notice-new-section "reftex-auc") |
| 1643 | 1704 | ||
| @@ -1702,6 +1763,11 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1702 | (progn (skip-chars-backward class) (point)) | 1763 | (progn (skip-chars-backward class) (point)) |
| 1703 | (progn (skip-chars-forward class) (point))))) | 1764 | (progn (skip-chars-forward class) (point))))) |
| 1704 | 1765 | ||
| 1766 | (defun reftex-number (n unit &optional ending) | ||
| 1767 | (if (and (integerp n) (stringp unit)) | ||
| 1768 | (format "%d %s%s" n unit (if (= n 1) "" (or ending "s"))) | ||
| 1769 | "")) | ||
| 1770 | |||
| 1705 | (defun reftex-all-assq (key list) | 1771 | (defun reftex-all-assq (key list) |
| 1706 | ;; Return a list of all associations of KEY in LIST. Comparison with eq. | 1772 | ;; Return a list of all associations of KEY in LIST. Comparison with eq. |
| 1707 | (let (rtn) | 1773 | (let (rtn) |
| @@ -2227,14 +2293,16 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2227 | 2293 | ||
| 2228 | ;; The default bindings in the mode map. | 2294 | ;; The default bindings in the mode map. |
| 2229 | (loop for x in | 2295 | (loop for x in |
| 2230 | '(("\C-c=" . reftex-toc) | 2296 | '(("\C-c=" . reftex-toc) |
| 2231 | ("\C-c(" . reftex-label) | 2297 | ("\C-c(" . reftex-label) |
| 2232 | ("\C-c)" . reftex-reference) | 2298 | ("\C-c)" . reftex-reference) |
| 2233 | ("\C-c[" . reftex-citation) | 2299 | ("\C-c[" . reftex-citation) |
| 2234 | ("\C-c<" . reftex-index) | 2300 | ("\C-c<" . reftex-index) |
| 2235 | ("\C-c>" . reftex-display-index) | 2301 | ("\C-c>" . reftex-display-index) |
| 2236 | ("\C-c/" . reftex-index-selection-or-word) | 2302 | ("\C-c/" . reftex-index-selection-or-word) |
| 2237 | ("\C-c&" . reftex-view-crossref)) | 2303 | ("\C-c\\" . reftex-index-phrase-selection-or-word) |
| 2304 | ("\C-c|" . reftex-index-visit-phrases-buffer) | ||
| 2305 | ("\C-c&" . reftex-view-crossref)) | ||
| 2238 | do (define-key reftex-mode-map (car x) (cdr x))) | 2306 | do (define-key reftex-mode-map (car x) (cdr x))) |
| 2239 | 2307 | ||
| 2240 | ;; Bind `reftex-mouse-view-crossref' only when the key is still free | 2308 | ;; Bind `reftex-mouse-view-crossref' only when the key is still free |
| @@ -2279,11 +2347,17 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2279 | ["\\label" reftex-label t] | 2347 | ["\\label" reftex-label t] |
| 2280 | ["\\ref" reftex-reference t] | 2348 | ["\\ref" reftex-reference t] |
| 2281 | ["\\cite" reftex-citation t] | 2349 | ["\\cite" reftex-citation t] |
| 2282 | ["\\index" reftex-index t] | 2350 | ("\\index" |
| 2283 | ["\\index{THIS}" reftex-index-selection-or-word t] | 2351 | ["\\index" reftex-index t] |
| 2284 | ["View Crossref" reftex-view-crossref t] | 2352 | ["\\index{THIS}" reftex-index-selection-or-word t] |
| 2353 | "--" | ||
| 2354 | ["Add THIS to Index Phrases" reftex-index-phrase-selection-or-word t] | ||
| 2355 | ["Visit Phrase Buffer" reftex-index-visit-phrases-buffer t] | ||
| 2356 | ["Apply Phrases to Region" reftex-index-phrases-apply-to-region t] | ||
| 2357 | "--" | ||
| 2358 | ["Display the Index" reftex-display-index t]) | ||
| 2285 | "--" | 2359 | "--" |
| 2286 | ["Index Buffer" reftex-display-index t] | 2360 | ["View Crossref" reftex-view-crossref t] |
| 2287 | "--" | 2361 | "--" |
| 2288 | ("Parse Document" | 2362 | ("Parse Document" |
| 2289 | ["One File" reftex-parse-one reftex-enable-partial-scans] | 2363 | ["One File" reftex-parse-one reftex-enable-partial-scans] |
| @@ -2302,8 +2376,6 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2302 | ["Change Label and Refs" reftex-change-label t] | 2376 | ["Change Label and Refs" reftex-change-label t] |
| 2303 | ["Renumber Simple Labels" reftex-renumber-simple-labels t] | 2377 | ["Renumber Simple Labels" reftex-renumber-simple-labels t] |
| 2304 | "--" | 2378 | "--" |
| 2305 | ["Index Globally" reftex-index-globally t] | ||
| 2306 | "--" | ||
| 2307 | ["Create TAGS File" reftex-create-tags-file t] | 2379 | ["Create TAGS File" reftex-create-tags-file t] |
| 2308 | "--" | 2380 | "--" |
| 2309 | ["Save Document" reftex-save-all-document-buffers t]) | 2381 | ["Save Document" reftex-save-all-document-buffers t]) |
| @@ -2408,11 +2480,12 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2408 | (require 'finder) | 2480 | (require 'finder) |
| 2409 | (finder-commentary "reftex.el")) | 2481 | (finder-commentary "reftex.el")) |
| 2410 | 2482 | ||
| 2411 | (defun reftex-info () | 2483 | (defun reftex-info (&optional node) |
| 2412 | "Read documentation for RefTeX in the info system." | 2484 | "Read documentation for RefTeX in the info system. |
| 2485 | With optional NODE, go directly to that node." | ||
| 2413 | (interactive) | 2486 | (interactive) |
| 2414 | (require 'info) | 2487 | (require 'info) |
| 2415 | (Info-goto-node "(reftex)")) | 2488 | (Info-goto-node (format "(reftex)%s" (or node "")))) |
| 2416 | 2489 | ||
| 2417 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ | 2490 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ |
| 2418 | 2491 | ||
| @@ -2431,3 +2504,4 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2431 | ;;;============================================================================ | 2504 | ;;;============================================================================ |
| 2432 | 2505 | ||
| 2433 | ;;; reftex.el ends here | 2506 | ;;; reftex.el ends here |
| 2507 | |||