diff options
| author | Carsten Dominik | 1999-01-05 09:07:29 +0000 |
|---|---|---|
| committer | Carsten Dominik | 1999-01-05 09:07:29 +0000 |
| commit | 921759ee11f81bc39e75aafbcd33528dbc92866b (patch) | |
| tree | 4e4a0ad48e4e2bc6e7d2334bd9faea183e7c8b78 | |
| parent | 0a57cf5133908a31dcdd615aad5e6c24d485ee43 (diff) | |
| download | emacs-921759ee11f81bc39e75aafbcd33528dbc92866b.tar.gz emacs-921759ee11f81bc39e75aafbcd33528dbc92866b.zip | |
(reftex-section-levels): Allow negative levels.
(reftex-section-info): Handle negative section levels.
(reftex-view-crossref-extra): New option.
(reftex-view-crossref): Generalized to work in more places.
(reftex-find-citation-regexp-format, reftex-find-reference-format,
reftex-macros-with-labels, reftex-global-search-marker): New variables.
(reftex-view-cite-locations-from-bibtex): New command.
(reftex-view-regexp-match, reftex-global-search,
reftex-global-search-continue): New functions.
(reftex-extract-bib-entries): No error for non-existing BibTeX
file, just a message.
(reftex-extract-bib-entries): Better error handling.
(reftex-select-with-char): Use `*RefTeX Select*' for selection
help and force it on current frame.
(reftex-default-bibliography): New function.
(reftex-access-parse-file): Check consistency after loading a
parse file. When inconsistent, enfore rescan.
(reftex-check-parse-consistency): New function.
(easy-menu-define): Options section drastically shortened.
| -rw-r--r-- | lisp/textmodes/reftex.el | 688 |
1 files changed, 434 insertions, 254 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 664f7be6807..6d3cc24e70e 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -67,30 +67,28 @@ | |||
| 67 | ;; | 67 | ;; |
| 68 | ;; RefTeX in a Nutshell | 68 | ;; RefTeX in a Nutshell |
| 69 | ;; ==================== | 69 | ;; ==================== |
| 70 | ;; | 70 | ;; |
| 71 | ;; 1. Table of Contents | 71 | ;; 1. Table of Contents |
| 72 | ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the | 72 | ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the |
| 73 | ;; document. From that buffer, you can jump quickly to every part of | 73 | ;; document. From that buffer, you can jump quickly to every part of |
| 74 | ;; your document. Press `?' to get help. | 74 | ;; your document. Press `?' to get help. |
| 75 | ;; | 75 | ;; |
| 76 | ;; 2. Labels and References | 76 | ;; 2. Labels and References |
| 77 | ;; RefTeX distinguishes labels for different environments. It knows | 77 | ;; RefTeX distinguishes labels for different environments. It knows |
| 78 | ;; about all standard environments (and many others), and can be | 78 | ;; about all standard environments (and many others), and can be |
| 79 | ;; configured to recognize any additional labeled environments you | 79 | ;; configured to recognize any additional labeled environments you |
| 80 | ;; have defined yourself (variable REFTEX-LABEL-ALIST). | 80 | ;; have defined yourself (variable `reftex-label-alist'). |
| 81 | ;; | 81 | ;; |
| 82 | ;; * Creating Labels | 82 | ;; Creating Labels |
| 83 | ;; Type `C-c (' (`reftex-label') to insert a label at point. RefTeX | 83 | ;; Type `C-c (' (`reftex-label') to insert a label at point. RefTeX |
| 84 | ;; will either | 84 | ;; will either |
| 85 | ;; - derive a label from context (default for section labels) | 85 | ;; - derive a label from context (default for section labels) |
| 86 | ;; - prompt for a label string (default for figures and tables) or | 86 | ;; - prompt for a label string (default for figures and tables) or |
| 87 | ;; - insert a simple label made of a prefix and a number (all other | 87 | ;; - insert a simple label made of a prefix and a number (all other |
| 88 | ;; environments) | 88 | ;; environments) |
| 89 | ;; This is configurable with the variable `reftex-insert-label-flags'. | ||
| 89 | ;; | 90 | ;; |
| 90 | ;; Which labels are created how is configurable with the variable | 91 | ;; Referencing Labels |
| 91 | ;; REFTEX-INSERT-LABEL-FLAGS. | ||
| 92 | ;; | ||
| 93 | ;; * Referencing Labels | ||
| 94 | ;; To make a reference, type `C-c )' (`reftex-reference'). This | 92 | ;; To make a reference, type `C-c )' (`reftex-reference'). This |
| 95 | ;; shows an outline of the document with all labels of a certain type | 93 | ;; shows an outline of the document with all labels of a certain type |
| 96 | ;; (figure, equation,...) and some label context. Selecting a label | 94 | ;; (figure, equation,...) and some label context. Selecting a label |
| @@ -102,20 +100,22 @@ | |||
| 102 | ;; specified in the `\bibliography' command) and pull out a list of | 100 | ;; specified in the `\bibliography' command) and pull out a list of |
| 103 | ;; matches for you to choose from. The list is *formatted* and | 101 | ;; matches for you to choose from. The list is *formatted* and |
| 104 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see | 102 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see |
| 105 | ;; also the variable REFTEX-CITE-FORMAT). | 103 | ;; variable `reftex-cite-format'). |
| 106 | ;; | 104 | ;; |
| 107 | ;; 4. Viewing Cross References | 105 | ;; 4. Viewing Cross-References |
| 108 | ;; When point is idle on the argument of a `\ref' or `\cite' macro, | 106 | ;; When point is on the KEY argument of a cross-referencing macro |
| 109 | ;; the echo area will (if it is empty) display information about the | 107 | ;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations) |
| 110 | ;; citation/cross reference. Press `C-c &' (`reftex-view-crossref'), | 108 | ;; or inside a BibTeX database entry, you can press `C-c &' |
| 111 | ;; or click with `S-mouse-2' on the macro argument to display the | 109 | ;; (`reftex-view-crossref') to display corresponding locations in the |
| 112 | ;; corresponding label definition or BibTeX database entry in another | 110 | ;; document and associated BibTeX database files. |
| 113 | ;; window. | 111 | ;; When the enclosing macro is `\cite' or `\ref' and no other message |
| 112 | ;; occupies the echo area, information about the citation or label | ||
| 113 | ;; will automatically be displayed. | ||
| 114 | ;; | 114 | ;; |
| 115 | ;; 5. Multifile Documents | 115 | ;; 5. Multifile Documents |
| 116 | ;; Multifile Documents are fully supported. RefTeX provides cross | 116 | ;; Multifile Documents are fully supported. RefTeX provides |
| 117 | ;; referencing information from all files which are part of the | 117 | ;; cross-referencing information from all parts of the document, and |
| 118 | ;; document, and across document borders (`xr.sty'). | 118 | ;; across document borders (`xr.sty'). |
| 119 | ;; | 119 | ;; |
| 120 | ;; 6. Document Parsing | 120 | ;; 6. Document Parsing |
| 121 | ;; RefTeX needs to parse the document in order to find labels and | 121 | ;; RefTeX needs to parse the document in order to find labels and |
| @@ -428,7 +428,7 @@ M-x customize-variable RET reftex-default-label-alist-entries RET." | |||
| 428 | ,@(mapcar | 428 | ,@(mapcar |
| 429 | (function | 429 | (function |
| 430 | (lambda (x) | 430 | (lambda (x) |
| 431 | (list 'const ':tag (concat (symbol-name (nth 0 x)) | 431 | (list 'const :tag (concat (symbol-name (nth 0 x)) |
| 432 | ": " (nth 1 x)) | 432 | ": " (nth 1 x)) |
| 433 | (nth 0 x)))) | 433 | (nth 0 x)))) |
| 434 | reftex-label-alist-builtin))) | 434 | reftex-label-alist-builtin))) |
| @@ -575,25 +575,29 @@ list. However, builtin defaults should normally be set with the variable | |||
| 575 | ,@(mapcar | 575 | ,@(mapcar |
| 576 | (function | 576 | (function |
| 577 | (lambda (x) | 577 | (lambda (x) |
| 578 | (list 'const ':tag (concat (symbol-name (nth 0 x))) | 578 | (list 'const :tag (concat (symbol-name (nth 0 x))) |
| 579 | (nth 0 x)))) | 579 | (nth 0 x)))) |
| 580 | reftex-label-alist-builtin))))) | 580 | reftex-label-alist-builtin))))) |
| 581 | 581 | ||
| 582 | ;; LaTeX section commands and level numbers | 582 | ;; LaTeX section commands and level numbers |
| 583 | (defcustom reftex-section-levels | 583 | (defcustom reftex-section-levels |
| 584 | '( | 584 | '( |
| 585 | ("part" . 0) | 585 | ("part" . 0) |
| 586 | ("chapter" . 1) | 586 | ("chapter" . 1) |
| 587 | ("section" . 2) | 587 | ("section" . 2) |
| 588 | ("subsection" . 3) | 588 | ("subsection" . 3) |
| 589 | ("subsubsection" . 4) | 589 | ("subsubsection" . 4) |
| 590 | ("paragraph" . 5) | 590 | ("paragraph" . 5) |
| 591 | ("subparagraph" . 6) | 591 | ("subparagraph" . 6) |
| 592 | ("subsubparagraph" . 7) | 592 | ("subsubparagraph" . 7) |
| 593 | ("addchap" . -1) ; KOMA-Script | ||
| 594 | ("addsec" . -2) ; KOMA-Script | ||
| 595 | ;;; ("minisec" . -7) ; KOMA-Script | ||
| 593 | ) | 596 | ) |
| 594 | "Commands and levels used for defining sections in the document. | 597 | "Commands and levels used for defining sections in the document. |
| 595 | The car of each cons cell is the name of the section macro. The cdr is a | 598 | The car of each cons cell is the name of the section macro. The cdr is a |
| 596 | number indicating its level." | 599 | number indicating its level. A negative level means the same as the |
| 600 | positive value, but the section will never get a number." | ||
| 597 | :group 'reftex-defining-label-environments | 601 | :group 'reftex-defining-label-environments |
| 598 | :set 'reftex-set-dirty | 602 | :set 'reftex-set-dirty |
| 599 | :type '(repeat | 603 | :type '(repeat |
| @@ -843,8 +847,9 @@ like, which are ignored by RefTeX anyway." | |||
| 843 | "*List of BibTeX database files which should be used if none are specified. | 847 | "*List of BibTeX database files which should be used if none are specified. |
| 844 | When `reftex-citation' is called from a document which has neither a | 848 | When `reftex-citation' is called from a document which has neither a |
| 845 | `\bibliography{..}' statement nor a `thebibliography' environment, | 849 | `\bibliography{..}' statement nor a `thebibliography' environment, |
| 846 | RefTeX will scan these files instead. Intended for using | 850 | RefTeX will scan these files instead. Intended for using `reftex-citation' |
| 847 | `reftex-citation' in non-LaTeX files." | 851 | in non-LaTeX files. The files will be searched along the BIBINPUTS or TEXBIB |
| 852 | path." | ||
| 848 | :group 'reftex-citation-support | 853 | :group 'reftex-citation-support |
| 849 | :type '(repeat (file))) | 854 | :type '(repeat (file))) |
| 850 | 855 | ||
| @@ -911,7 +916,7 @@ the predefined styles (see `reftex-cite-format-builtin'). E.g.: | |||
| 911 | ,@(mapcar | 916 | ,@(mapcar |
| 912 | (function | 917 | (function |
| 913 | (lambda (x) | 918 | (lambda (x) |
| 914 | (list 'const ':tag (concat (symbol-name (nth 0 x)) | 919 | (list 'const :tag (concat (symbol-name (nth 0 x)) |
| 915 | ": " (nth 1 x)) | 920 | ": " (nth 1 x)) |
| 916 | (nth 0 x)))) | 921 | (nth 0 x)))) |
| 917 | reftex-cite-format-builtin)) | 922 | reftex-cite-format-builtin)) |
| @@ -971,12 +976,31 @@ should return the string to insert into the buffer." | |||
| 971 | :group 'reftex-citation-support | 976 | :group 'reftex-citation-support |
| 972 | :type 'hook) | 977 | :type 'hook) |
| 973 | 978 | ||
| 974 | |||
| 975 | ;; Viewing Cross References and Citations | 979 | ;; Viewing Cross References and Citations |
| 976 | (defgroup reftex-viewing-cross-references-and-citations nil | 980 | (defgroup reftex-viewing-cross-references-and-citations nil |
| 977 | "Displaying cross references and citations." | 981 | "Displaying cross references and citations." |
| 978 | :group 'reftex) | 982 | :group 'reftex) |
| 979 | 983 | ||
| 984 | (defcustom reftex-view-crossref-extra | ||
| 985 | '(("index\\|idx" "\\\\[a-zA-Z]*\\(index\\|idx\\)[a-zA-Z]*\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\(%s\\)}" 3)) | ||
| 986 | "Macros which can be used for the display of cross references. | ||
| 987 | This is used when `reftex-view-crossref' is called with point in an | ||
| 988 | argument of a macro. Note that crossref viewing for citations and | ||
| 989 | references (both ways) is hard-coded. This variable is only to | ||
| 990 | configure additional structures for which crossreference viewing | ||
| 991 | can be useful. Each entry has the structure | ||
| 992 | |||
| 993 | (MACRO-RE SEARCH-RE HIGHLIGHT). | ||
| 994 | |||
| 995 | MACRO-RE is matched against the macro. SEARCH-RE is the regexp used | ||
| 996 | to search for cross references. `%s' in this regexp is replaced with | ||
| 997 | with the macro argument at point. HIGHLIGHT is an integer indicating | ||
| 998 | which subgroup of the match should be highlighted." | ||
| 999 | :group 'reftex-viewing-cross-references-and-citations | ||
| 1000 | :type '(repeat (group (regexp :tag "Macro Regexp ") | ||
| 1001 | (string :tag "Search Regexp ") | ||
| 1002 | (integer :tag "Highlight Group")))) | ||
| 1003 | |||
| 980 | (defcustom reftex-auto-view-crossref t | 1004 | (defcustom reftex-auto-view-crossref t |
| 981 | "*Non-nil means, initially turn automatic viewing of crossref info on. | 1005 | "*Non-nil means, initially turn automatic viewing of crossref info on. |
| 982 | Automatic viewing of crossref info normally uses the echo area. | 1006 | Automatic viewing of crossref info normally uses the echo area. |
| @@ -1379,7 +1403,7 @@ construct: \\bbb [xxx] {aaa}." | |||
| 1379 | ;;; Define the formal stuff for a minor mode named RefTeX. | 1403 | ;;; Define the formal stuff for a minor mode named RefTeX. |
| 1380 | ;;; | 1404 | ;;; |
| 1381 | 1405 | ||
| 1382 | (defconst reftex-version "RefTeX version 3.42" | 1406 | (defconst reftex-version "RefTeX version 3.43" |
| 1383 | "Version string for RefTeX.") | 1407 | "Version string for RefTeX.") |
| 1384 | 1408 | ||
| 1385 | (defvar reftex-mode nil | 1409 | (defvar reftex-mode nil |
| @@ -1445,8 +1469,8 @@ on the menu bar. | |||
| 1445 | (if (fboundp 'add-minor-mode) | 1469 | (if (fboundp 'add-minor-mode) |
| 1446 | ;; Use it so that we get the extras | 1470 | ;; Use it so that we get the extras |
| 1447 | (progn | 1471 | (progn |
| 1448 | (put 'reftex-mode ':included '(memq major-mode '(latex-mode tex-mode))) | 1472 | (put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode))) |
| 1449 | (put 'reftex-mode ':menu-tag "RefTeX Mode") | 1473 | (put 'reftex-mode :menu-tag "RefTeX Mode") |
| 1450 | (add-minor-mode 'reftex-mode " Ref" reftex-mode-map)) | 1474 | (add-minor-mode 'reftex-mode " Ref" reftex-mode-map)) |
| 1451 | ;; The standard way | 1475 | ;; The standard way |
| 1452 | (unless (assoc 'reftex-mode minor-mode-alist) | 1476 | (unless (assoc 'reftex-mode minor-mode-alist) |
| @@ -1518,7 +1542,7 @@ on the menu bar. | |||
| 1518 | symlist (cdr symlist) | 1542 | symlist (cdr symlist) |
| 1519 | symname (symbol-name symbol)) | 1543 | symname (symbol-name symbol)) |
| 1520 | (set symbol (intern (concat symname "-" (int-to-string index)))) | 1544 | (set symbol (intern (concat symname "-" (int-to-string index)))) |
| 1521 | (put (symbol-value symbol) ':master-index index) | 1545 | (put (symbol-value symbol) :master-index index) |
| 1522 | ;; Initialize if new symbols. | 1546 | ;; Initialize if new symbols. |
| 1523 | (if newflag (set (symbol-value symbol) nil))) | 1547 | (if newflag (set (symbol-value symbol) nil))) |
| 1524 | 1548 | ||
| @@ -1649,6 +1673,11 @@ on the menu bar. | |||
| 1649 | (defvar reftex-section-regexp nil) | 1673 | (defvar reftex-section-regexp nil) |
| 1650 | (defvar reftex-section-or-include-regexp nil) | 1674 | (defvar reftex-section-or-include-regexp nil) |
| 1651 | (defvar reftex-everything-regexp nil) | 1675 | (defvar reftex-everything-regexp nil) |
| 1676 | (defvar reftex-find-citation-regexp-format | ||
| 1677 | "\\\\[a-zA-Z]*cite[*a-zA-Z]*\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\([^}]*,\\)?\\(%s\\)[},]") | ||
| 1678 | (defvar reftex-find-reference-format | ||
| 1679 | "\\\\\\(ref[a-zA-Z]*\\|[a-zA-Z]*ref\\)\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\(%s\\)}") | ||
| 1680 | (defvar reftex-macros-with-labels nil) | ||
| 1652 | (defvar reftex-find-label-regexp-format nil) | 1681 | (defvar reftex-find-label-regexp-format nil) |
| 1653 | (defvar reftex-find-label-regexp-format2 nil) | 1682 | (defvar reftex-find-label-regexp-format2 nil) |
| 1654 | 1683 | ||
| @@ -1939,27 +1968,42 @@ on the menu bar. | |||
| 1939 | ;; Return the list | 1968 | ;; Return the list |
| 1940 | docstruct)) | 1969 | docstruct)) |
| 1941 | 1970 | ||
| 1942 | (defun reftex-locate-bibliography-files (master-dir) | 1971 | (defun reftex-locate-bibliography-files (master-dir &optional files) |
| 1943 | ;; Scan buffer for bibliography macro and return file list. | 1972 | ;; Scan buffer for bibliography macro and return file list. |
| 1944 | (let (files) | 1973 | |
| 1974 | (unless files | ||
| 1945 | (save-excursion | 1975 | (save-excursion |
| 1946 | (goto-char (point-min)) | 1976 | (goto-char (point-min)) |
| 1947 | (when (re-search-forward | 1977 | (if (re-search-forward |
| 1948 | "\\(\\`\\|[\n\r]\\)[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t) | 1978 | "\\(\\`\\|[\n\r]\\)[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t) |
| 1949 | (setq files (split-string (reftex-match-string 2) | 1979 | (setq files |
| 1950 | "[ \t\n\r]*,[ \t\n\r]*")) | 1980 | (split-string (reftex-match-string 2) |
| 1951 | (setq files | 1981 | "[ \t\n\r]*,[ \t\n\r]*"))))) |
| 1952 | (mapcar | 1982 | (when files |
| 1953 | (lambda (x) | 1983 | (setq files |
| 1954 | (if (or (member x reftex-bibfile-ignore-list) | 1984 | (mapcar |
| 1955 | (delq nil (mapcar (lambda (re) (string-match re x)) | 1985 | (lambda (x) |
| 1956 | reftex-bibfile-ignore-regexps))) | 1986 | (if (or (member x reftex-bibfile-ignore-list) |
| 1957 | ;; excluded file | 1987 | (delq nil (mapcar (lambda (re) (string-match re x)) |
| 1958 | nil | 1988 | reftex-bibfile-ignore-regexps))) |
| 1959 | ;; find the file | 1989 | ;; excluded file |
| 1960 | (reftex-locate-file x "bib" master-dir))) | 1990 | nil |
| 1961 | files)) | 1991 | ;; find the file |
| 1962 | (delq nil files))))) | 1992 | (reftex-locate-file x "bib" master-dir))) |
| 1993 | files)) | ||
| 1994 | (delq nil files))) | ||
| 1995 | |||
| 1996 | (defun reftex-default-bibliography () | ||
| 1997 | ;; Return the expanded value of `reftex-default-bibliography'. | ||
| 1998 | ;; The expanded value is cached. | ||
| 1999 | (unless (eq (get 'reftex-default-bibliography :reftex-raw) | ||
| 2000 | reftex-default-bibliography) | ||
| 2001 | (put 'reftex-default-bibliography :reftex-expanded | ||
| 2002 | (reftex-locate-bibliography-files | ||
| 2003 | default-directory reftex-default-bibliography)) | ||
| 2004 | (put 'reftex-default-bibliography :reftex-raw | ||
| 2005 | reftex-default-bibliography)) | ||
| 2006 | (get 'reftex-default-bibliography :reftex-expanded)) | ||
| 1963 | 2007 | ||
| 1964 | (defun reftex-replace-label-list-segment (old insert &optional entirely) | 2008 | (defun reftex-replace-label-list-segment (old insert &optional entirely) |
| 1965 | ;; Replace the segment in OLD which corresponds to INSERT. | 2009 | ;; Replace the segment in OLD which corresponds to INSERT. |
| @@ -2025,8 +2069,11 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2025 | (if (file-exists-p file) | 2069 | (if (file-exists-p file) |
| 2026 | ;; load the file and return t for success | 2070 | ;; load the file and return t for success |
| 2027 | (condition-case nil | 2071 | (condition-case nil |
| 2028 | (progn (load-file file) t) | 2072 | (progn |
| 2029 | (error (message "Error while loading file %s" file) | 2073 | (load-file file) |
| 2074 | (reftex-check-parse-consistency) | ||
| 2075 | t) | ||
| 2076 | (error (message "Error while restoring file %s" file) | ||
| 2030 | (set reftex-docstruct-symbol nil) | 2077 | (set reftex-docstruct-symbol nil) |
| 2031 | nil)) | 2078 | nil)) |
| 2032 | ;; return nil for failure, but no exception | 2079 | ;; return nil for failure, but no exception |
| @@ -2069,6 +2116,28 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2069 | (error "Cannot write to file %s" file))) | 2116 | (error "Cannot write to file %s" file))) |
| 2070 | t)))) | 2117 | t)))) |
| 2071 | 2118 | ||
| 2119 | (defun reftex-check-parse-consistency () | ||
| 2120 | ;; Check if parse file is consistent, throw an error if not. | ||
| 2121 | |||
| 2122 | ;; Check if the master is the same: when moving a document, this will see it. | ||
| 2123 | (let* ((real-master (reftex-TeX-master-file)) | ||
| 2124 | (parsed-master | ||
| 2125 | (nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol))))) | ||
| 2126 | (unless (string= (file-truename real-master) (file-truename parsed-master)) | ||
| 2127 | (message "Master file name in load file is different: %s versus %s" | ||
| 2128 | parsed-master real-master) | ||
| 2129 | (error "Master file name error"))) | ||
| 2130 | |||
| 2131 | ;; Check for the existence of all document files | ||
| 2132 | ;;; (let* ((all (symbol-value reftex-docstruct-symbol))) | ||
| 2133 | ;;; (while all | ||
| 2134 | ;;; (when (and (eq (car (car all)) 'bof) | ||
| 2135 | ;;; (not (file-regular-p (nth 1 (car all))))) | ||
| 2136 | ;;; (message "File %s in saved parse info not avalable" (cdr (car all))) | ||
| 2137 | ;;; (error "File not found")) | ||
| 2138 | ;;; (setq all (cdr all)))) | ||
| 2139 | ) | ||
| 2140 | |||
| 2072 | (defun reftex-kill-buffer-hook () | 2141 | (defun reftex-kill-buffer-hook () |
| 2073 | "Save RefTeX's parse file for this buffer if the information has changed." | 2142 | "Save RefTeX's parse file for this buffer if the information has changed." |
| 2074 | ;; Save the parsing information if it was modified. | 2143 | ;; Save the parsing information if it was modified. |
| @@ -2098,9 +2167,11 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2098 | ;; Carefull: This function expects the match-data to be still in place! | 2167 | ;; Carefull: This function expects the match-data to be still in place! |
| 2099 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) | 2168 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) |
| 2100 | (macro (reftex-match-string 3)) | 2169 | (macro (reftex-match-string 3)) |
| 2101 | (star (= ?* (char-after (match-end 3)))) | ||
| 2102 | (level (cdr (assoc macro reftex-section-levels-all))) | 2170 | (level (cdr (assoc macro reftex-section-levels-all))) |
| 2103 | (section-number (reftex-section-number level star)) | 2171 | (star (= ?* (char-after (match-end 3)))) |
| 2172 | (unnumbered (or star (< level 0))) | ||
| 2173 | (level (abs level)) | ||
| 2174 | (section-number (reftex-section-number level unnumbered)) | ||
| 2104 | (text1 (save-match-data (save-excursion (reftex-context-substring)))) | 2175 | (text1 (save-match-data (save-excursion (reftex-context-substring)))) |
| 2105 | (literal (buffer-substring-no-properties | 2176 | (literal (buffer-substring-no-properties |
| 2106 | (1- (match-beginning 3)) | 2177 | (1- (match-beginning 3)) |
| @@ -3187,7 +3258,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3187 | (defun reftex-make-selection-buffer-name (type &optional index) | 3258 | (defun reftex-make-selection-buffer-name (type &optional index) |
| 3188 | ;; Make unique name for a selection buffer. | 3259 | ;; Make unique name for a selection buffer. |
| 3189 | (format " *RefTeX[%s][%d]*" | 3260 | (format " *RefTeX[%s][%d]*" |
| 3190 | type (or index (get reftex-docstruct-symbol ':master-index) 0))) | 3261 | type (or index (get reftex-docstruct-symbol :master-index) 0))) |
| 3191 | 3262 | ||
| 3192 | (defun reftex-get-offset (buf here-am-I &optional typekey toc file) | 3263 | (defun reftex-get-offset (buf here-am-I &optional typekey toc file) |
| 3193 | ;; Find the correct offset data, like insert-docstruct would, but faster. | 3264 | ;; Find the correct offset data, like insert-docstruct would, but faster. |
| @@ -3299,7 +3370,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3299 | (if mouse-face | 3370 | (if mouse-face |
| 3300 | (put-text-property from (1- to) | 3371 | (put-text-property from (1- to) |
| 3301 | 'mouse-face mouse-face)) | 3372 | 'mouse-face mouse-face)) |
| 3302 | (put-text-property from to ':data cell)))) | 3373 | (put-text-property from to :data cell)))) |
| 3303 | 3374 | ||
| 3304 | ((eq (car cell) 'toc) | 3375 | ((eq (car cell) 'toc) |
| 3305 | ;; a table of contents entry | 3376 | ;; a table of contents entry |
| @@ -3315,7 +3386,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3315 | (if mouse-face | 3386 | (if mouse-face |
| 3316 | (put-text-property from (1- to) | 3387 | (put-text-property from (1- to) |
| 3317 | 'mouse-face mouse-face)) | 3388 | 'mouse-face mouse-face)) |
| 3318 | (put-text-property from to ':data cell)) | 3389 | (put-text-property from to :data cell)) |
| 3319 | (goto-char to))) | 3390 | (goto-char to))) |
| 3320 | 3391 | ||
| 3321 | ((stringp (car cell)) | 3392 | ((stringp (car cell)) |
| @@ -3360,7 +3431,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3360 | (when context | 3431 | (when context |
| 3361 | (insert context-indent text "\n") | 3432 | (insert context-indent text "\n") |
| 3362 | (setq to (point))) | 3433 | (setq to (point))) |
| 3363 | (put-text-property from to ':data cell) | 3434 | (put-text-property from to :data cell) |
| 3364 | (when mouse-face | 3435 | (when mouse-face |
| 3365 | (put-text-property from (1- to) | 3436 | (put-text-property from (1- to) |
| 3366 | 'mouse-face mouse-face)) | 3437 | 'mouse-face mouse-face)) |
| @@ -3374,7 +3445,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3374 | 3445 | ||
| 3375 | (defun reftex-find-start-point (fallback &rest locations) | 3446 | (defun reftex-find-start-point (fallback &rest locations) |
| 3376 | ;; Set point to the first available LOCATION. When a LOCATION is a list, | 3447 | ;; Set point to the first available LOCATION. When a LOCATION is a list, |
| 3377 | ;; search for such a ':data text property. When it is an integer, | 3448 | ;; search for such a :data text property. When it is an integer, |
| 3378 | ;; use is as line number. FALLBACK is a buffer position used if everything | 3449 | ;; use is as line number. FALLBACK is a buffer position used if everything |
| 3379 | ;; else fails. | 3450 | ;; else fails. |
| 3380 | (catch 'exit | 3451 | (catch 'exit |
| @@ -3385,7 +3456,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3385 | (cond | 3456 | (cond |
| 3386 | ((null loc)) | 3457 | ((null loc)) |
| 3387 | ((listp loc) | 3458 | ((listp loc) |
| 3388 | (setq pos (text-property-any (point-min) (point-max) ':data loc)) | 3459 | (setq pos (text-property-any (point-min) (point-max) :data loc)) |
| 3389 | (when pos | 3460 | (when pos |
| 3390 | (goto-char pos) | 3461 | (goto-char pos) |
| 3391 | (throw 'exit t))) | 3462 | (throw 'exit t))) |
| @@ -3464,7 +3535,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3464 | 3535 | ||
| 3465 | (defun reftex-show-entry (beg-hlt end-hlt) | 3536 | (defun reftex-show-entry (beg-hlt end-hlt) |
| 3466 | ;; Show entry if point is hidden | 3537 | ;; Show entry if point is hidden |
| 3467 | (let* ((n (/ (window-height) 2)) | 3538 | (let* ((n (/ (reftex-window-height) 2)) |
| 3468 | (beg (save-excursion | 3539 | (beg (save-excursion |
| 3469 | (re-search-backward "[\n\r]" nil 1 n) (point))) | 3540 | (re-search-backward "[\n\r]" nil 1 n) (point))) |
| 3470 | (end (save-excursion | 3541 | (end (save-excursion |
| @@ -3582,7 +3653,7 @@ When called with a raw C-u prefix, rescan the document first." | |||
| 3582 | (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol))) | 3653 | (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol))) |
| 3583 | (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) | 3654 | (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) |
| 3584 | (here-I-am (if rebuild | 3655 | (here-I-am (if rebuild |
| 3585 | (get 'reftex-toc ':reftex-data) | 3656 | (get 'reftex-toc :reftex-data) |
| 3586 | (car (reftex-where-am-I)))) | 3657 | (car (reftex-where-am-I)))) |
| 3587 | offset) | 3658 | offset) |
| 3588 | 3659 | ||
| @@ -3640,12 +3711,12 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |||
| 3640 | (reftex-last-assoc-before-elt | 3711 | (reftex-last-assoc-before-elt |
| 3641 | 'toc here-I-am | 3712 | 'toc here-I-am |
| 3642 | (symbol-value reftex-docstruct-symbol)))) | 3713 | (symbol-value reftex-docstruct-symbol)))) |
| 3643 | (put 'reftex-toc ':reftex-line 3) | 3714 | (put 'reftex-toc :reftex-line 3) |
| 3644 | (goto-line 3) | 3715 | (goto-line 3) |
| 3645 | (beginning-of-line))) | 3716 | (beginning-of-line))) |
| 3646 | 3717 | ||
| 3647 | ;; Find the correct starting point | 3718 | ;; Find the correct starting point |
| 3648 | (reftex-find-start-point (point) offset (get 'reftex-toc ':reftex-line)) | 3719 | (reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line)) |
| 3649 | (setq reftex-last-follow-point (point)))) | 3720 | (setq reftex-last-follow-point (point)))) |
| 3650 | 3721 | ||
| 3651 | (defun reftex-toc-pre-command-hook () | 3722 | (defun reftex-toc-pre-command-hook () |
| @@ -3655,15 +3726,15 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |||
| 3655 | 3726 | ||
| 3656 | (defun reftex-toc-post-command-hook () | 3727 | (defun reftex-toc-post-command-hook () |
| 3657 | ;; used in the post-command-hook for the *toc* buffer | 3728 | ;; used in the post-command-hook for the *toc* buffer |
| 3658 | (when (get-text-property (point) ':data) | 3729 | (when (get-text-property (point) :data) |
| 3659 | (put 'reftex-toc ':reftex-data (get-text-property (point) ':data)) | 3730 | (put 'reftex-toc :reftex-data (get-text-property (point) :data)) |
| 3660 | (and (> (point) 1) | 3731 | (and (> (point) 1) |
| 3661 | (not (get-text-property (point) 'intangible)) | 3732 | (not (get-text-property (point) 'intangible)) |
| 3662 | (memq reftex-highlight-selection '(cursor both)) | 3733 | (memq reftex-highlight-selection '(cursor both)) |
| 3663 | (reftex-highlight 1 | 3734 | (reftex-highlight 1 |
| 3664 | (or (previous-single-property-change (1+ (point)) ':data) | 3735 | (or (previous-single-property-change (1+ (point)) :data) |
| 3665 | (point-min)) | 3736 | (point-min)) |
| 3666 | (or (next-single-property-change (point) ':data) | 3737 | (or (next-single-property-change (point) :data) |
| 3667 | (point-max))))) | 3738 | (point-max))))) |
| 3668 | (if (integerp reftex-toc-follow-mode) | 3739 | (if (integerp reftex-toc-follow-mode) |
| 3669 | ;; remove delayed action | 3740 | ;; remove delayed action |
| @@ -3696,13 +3767,13 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help | |||
| 3696 | (interactive "p") | 3767 | (interactive "p") |
| 3697 | (setq reftex-callback-fwd t) | 3768 | (setq reftex-callback-fwd t) |
| 3698 | (or (eobp) (forward-char 1)) | 3769 | (or (eobp) (forward-char 1)) |
| 3699 | (goto-char (or (next-single-property-change (point) ':data) | 3770 | (goto-char (or (next-single-property-change (point) :data) |
| 3700 | (point)))) | 3771 | (point)))) |
| 3701 | (defun reftex-toc-previous (&optional arg) | 3772 | (defun reftex-toc-previous (&optional arg) |
| 3702 | "Move to previous selectable item." | 3773 | "Move to previous selectable item." |
| 3703 | (interactive "p") | 3774 | (interactive "p") |
| 3704 | (setq reftex-callback-fwd nil) | 3775 | (setq reftex-callback-fwd nil) |
| 3705 | (goto-char (or (previous-single-property-change (point) ':data) | 3776 | (goto-char (or (previous-single-property-change (point) :data) |
| 3706 | (point)))) | 3777 | (point)))) |
| 3707 | (defun reftex-toc-toggle-follow () | 3778 | (defun reftex-toc-toggle-follow () |
| 3708 | "Toggle follow (other window follows with context)." | 3779 | "Toggle follow (other window follows with context)." |
| @@ -3778,7 +3849,7 @@ Label context is only displayed when the labels are there as well." | |||
| 3778 | "Regenerate the *toc* buffer by reparsing file of section at point." | 3849 | "Regenerate the *toc* buffer by reparsing file of section at point." |
| 3779 | (interactive) | 3850 | (interactive) |
| 3780 | (if reftex-enable-partial-scans | 3851 | (if reftex-enable-partial-scans |
| 3781 | (let* ((data (get-text-property (point) ':data)) | 3852 | (let* ((data (get-text-property (point) :data)) |
| 3782 | (what (car data)) | 3853 | (what (car data)) |
| 3783 | (file (cond ((eq what 'toc) (nth 3 data)) | 3854 | (file (cond ((eq what 'toc) (nth 3 data)) |
| 3784 | ((memq what '(eof bof file-error)) (nth 1 data)) | 3855 | ((memq what '(eof bof file-error)) (nth 1 data)) |
| @@ -3786,7 +3857,7 @@ Label context is only displayed when the labels are there as well." | |||
| 3786 | (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) | 3857 | (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) |
| 3787 | (if (not file) | 3858 | (if (not file) |
| 3788 | (error "Don't know which file to rescan. Try `R'") | 3859 | (error "Don't know which file to rescan. Try `R'") |
| 3789 | (put 'reftex-toc ':reftex-line line) | 3860 | (put 'reftex-toc :reftex-line line) |
| 3790 | (switch-to-buffer-other-window | 3861 | (switch-to-buffer-other-window |
| 3791 | (reftex-get-file-buffer-force file)) | 3862 | (reftex-get-file-buffer-force file)) |
| 3792 | (setq current-prefix-arg '(4)) | 3863 | (setq current-prefix-arg '(4)) |
| @@ -3833,7 +3904,7 @@ Label context is only displayed when the labels are there as well." | |||
| 3833 | ;; even if the buffer is not live, or things like outline, x-symbol etc. | 3904 | ;; even if the buffer is not live, or things like outline, x-symbol etc. |
| 3834 | ;; have been active. | 3905 | ;; have been active. |
| 3835 | 3906 | ||
| 3836 | (let* ((toc (get-text-property (point) ':data)) | 3907 | (let* ((toc (get-text-property (point) :data)) |
| 3837 | (toc-window (selected-window)) | 3908 | (toc-window (selected-window)) |
| 3838 | show-window show-buffer match) | 3909 | show-window show-buffer match) |
| 3839 | 3910 | ||
| @@ -4012,7 +4083,7 @@ During a selection process, these are the local bindings. | |||
| 4012 | (symbol-value reftex-docstruct-symbol)))) | 4083 | (symbol-value reftex-docstruct-symbol)))) |
| 4013 | ;; Anywhere in the entire document | 4084 | ;; Anywhere in the entire document |
| 4014 | (cdr (assq 'bib (symbol-value reftex-docstruct-symbol))) | 4085 | (cdr (assq 'bib (symbol-value reftex-docstruct-symbol))) |
| 4015 | (error "\\bibliography statement missing or .bib files not found."))) | 4086 | (error "\\bibliography statement missing or .bib files not found"))) |
| 4016 | 4087 | ||
| 4017 | ;; Find a certain reference in any of the BibTeX files. | 4088 | ;; Find a certain reference in any of the BibTeX files. |
| 4018 | 4089 | ||
| @@ -4098,7 +4169,7 @@ During a selection process, these are the local bindings. | |||
| 4098 | 4169 | ||
| 4099 | (setq first-re (car re-list) ; We'll use the first re to find things, | 4170 | (setq first-re (car re-list) ; We'll use the first re to find things, |
| 4100 | rest-re (cdr re-list)) ; the others to narrow down. | 4171 | rest-re (cdr re-list)) ; the others to narrow down. |
| 4101 | (if (string-match "\\`[ \t]*\\'" first-re) | 4172 | (if (string-match "\\`[ \t]*\\'" (or first-re "")) |
| 4102 | (error "Empty regular expression")) | 4173 | (error "Empty regular expression")) |
| 4103 | 4174 | ||
| 4104 | (save-excursion | 4175 | (save-excursion |
| @@ -4114,7 +4185,7 @@ During a selection process, these are the local bindings. | |||
| 4114 | (setq buffer1 (reftex-get-file-buffer-force | 4185 | (setq buffer1 (reftex-get-file-buffer-force |
| 4115 | buffer (not reftex-keep-temporary-buffers)))) | 4186 | buffer (not reftex-keep-temporary-buffers)))) |
| 4116 | (if (not buffer1) | 4187 | (if (not buffer1) |
| 4117 | (error "Cannot find BibTeX file %s" buffer) | 4188 | (message "No such BibTeX file %s (ignored)" buffer) |
| 4118 | (message "Scanning bibliography database %s" buffer1)) | 4189 | (message "Scanning bibliography database %s" buffer1)) |
| 4119 | 4190 | ||
| 4120 | (set-buffer buffer1) | 4191 | (set-buffer buffer1) |
| @@ -4454,16 +4525,18 @@ After prompting for a regular expression, scans the buffers with | |||
| 4454 | bibtex entries (taken from the \\bibliography command) and offers the | 4525 | bibtex entries (taken from the \\bibliography command) and offers the |
| 4455 | matching entries for selection. The selected entry is formated according | 4526 | matching entries for selection. The selected entry is formated according |
| 4456 | to `reftex-cite-format' and inserted into the buffer. | 4527 | to `reftex-cite-format' and inserted into the buffer. |
| 4528 | |||
| 4457 | If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. | 4529 | If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. |
| 4530 | |||
| 4531 | When called with one or two `C-u' prefixes, first rescans the document. | ||
| 4532 | When called with a numeric prefix, make that many citations. When | ||
| 4533 | called with point inside the braces of a `\cite' command, it will | ||
| 4534 | add another key, ignoring the value of `reftex-cite-format'. | ||
| 4535 | |||
| 4458 | The regular expression uses an expanded syntax: && is interpreted as `and'. | 4536 | The regular expression uses an expanded syntax: && is interpreted as `and'. |
| 4459 | Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. | 4537 | Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. |
| 4460 | While entering the regexp, completion on knows citation keys is possible. | 4538 | While entering the regexp, completion on knows citation keys is possible. |
| 4461 | When this function is called with point inside the braces of a \\cite | 4539 | `=' is a good regular expression to match all entries in all files." |
| 4462 | command, it will add another key, ignoring the value of `reftex-cite-format'. | ||
| 4463 | When called with a numeric prefix, that many citations will be made and all | ||
| 4464 | put into the same \\cite command. | ||
| 4465 | When called with just or two C-u as prefix, enforces rescan of buffer for | ||
| 4466 | bibliography statement (e.g. if it was changed)." | ||
| 4467 | 4540 | ||
| 4468 | (interactive) | 4541 | (interactive) |
| 4469 | 4542 | ||
| @@ -4611,7 +4684,6 @@ bibliography statement (e.g. if it was changed)." | |||
| 4611 | ;; Offer bib menu and return list of selected items | 4684 | ;; Offer bib menu and return list of selected items |
| 4612 | 4685 | ||
| 4613 | (let (found-list rtn key data selected-entries) | 4686 | (let (found-list rtn key data selected-entries) |
| 4614 | |||
| 4615 | (while | 4687 | (while |
| 4616 | (not | 4688 | (not |
| 4617 | (catch 'done | 4689 | (catch 'done |
| @@ -4627,7 +4699,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4627 | (cdr (assq 'thebib (symbol-value reftex-docstruct-symbol))))) | 4699 | (cdr (assq 'thebib (symbol-value reftex-docstruct-symbol))))) |
| 4628 | (reftex-default-bibliography | 4700 | (reftex-default-bibliography |
| 4629 | (message "Using default bibliography") | 4701 | (message "Using default bibliography") |
| 4630 | (reftex-extract-bib-entries reftex-default-bibliography)) | 4702 | (reftex-extract-bib-entries (reftex-default-bibliography))) |
| 4631 | (t (error "No valid bibliography in this document, and no default available")))) | 4703 | (t (error "No valid bibliography in this document, and no default available")))) |
| 4632 | 4704 | ||
| 4633 | (unless found-list | 4705 | (unless found-list |
| @@ -4650,7 +4722,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4650 | (reftex-insert-bib-matches found-list))) | 4722 | (reftex-insert-bib-matches found-list))) |
| 4651 | (setq buffer-read-only t) | 4723 | (setq buffer-read-only t) |
| 4652 | (if (= 0 (buffer-size)) | 4724 | (if (= 0 (buffer-size)) |
| 4653 | (error "Sorry, no matches found")) | 4725 | (error "No matches found")) |
| 4654 | (setq truncate-lines t) | 4726 | (setq truncate-lines t) |
| 4655 | (goto-char 1) | 4727 | (goto-char 1) |
| 4656 | (while t | 4728 | (while t |
| @@ -4732,7 +4804,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4732 | (lambda (x) | 4804 | (lambda (x) |
| 4733 | (setq tmp (cdr (assoc "&formatted" x)) | 4805 | (setq tmp (cdr (assoc "&formatted" x)) |
| 4734 | len (length tmp)) | 4806 | len (length tmp)) |
| 4735 | (put-text-property 0 len ':data x tmp) | 4807 | (put-text-property 0 len :data x tmp) |
| 4736 | (put-text-property 0 (1- len) 'mouse-face mouse-face tmp) | 4808 | (put-text-property 0 (1- len) 'mouse-face mouse-face tmp) |
| 4737 | (insert tmp))) | 4809 | (insert tmp))) |
| 4738 | list)) | 4810 | list)) |
| @@ -4837,7 +4909,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4837 | (setq bibfile-list (list (cdr tmp)) | 4909 | (setq bibfile-list (list (cdr tmp)) |
| 4838 | item t)) | 4910 | item t)) |
| 4839 | (reftex-default-bibliography | 4911 | (reftex-default-bibliography |
| 4840 | (setq bibfile-list reftex-default-bibliography)) | 4912 | (setq bibfile-list (reftex-default-bibliography))) |
| 4841 | (t (ding) (throw 'exit)))) | 4913 | (t (ding) (throw 'exit)))) |
| 4842 | 4914 | ||
| 4843 | (when no-revisit | 4915 | (when no-revisit |
| @@ -4866,7 +4938,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4866 | (if (marker-position reftex-recursive-edit-marker) | 4938 | (if (marker-position reftex-recursive-edit-marker) |
| 4867 | (error | 4939 | (error |
| 4868 | (substitute-command-keys | 4940 | (substitute-command-keys |
| 4869 | "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit].")))) | 4941 | "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]")))) |
| 4870 | 4942 | ||
| 4871 | (defun reftex-select-item (prompt help-string keymap | 4943 | (defun reftex-select-item (prompt help-string keymap |
| 4872 | &optional offset | 4944 | &optional offset |
| @@ -4943,7 +5015,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4943 | 5015 | ||
| 4944 | (defun reftex-select-post-command-hook () | 5016 | (defun reftex-select-post-command-hook () |
| 4945 | (let (b e) | 5017 | (let (b e) |
| 4946 | (setq data (get-text-property (point) ':data)) | 5018 | (setq data (get-text-property (point) :data)) |
| 4947 | (setq last-data (or data last-data)) | 5019 | (setq last-data (or data last-data)) |
| 4948 | 5020 | ||
| 4949 | (when (and data cb-flag | 5021 | (when (and data cb-flag |
| @@ -4953,10 +5025,10 @@ bibliography statement (e.g. if it was changed)." | |||
| 4953 | (not reftex-revisit-to-follow))) | 5025 | (not reftex-revisit-to-follow))) |
| 4954 | (if data | 5026 | (if data |
| 4955 | (setq b (or (previous-single-property-change | 5027 | (setq b (or (previous-single-property-change |
| 4956 | (1+ (point)) ':data) | 5028 | (1+ (point)) :data) |
| 4957 | (point-min)) | 5029 | (point-min)) |
| 4958 | e (or (next-single-property-change | 5030 | e (or (next-single-property-change |
| 4959 | (point) ':data) | 5031 | (point) :data) |
| 4960 | (point-max))) | 5032 | (point-max))) |
| 4961 | (setq b (point) e (point))) | 5033 | (setq b (point) e (point))) |
| 4962 | (and (memq reftex-highlight-selection '(cursor both)) | 5034 | (and (memq reftex-highlight-selection '(cursor both)) |
| @@ -5005,7 +5077,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 5005 | ((and (local-variable-p 'reftex-last-data (current-buffer)) | 5077 | ((and (local-variable-p 'reftex-last-data (current-buffer)) |
| 5006 | reftex-last-data | 5078 | reftex-last-data |
| 5007 | (setq pos (text-property-any (point-min) (point-max) | 5079 | (setq pos (text-property-any (point-min) (point-max) |
| 5008 | ':data reftex-last-data))) | 5080 | :data reftex-last-data))) |
| 5009 | (goto-char pos)) | 5081 | (goto-char pos)) |
| 5010 | ((and (local-variable-p 'reftex-last-line (current-buffer)) | 5082 | ((and (local-variable-p 'reftex-last-line (current-buffer)) |
| 5011 | (integerp reftex-last-line)) | 5083 | (integerp reftex-last-line)) |
| @@ -5046,7 +5118,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 5046 | "Accept the item at the mouse click." | 5118 | "Accept the item at the mouse click." |
| 5047 | (interactive "e") | 5119 | (interactive "e") |
| 5048 | (mouse-set-point ev) | 5120 | (mouse-set-point ev) |
| 5049 | (setq data (get-text-property (point) ':data)) | 5121 | (setq data (get-text-property (point) :data)) |
| 5050 | (setq last-data (or data last-data)) | 5122 | (setq last-data (or data last-data)) |
| 5051 | (throw 'myexit 'return)) | 5123 | (throw 'myexit 'return)) |
| 5052 | (defun reftex-select-read-label () | 5124 | (defun reftex-select-read-label () |
| @@ -5080,53 +5152,69 @@ bibliography statement (e.g. if it was changed)." | |||
| 5080 | ;;; | 5152 | ;;; |
| 5081 | ;;; View cross references | 5153 | ;;; View cross references |
| 5082 | 5154 | ||
| 5083 | (defun reftex-view-crossref (&optional arg how) | 5155 | (defun reftex-view-crossref (&optional arg auto-how) |
| 5084 | "View cross reference of \\ref or \\cite macro at point. | 5156 | "View cross reference of macro at point. Point must be on the KEY |
| 5085 | If the macro at point is a \\ref, show the corresponding label definition. | 5157 | argument. When at at `\ref' macro, show corresponding `\label' |
| 5086 | If it is a \\cite, show the BibTeX database entry or the \\bibitem. | 5158 | definition, also in external documents (`xr'). When on a label, show |
| 5087 | To cope with the plethora of variations in packages, this | 5159 | a locations where KEY is referenced. Subsequent calls find additional |
| 5088 | function assumes any macro either starting with or ending in `ref' or | 5160 | locations. When on a `\cite', show the associated `\bibitem' macro or |
| 5089 | `cite' to contain cross references. | 5161 | the BibTeX database entry. When on a `\bibitem', show a `\cite' macro |
| 5090 | When the LaTeX package `xr' is being used, this command will also view | 5162 | which uses this KEY. When on an `\index', show other locations marked |
| 5091 | crossreferences in external documents. However, this works correctly only | 5163 | by the same index entry. |
| 5092 | when the \\externaldocument macros are used with the optional label prefix | 5164 | To define additional cross referencing items, use the option |
| 5093 | argument. | 5165 | `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. |
| 5094 | With one or two C-u prefixes, enforce rescanning of the document. | 5166 | With one or two C-u prefixes, enforce rescanning of the document. |
| 5095 | With argument 2, select the window showing the cross reference. | 5167 | With argument 2, select the window showing the cross reference. |
| 5096 | When HOW is 'echo, call the corresponding echo function. | 5168 | AUTO-HOW is only for the automatic crossref display and is handed through |
| 5097 | When HOW is 'tmp-window, make the pop-up window as small as possible and | 5169 | to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." |
| 5098 | arrange for its removal before the next command." | ||
| 5099 | 5170 | ||
| 5100 | (interactive "P") | 5171 | (interactive "P") |
| 5101 | |||
| 5102 | ;; See where we are. | 5172 | ;; See where we are. |
| 5103 | (let* ((macro (car (reftex-what-macro 1))) | 5173 | (let* ((macro (car (reftex-what-macro 1))) |
| 5104 | (key (reftex-this-word "^{}%\n\r,"))) | 5174 | (key (reftex-this-word "^{}%\n\r,")) |
| 5105 | 5175 | dw) | |
| 5106 | (setq reftex-call-back-to-this-buffer (current-buffer)) | ||
| 5107 | |||
| 5108 | (if (and macro | ||
| 5109 | (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'" | ||
| 5110 | macro)) | ||
| 5111 | (and (setq macro (match-string 0 macro)) | ||
| 5112 | (string-match "\\`\\\\" macro) | ||
| 5113 | (setq macro (substring macro 1))) | ||
| 5114 | (setq macro nil)) | ||
| 5115 | 5176 | ||
| 5116 | (if (or (null macro) (reftex-in-comment)) | 5177 | (if (or (null macro) (reftex-in-comment)) |
| 5117 | (error "No cross reference to display")) | 5178 | (error "Not on a crossref macro argument")) |
| 5179 | |||
| 5180 | (setq reftex-call-back-to-this-buffer (current-buffer)) | ||
| 5118 | 5181 | ||
| 5119 | (if (eq how 'tmp-window) | ||
| 5120 | ;; Remember the window configuration | ||
| 5121 | (put 'reftex-auto-view-crossref 'last-window-conf | ||
| 5122 | (current-window-configuration))) | ||
| 5123 | (cond | 5182 | (cond |
| 5124 | ((string= macro "cite") | 5183 | ((string-match "\\`\\\\cite\\|cite\\*?\\'" macro) |
| 5125 | (reftex-view-cr-cite arg key how)) | 5184 | ;; A citation macro: search for bibitems or BibTeX entries |
| 5126 | ((string= macro "ref") | 5185 | (setq dw (reftex-view-cr-cite arg key auto-how))) |
| 5127 | (reftex-view-cr-ref arg key how)) | 5186 | ((string-match "\\`\\\\ref\\|ref\\*?\\'" macro) |
| 5187 | ;; A reference macro: search for labels | ||
| 5188 | (setq dw (reftex-view-cr-ref arg key auto-how))) | ||
| 5189 | (auto-how nil) ;; No further action for automatic display (speed) | ||
| 5190 | ((or (equal macro "\\label") | ||
| 5191 | (member macro reftex-macros-with-labels)) | ||
| 5192 | ;; A label macro: search for reference macros | ||
| 5193 | (reftex-access-scan-info arg) | ||
| 5194 | (setq dw (reftex-view-regexp-match | ||
| 5195 | (format reftex-find-reference-format (regexp-quote key)) | ||
| 5196 | 3 nil nil))) | ||
| 5197 | ((equal macro "\\bibitem") | ||
| 5198 | ;; A bibitem macro: search for citations | ||
| 5199 | (reftex-access-scan-info arg) | ||
| 5200 | (setq dw (reftex-view-regexp-match | ||
| 5201 | (format reftex-find-citation-regexp-format (regexp-quote key)) | ||
| 5202 | 3 nil nil))) | ||
| 5128 | (t | 5203 | (t |
| 5129 | (error "Cannot display crossref\n"))))) | 5204 | (reftex-access-scan-info arg) |
| 5205 | (catch 'exit | ||
| 5206 | (let ((list reftex-view-crossref-extra) | ||
| 5207 | entry mre action group) | ||
| 5208 | (while (setq entry (pop list)) | ||
| 5209 | (setq mre (car entry) | ||
| 5210 | action (nth 1 entry) | ||
| 5211 | group (nth 2 entry)) | ||
| 5212 | (when (string-match mre macro) | ||
| 5213 | (setq dw (reftex-view-regexp-match | ||
| 5214 | (format action key) group nil nil)) | ||
| 5215 | (throw 'exit t)))) | ||
| 5216 | (error "Not on a crossref macro argument")))) | ||
| 5217 | (if (and (eq arg 2) (windowp dw)) (select-window dw)))) | ||
| 5130 | 5218 | ||
| 5131 | (defun reftex-view-cr-cite (arg key how) | 5219 | (defun reftex-view-cr-cite (arg key how) |
| 5132 | ;; View crossreference of a ref cite. HOW can have the values | 5220 | ;; View crossreference of a ref cite. HOW can have the values |
| @@ -5137,6 +5225,11 @@ arrange for its removal before the next command." | |||
| 5137 | ;; Ensure access to scanning info | 5225 | ;; Ensure access to scanning info |
| 5138 | (reftex-access-scan-info (or arg current-prefix-arg)) | 5226 | (reftex-access-scan-info (or arg current-prefix-arg)) |
| 5139 | 5227 | ||
| 5228 | (if (eq how 'tmp-window) | ||
| 5229 | ;; Remember the window configuration | ||
| 5230 | (put 'reftex-auto-view-crossref 'last-window-conf | ||
| 5231 | (current-window-configuration))) | ||
| 5232 | |||
| 5140 | (let (files size item (pos (point)) (win (selected-window)) pop-win) | 5233 | (let (files size item (pos (point)) (win (selected-window)) pop-win) |
| 5141 | ;; Find the citation mode and the file list | 5234 | ;; Find the citation mode and the file list |
| 5142 | (cond | 5235 | (cond |
| @@ -5149,7 +5242,7 @@ arrange for its removal before the next command." | |||
| 5149 | (symbol-value reftex-docstruct-symbol)))))) | 5242 | (symbol-value reftex-docstruct-symbol)))))) |
| 5150 | (reftex-default-bibliography | 5243 | (reftex-default-bibliography |
| 5151 | (setq item nil | 5244 | (setq item nil |
| 5152 | files reftex-default-bibliography)) | 5245 | files (reftex-default-bibliography))) |
| 5153 | (how) ;; don't throw for special display | 5246 | (how) ;; don't throw for special display |
| 5154 | (t (error "Cannot display crossref"))) | 5247 | (t (error "Cannot display crossref"))) |
| 5155 | 5248 | ||
| @@ -5192,6 +5285,11 @@ arrange for its removal before the next command." | |||
| 5192 | ;; Ensure access to scanning info | 5285 | ;; Ensure access to scanning info |
| 5193 | (reftex-access-scan-info (or arg current-prefix-arg)) | 5286 | (reftex-access-scan-info (or arg current-prefix-arg)) |
| 5194 | 5287 | ||
| 5288 | (if (eq how 'tmp-window) | ||
| 5289 | ;; Remember the window configuration | ||
| 5290 | (put 'reftex-auto-view-crossref 'last-window-conf | ||
| 5291 | (current-window-configuration))) | ||
| 5292 | |||
| 5195 | (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) | 5293 | (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) |
| 5196 | (xr-re (nth 2 xr-data)) | 5294 | (xr-re (nth 2 xr-data)) |
| 5197 | (entry (assoc label (symbol-value reftex-docstruct-symbol))) | 5295 | (entry (assoc label (symbol-value reftex-docstruct-symbol))) |
| @@ -5211,7 +5309,7 @@ arrange for its removal before the next command." | |||
| 5211 | (setq entry | 5309 | (setq entry |
| 5212 | (assoc label (symbol-value reftex-docstruct-symbol))))) | 5310 | (assoc label (symbol-value reftex-docstruct-symbol))))) |
| 5213 | (if (eq how 'echo) | 5311 | (if (eq how 'echo) |
| 5214 | ;; Dsiplay in echo area | 5312 | ;; Display in echo area |
| 5215 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | 5313 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) |
| 5216 | (let ((window-conf (current-window-configuration))) | 5314 | (let ((window-conf (current-window-configuration))) |
| 5217 | (condition-case nil | 5315 | (condition-case nil |
| @@ -5393,6 +5491,130 @@ will display info in the echo area." | |||
| 5393 | 'reftex-view-crossref-when-idle | 5491 | 'reftex-view-crossref-when-idle |
| 5394 | reftex-idle-time nil t)))) | 5492 | reftex-idle-time nil t)))) |
| 5395 | 5493 | ||
| 5494 | (defun reftex-view-crossref-from-bibtex (&optional arg) | ||
| 5495 | "View location in a LaTeX document which cites the BibTeX entry at point. | ||
| 5496 | Since BibTeX files can be used by many LaTeX documents, this function | ||
| 5497 | promps upon first use for a buffer in RefTeX mode. To reset this | ||
| 5498 | link to a document, call the function with with a prefix arg. | ||
| 5499 | Calling this function several times find successive citation locations." | ||
| 5500 | (interactive "P") | ||
| 5501 | (when arg | ||
| 5502 | ;; Break connection to reference buffer | ||
| 5503 | (remprop 'reftex-bibtex-view-cite-locations :ref-buffer)) | ||
| 5504 | (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) | ||
| 5505 | ;; Establish connection to reference buffer | ||
| 5506 | (unless ref-buffer | ||
| 5507 | (setq ref-buffer | ||
| 5508 | (save-excursion | ||
| 5509 | (completing-read | ||
| 5510 | "Reference buffer: " | ||
| 5511 | (delq nil | ||
| 5512 | (mapcar | ||
| 5513 | (lambda (b) | ||
| 5514 | (set-buffer b) | ||
| 5515 | (if reftex-mode (list (buffer-name b)) nil)) | ||
| 5516 | (buffer-list))) | ||
| 5517 | nil t))) | ||
| 5518 | (put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer)) | ||
| 5519 | ;; Search for citations | ||
| 5520 | (bibtex-beginning-of-entry) | ||
| 5521 | (if (looking-at | ||
| 5522 | "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)") | ||
| 5523 | (progn | ||
| 5524 | (goto-char (match-beginning 1)) | ||
| 5525 | (reftex-view-regexp-match | ||
| 5526 | (format reftex-find-citation-regexp-format | ||
| 5527 | (regexp-quote (match-string 1))) | ||
| 5528 | 3 arg ref-buffer)) | ||
| 5529 | (error "Cannot find citation key in BibTeX entry")))) | ||
| 5530 | |||
| 5531 | (defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer) | ||
| 5532 | ;; Search for RE in current document or in the document of REF-BUFFER. | ||
| 5533 | ;; Continue the search, if the same re was searched last. | ||
| 5534 | ;; Highlight the group HIGHLIGHT-GROUP of the match. | ||
| 5535 | ;; When NEW is non-nil, start a new search regardless. | ||
| 5536 | ;; Match point is displayed in another window. | ||
| 5537 | ;; Upon success, returns the window which displays the match. | ||
| 5538 | |||
| 5539 | ;;; Decide if new search or continued search | ||
| 5540 | (let* ((oldprop (get 'reftex-view-regexp-match :props)) | ||
| 5541 | (newprop (list (current-buffer) re)) | ||
| 5542 | (cont (and (not new) (equal oldprop newprop))) | ||
| 5543 | (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0)) | ||
| 5544 | (current-window (selected-window)) | ||
| 5545 | (window-conf (current-window-configuration)) | ||
| 5546 | match pop-window) | ||
| 5547 | (switch-to-buffer-other-window (or ref-buffer (current-buffer))) | ||
| 5548 | ;; Search | ||
| 5549 | (condition-case nil | ||
| 5550 | (if cont | ||
| 5551 | (setq match (reftex-global-search-continue)) | ||
| 5552 | (reftex-access-scan-info) | ||
| 5553 | (setq match (reftex-global-search re (reftex-all-document-files)))) | ||
| 5554 | (error nil)) | ||
| 5555 | ;; Evaluate the match. | ||
| 5556 | (if match | ||
| 5557 | (progn | ||
| 5558 | (put 'reftex-view-regexp-match :props newprop) | ||
| 5559 | (put 'reftex-view-regexp-match :cnt (incf cnt)) | ||
| 5560 | (reftex-highlight 0 (match-beginning highlight-group) | ||
| 5561 | (match-end highlight-group)) | ||
| 5562 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | ||
| 5563 | (setq pop-window (selected-window))) | ||
| 5564 | (remprop 'reftex-view-regexp-match :props) | ||
| 5565 | (or cont (set-window-configuration window-conf))) | ||
| 5566 | (select-window current-window) | ||
| 5567 | (if match | ||
| 5568 | (progn | ||
| 5569 | (message "Match Nr. %s" cnt) | ||
| 5570 | pop-window) | ||
| 5571 | (if cont | ||
| 5572 | (error "No further matches (total number of matches: %d)" cnt) | ||
| 5573 | (error "No matches"))))) | ||
| 5574 | |||
| 5575 | (defvar reftex-global-search-marker (make-marker)) | ||
| 5576 | (defun reftex-global-search (regexp file-list) | ||
| 5577 | ;; Start a search for REGEXP in all files of FILE-LIST | ||
| 5578 | (put 'reftex-global-search :file-list file-list) | ||
| 5579 | (put 'reftex-global-search :regexp regexp) | ||
| 5580 | (move-marker reftex-global-search-marker nil) | ||
| 5581 | (reftex-global-search-continue)) | ||
| 5582 | |||
| 5583 | (defun reftex-global-search-continue () | ||
| 5584 | ;; Continue a global search started with `reftex-global-search' | ||
| 5585 | (unless (get 'reftex-global-search :file-list) | ||
| 5586 | (error "No global search to continue")) | ||
| 5587 | (let* ((file-list (get 'reftex-global-search :file-list)) | ||
| 5588 | (regexp (get 'reftex-global-search :regexp)) | ||
| 5589 | (buf (or (marker-buffer reftex-global-search-marker) | ||
| 5590 | (reftex-get-file-buffer-force (car file-list)))) | ||
| 5591 | (pos (or (marker-position reftex-global-search-marker) 1)) | ||
| 5592 | file) | ||
| 5593 | ;; Take up starting position | ||
| 5594 | (unless buf (error "No such buffer %s" buf)) | ||
| 5595 | (switch-to-buffer buf) | ||
| 5596 | (widen) | ||
| 5597 | (goto-char pos) | ||
| 5598 | ;; Search and switch file if necessary | ||
| 5599 | (if (catch 'exit | ||
| 5600 | (while t | ||
| 5601 | (when (re-search-forward regexp nil t) | ||
| 5602 | (move-marker reftex-global-search-marker (point)) | ||
| 5603 | (throw 'exit t)) | ||
| 5604 | ;; No match - goto next file | ||
| 5605 | (pop file-list) | ||
| 5606 | (or file-list (throw 'exit nil)) | ||
| 5607 | (setq file (car file-list) | ||
| 5608 | buf (reftex-get-file-buffer-force file)) | ||
| 5609 | (unless buf (error "Cannot access file %s" file)) | ||
| 5610 | (put 'reftex-global-search :file-list file-list) | ||
| 5611 | (switch-to-buffer buf) | ||
| 5612 | (widen) | ||
| 5613 | (goto-char 1))) | ||
| 5614 | t | ||
| 5615 | (move-marker reftex-global-search-marker nil) | ||
| 5616 | (error "All files processed")))) | ||
| 5617 | |||
| 5396 | ;;; ========================================================================= | 5618 | ;;; ========================================================================= |
| 5397 | ;;; | 5619 | ;;; |
| 5398 | ;;; Functions that check out the surroundings | 5620 | ;;; Functions that check out the surroundings |
| @@ -5807,18 +6029,23 @@ When DIE is non-nil, throw an error if file not found." | |||
| 5807 | (pop alist)) | 6029 | (pop alist)) |
| 5808 | (nreverse out))) | 6030 | (nreverse out))) |
| 5809 | 6031 | ||
| 6032 | (defun reftex-window-height () | ||
| 6033 | (if (fboundp 'window-displayed-height) | ||
| 6034 | (window-displayed-height) | ||
| 6035 | (window-height))) | ||
| 6036 | |||
| 5810 | (defun reftex-enlarge-to-fit (buf2 &optional keep-current) | 6037 | (defun reftex-enlarge-to-fit (buf2 &optional keep-current) |
| 5811 | ;; Enlarge other window displaying buffer to show whole buffer if possible. | 6038 | ;; Enlarge other window displaying buffer to show whole buffer if possible. |
| 5812 | ;; If KEEP-CURRENT in non-nil, current buffer must remain visible. | 6039 | ;; If KEEP-CURRENT in non-nil, current buffer must remain visible. |
| 5813 | (let* ((win1 (selected-window)) | 6040 | (let* ((win1 (selected-window)) |
| 5814 | (buf1 (current-buffer)) | 6041 | (buf1 (current-buffer)) |
| 5815 | (win2 (get-buffer-window buf2))) | 6042 | (win2 (get-buffer-window buf2))) ;; Only on current frame. |
| 5816 | (when win2 | 6043 | (when win2 |
| 5817 | (select-window win2) | 6044 | (select-window win2) |
| 5818 | (unless (and (pos-visible-in-window-p 1) | 6045 | (unless (and (pos-visible-in-window-p 1) |
| 5819 | (pos-visible-in-window-p (point-max))) | 6046 | (pos-visible-in-window-p (point-max))) |
| 5820 | (enlarge-window (1+ (- (count-lines 1 (point-max)) | 6047 | (enlarge-window (1+ (- (count-lines 1 (point-max)) |
| 5821 | (window-height)))))) | 6048 | (reftex-window-height)))))) |
| 5822 | (cond | 6049 | (cond |
| 5823 | ((window-live-p win1) (select-window win1)) | 6050 | ((window-live-p win1) (select-window win1)) |
| 5824 | (keep-current | 6051 | (keep-current |
| @@ -5836,10 +6063,14 @@ When DIE is non-nil, throw an error if file not found." | |||
| 5836 | (message (concat prompt " (?=Help)")) | 6063 | (message (concat prompt " (?=Help)")) |
| 5837 | (when (or (sit-for (or delay-time 0)) | 6064 | (when (or (sit-for (or delay-time 0)) |
| 5838 | (= ?\? (setq char (read-char-exclusive)))) | 6065 | (= ?\? (setq char (read-char-exclusive)))) |
| 5839 | (with-output-to-temp-buffer " *RefTeX Help*" | 6066 | (reftex-kill-buffer "*RefTeX Select*") |
| 5840 | (princ help-string)) | 6067 | (switch-to-buffer-other-window "*RefTeX Select*") |
| 5841 | (reftex-enlarge-to-fit " *RefTeX Help*") | 6068 | (insert help-string) |
| 5842 | (select-window (get-buffer-window " *RefTeX Help*")) | 6069 | (goto-char 1) |
| 6070 | (unless (and (pos-visible-in-window-p 1) | ||
| 6071 | (pos-visible-in-window-p (point-max))) | ||
| 6072 | (enlarge-window (1+ (- (count-lines 1 (point-max)) | ||
| 6073 | (reftex-window-height))))) | ||
| 5843 | (setq truncate-lines t)) | 6074 | (setq truncate-lines t)) |
| 5844 | (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" ""))) | 6075 | (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" ""))) |
| 5845 | (message prompt) | 6076 | (message prompt) |
| @@ -6097,6 +6328,7 @@ When DIE is non-nil, throw an error if file not found." | |||
| 6097 | (defconst reftex-cache-variables | 6328 | (defconst reftex-cache-variables |
| 6098 | '(reftex-memory ;; This MUST ALWAYS be the first! | 6329 | '(reftex-memory ;; This MUST ALWAYS be the first! |
| 6099 | reftex-env-or-mac-alist reftex-everything-regexp | 6330 | reftex-env-or-mac-alist reftex-everything-regexp |
| 6331 | reftex-macros-with-labels | ||
| 6100 | reftex-find-label-regexp-format reftex-find-label-regexp-format2 | 6332 | reftex-find-label-regexp-format reftex-find-label-regexp-format2 |
| 6101 | reftex-label-env-list reftex-label-mac-list | 6333 | reftex-label-env-list reftex-label-mac-list |
| 6102 | reftex-section-or-include-regexp reftex-section-levels-all | 6334 | reftex-section-or-include-regexp reftex-section-levels-all |
| @@ -6392,6 +6624,7 @@ This enforces rescanning the buffer on next use." | |||
| 6392 | (concat label-re "\\|" section-re "\\|" include-re | 6624 | (concat label-re "\\|" section-re "\\|" include-re |
| 6393 | "\\|" appendix-re | 6625 | "\\|" appendix-re |
| 6394 | (if macros-with-labels "\\|" "") macro-re) | 6626 | (if macros-with-labels "\\|" "") macro-re) |
| 6627 | reftex-macros-with-labels macros-with-labels | ||
| 6395 | reftex-find-label-regexp-format find-label-re-format | 6628 | reftex-find-label-regexp-format find-label-re-format |
| 6396 | reftex-find-label-regexp-format2 | 6629 | reftex-find-label-regexp-format2 |
| 6397 | "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]") | 6630 | "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]") |
| @@ -6757,7 +6990,7 @@ What is being used depends upon `reftex-plug-into-AUCTeX'." | |||
| 6757 | "Toggle Interface between AUCTeX and RefTeX on and off." | 6990 | "Toggle Interface between AUCTeX and RefTeX on and off." |
| 6758 | (interactive) | 6991 | (interactive) |
| 6759 | (unless (and (featurep 'tex-site) (featurep 'latex)) | 6992 | (unless (and (featurep 'tex-site) (featurep 'latex)) |
| 6760 | (error "AUCTeX's LaTeX mode does not seem to be loaded.")) | 6993 | (error "AUCTeX's LaTeX mode does not seem to be loaded")) |
| 6761 | (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX)) | 6994 | (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX)) |
| 6762 | (reftex-plug-into-AUCTeX) | 6995 | (reftex-plug-into-AUCTeX) |
| 6763 | (if reftex-plug-into-AUCTeX | 6996 | (if reftex-plug-into-AUCTeX |
| @@ -6904,14 +7137,14 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6904 | ("\C-c&" . reftex-view-crossref)) | 7137 | ("\C-c&" . reftex-view-crossref)) |
| 6905 | do (define-key reftex-mode-map (car x) (cdr x))) | 7138 | do (define-key reftex-mode-map (car x) (cdr x))) |
| 6906 | 7139 | ||
| 7140 | (eval-after-load | ||
| 7141 | "bibtex" | ||
| 7142 | '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex)) | ||
| 7143 | |||
| 6907 | ;; Bind `reftex-mouse-view-crossref' only when the key is still free | 7144 | ;; Bind `reftex-mouse-view-crossref' only when the key is still free |
| 6908 | (if (featurep 'xemacs) | 7145 | (let ((key (if (featurep 'xemacs) [(shift button2)] [(shift mouse-2)]))) |
| 6909 | (unless (key-binding [(shift button2)]) | 7146 | (unless (key-binding key) |
| 6910 | (define-key reftex-mode-map [(shift button2)] | 7147 | (define-key reftex-mode-map key 'reftex-mouse-view-crossref))) |
| 6911 | 'reftex-mouse-view-crossref)) | ||
| 6912 | (unless (key-binding [(shift mouse-2)]) | ||
| 6913 | (define-key reftex-mode-map [(shift mouse-2)] | ||
| 6914 | 'reftex-mouse-view-crossref))) | ||
| 6915 | 7148 | ||
| 6916 | ;; If the user requests so, she can have a few more bindings: | 7149 | ;; If the user requests so, she can have a few more bindings: |
| 6917 | (when reftex-extra-bindings | 7150 | (when reftex-extra-bindings |
| @@ -6951,9 +7184,8 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6951 | do (define-key map (car x) (cdr x))) | 7184 | do (define-key map (car x) (cdr x))) |
| 6952 | 7185 | ||
| 6953 | ;; The mouse-2 binding | 7186 | ;; The mouse-2 binding |
| 6954 | (if (featurep 'xemacs) | 7187 | (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)]) |
| 6955 | (define-key map [(button2)] 'reftex-select-mouse-accept) | 7188 | 'reftex-select-mouse-accept) |
| 6956 | (define-key map [(mouse-2)] 'reftex-select-mouse-accept)) | ||
| 6957 | 7189 | ||
| 6958 | ;; Digit arguments | 7190 | ;; Digit arguments |
| 6959 | (loop for key across "0123456789" do | 7191 | (loop for key across "0123456789" do |
| @@ -6994,9 +7226,8 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6994 | do (define-key reftex-select-bib-map (car x) (cdr x))) | 7226 | do (define-key reftex-select-bib-map (car x) (cdr x))) |
| 6995 | 7227 | ||
| 6996 | ;; Table of Contents map | 7228 | ;; Table of Contents map |
| 6997 | (if (featurep 'xemacs) | 7229 | (define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)]) |
| 6998 | (define-key reftex-toc-map [(button2)] 'reftex-toc-mouse-goto-line-and-hide) | 7230 | 'reftex-toc-mouse-goto-line-and-hide) |
| 6999 | (define-key reftex-toc-map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide)) | ||
| 7000 | 7231 | ||
| 7001 | (substitute-key-definition | 7232 | (substitute-key-definition |
| 7002 | 'next-line 'reftex-toc-next reftex-toc-map global-map) | 7233 | 'next-line 'reftex-toc-next reftex-toc-map global-map) |
| @@ -7068,108 +7299,56 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 7068 | ["Save Document" reftex-save-all-document-buffers t]) | 7299 | ["Save Document" reftex-save-all-document-buffers t]) |
| 7069 | "---" | 7300 | "---" |
| 7070 | ("Options" | 7301 | ("Options" |
| 7071 | ("Table of Contents" | 7302 | "PARSER" |
| 7072 | ["Keep Other Windows" (setq reftex-toc-keep-other-windows | 7303 | ["Partial Scans" |
| 7073 | (not reftex-toc-keep-other-windows)) | 7304 | (setq reftex-enable-partial-scans (not reftex-enable-partial-scans)) |
| 7074 | :style toggle :selected reftex-toc-keep-other-windows] | 7305 | :style toggle :selected reftex-enable-partial-scans] |
| 7075 | ["Follow Mode" (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)) | 7306 | ["Auto-Save Parse Info" |
| 7076 | :style toggle :selected reftex-toc-follow-mode] | 7307 | (setq reftex-save-parse-info (not reftex-save-parse-info)) |
| 7077 | ["Follow Mode may Visit Files" | 7308 | :style toggle :selected reftex-save-parse-info] |
| 7078 | (setq reftex-revisit-to-follow (not reftex-revisit-to-follow)) | 7309 | "---" |
| 7079 | :style toggle :selected reftex-revisit-to-follow]) | 7310 | "CROSSREF INFO" |
| 7080 | ("References" | 7311 | ["Automatic Info" reftex-toggle-auto-view-crossref |
| 7081 | ["Guess Label Type" | 7312 | :style toggle :selected reftex-auto-view-crossref-timer] |
| 7082 | (setq reftex-guess-label-type (not reftex-guess-label-type)) | 7313 | ["...in Echo Area" (setq reftex-auto-view-crossref t) |
| 7083 | :style toggle :selected reftex-guess-label-type] | 7314 | :style radio :selected (eq reftex-auto-view-crossref t)] |
| 7084 | ["Use `\\vref' by Default" | 7315 | ["...in Other Window" (setq reftex-auto-view-crossref 'window) |
| 7085 | (setq reftex-vref-is-default (not reftex-vref-is-default)) | 7316 | :style radio :selected (eq reftex-auto-view-crossref 'window)] |
| 7086 | :style toggle :selected reftex-vref-is-default] | 7317 | "---" |
| 7087 | "---" | 7318 | "MISC" |
| 7088 | "Selection Buffers" | 7319 | ["AUC TeX Interface" reftex-toggle-plug-into-AUCTeX |
| 7089 | ["Use Multiple Buffers" | 7320 | :style toggle :selected reftex-plug-into-AUCTeX]) |
| 7090 | (setq reftex-use-multiple-selection-buffers | 7321 | ("Reference Style" |
| 7091 | (not reftex-use-multiple-selection-buffers)) | 7322 | ["Standard" (setq reftex-vref-is-default nil) |
| 7092 | :style toggle :selected reftex-use-multiple-selection-buffers] | 7323 | :style radio :selected (not reftex-vref-is-default)] |
| 7093 | ["Auto Update Buffers" | 7324 | ["Varioref" (setq reftex-vref-is-default t) |
| 7094 | (setq reftex-auto-update-selection-buffers | 7325 | :style radio :selected reftex-vref-is-default]) |
| 7095 | (not reftex-auto-update-selection-buffers)) | 7326 | ("Citation Style" |
| 7096 | :style toggle :selected reftex-auto-update-selection-buffers]) | 7327 | ,@(mapcar |
| 7097 | ("Citations" | 7328 | (function |
| 7098 | "Citation Style" | 7329 | (lambda (x) |
| 7099 | ,@(mapcar | 7330 | (vector |
| 7100 | (function | 7331 | (capitalize (symbol-name (car x))) |
| 7101 | (lambda (x) | 7332 | (list 'reftex-set-cite-format (list 'quote (car x))) |
| 7102 | (vector | 7333 | :style 'radio :selected |
| 7103 | (capitalize (symbol-name (car x))) | 7334 | (list 'eq (list 'reftex-get-cite-format) (list 'quote (car x)))))) |
| 7104 | (list 'reftex-set-cite-format (list 'quote (car x))) | 7335 | reftex-cite-format-builtin) |
| 7105 | ':style 'radio ':selected | 7336 | "---" |
| 7106 | (list 'eq (list 'reftex-get-cite-format) (list 'quote (car x)))))) | 7337 | "Sort Database Matches" |
| 7107 | reftex-cite-format-builtin) | 7338 | ["Not" (setq reftex-sort-bibtex-matches nil) |
| 7108 | "---" | 7339 | :style radio :selected (eq reftex-sort-bibtex-matches nil)] |
| 7109 | "Bibinfo in Comments" | 7340 | ["by Author" (setq reftex-sort-bibtex-matches 'author) |
| 7110 | ["Attach Comments" | 7341 | :style radio :selected (eq reftex-sort-bibtex-matches 'author)] |
| 7111 | (setq reftex-comment-citations (not reftex-comment-citations)) | 7342 | ["by Year" (setq reftex-sort-bibtex-matches 'year) |
| 7112 | :style toggle :selected reftex-comment-citations] | 7343 | :style radio :selected (eq reftex-sort-bibtex-matches 'year)] |
| 7113 | "---" | 7344 | ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year) |
| 7114 | "Sort Database Matches" | 7345 | :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)]) |
| 7115 | ["Not" (setq reftex-sort-bibtex-matches nil) | 7346 | "---" |
| 7116 | :style radio :selected (eq reftex-sort-bibtex-matches nil)] | ||
| 7117 | ["by Author" (setq reftex-sort-bibtex-matches 'author) | ||
| 7118 | :style radio :selected (eq reftex-sort-bibtex-matches 'author)] | ||
| 7119 | ["by Year" (setq reftex-sort-bibtex-matches 'year) | ||
| 7120 | :style radio :selected (eq reftex-sort-bibtex-matches 'year)] | ||
| 7121 | ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year) | ||
| 7122 | :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)]) | ||
| 7123 | ("Crossref Viewing" | ||
| 7124 | ["Automatic Info" reftex-toggle-auto-view-crossref | ||
| 7125 | :style toggle :selected reftex-auto-view-crossref-timer] | ||
| 7126 | ["...in Echo Area" (setq reftex-auto-view-crossref t) | ||
| 7127 | :style radio :selected (eq reftex-auto-view-crossref t)] | ||
| 7128 | ["...in Other Window" (setq reftex-auto-view-crossref 'window) | ||
| 7129 | :style radio :selected (eq reftex-auto-view-crossref 'window)] | ||
| 7130 | "---" | ||
| 7131 | ["Crossref Echo may Visit Files" | ||
| 7132 | (setq reftex-revisit-to-echo (not reftex-revisit-to-echo)) | ||
| 7133 | :style toggle :selected reftex-revisit-to-echo] | ||
| 7134 | ["Cache Echo Strings for \cite" | ||
| 7135 | (setq reftex-cache-cite-echo (not reftex-cache-cite-echo)) | ||
| 7136 | :style toggle :selected reftex-cache-cite-echo]) | ||
| 7137 | ("Parser" | ||
| 7138 | "Document Scans" | ||
| 7139 | ["Partial Scans" | ||
| 7140 | (setq reftex-enable-partial-scans (not reftex-enable-partial-scans)) | ||
| 7141 | :style toggle :selected reftex-enable-partial-scans] | ||
| 7142 | ["Auto-Save Parse Info" | ||
| 7143 | (setq reftex-save-parse-info (not reftex-save-parse-info)) | ||
| 7144 | :style toggle :selected reftex-save-parse-info] | ||
| 7145 | ["Automatic Rescans" | ||
| 7146 | (setq reftex-allow-automatic-rescan (not reftex-allow-automatic-rescan)) | ||
| 7147 | :style toggle :selected reftex-allow-automatic-rescan] | ||
| 7148 | "---" | ||
| 7149 | "Temporary Buffers" | ||
| 7150 | ["Keep Buffers" | ||
| 7151 | (setq reftex-keep-temporary-buffers (not reftex-keep-temporary-buffers)) | ||
| 7152 | :style toggle :selected reftex-keep-temporary-buffers] | ||
| 7153 | ["Initialize when Visiting" | ||
| 7154 | (setq reftex-initialize-temporary-buffers | ||
| 7155 | (not reftex-initialize-temporary-buffers)) | ||
| 7156 | :style toggle :selected reftex-initialize-temporary-buffers]) | ||
| 7157 | ("AUC TeX" | ||
| 7158 | ["Plug into AUC TeX" reftex-toggle-plug-into-AUCTeX | ||
| 7159 | :style toggle :selected reftex-plug-into-AUCTeX]) | ||
| 7160 | ("Fontification" | ||
| 7161 | ["Use Fontification" (setq reftex-use-fonts (not reftex-use-fonts)) | ||
| 7162 | :style toggle :selected reftex-use-fonts] | ||
| 7163 | ["Fontify Context Display" (setq reftex-refontify-context | ||
| 7164 | (not (reftex-refontify))) | ||
| 7165 | :style toggle :selected (reftex-refontify)])) | ||
| 7166 | ;;"---" | ||
| 7167 | ("Customize" | 7347 | ("Customize" |
| 7168 | ["Browse RefTeX Group" reftex-customize t] | 7348 | ["Browse RefTeX Group" reftex-customize t] |
| 7169 | "---" | 7349 | "---" |
| 7170 | ["Build Full Customize Menu" reftex-create-customize-menu | 7350 | ["Build Full Customize Menu" reftex-create-customize-menu |
| 7171 | (fboundp 'customize-menu-create)]) | 7351 | (fboundp 'customize-menu-create)]) |
| 7172 | "---" | ||
| 7173 | ("Documentation" | 7352 | ("Documentation" |
| 7174 | ["Info" reftex-info t] | 7353 | ["Info" reftex-info t] |
| 7175 | ["Commentary" reftex-show-commentary t]))) | 7354 | ["Commentary" reftex-show-commentary t]))) |
| @@ -7227,3 +7406,4 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 7227 | 7406 | ||
| 7228 | ;;; reftex.el ends here | 7407 | ;;; reftex.el ends here |
| 7229 | 7408 | ||
| 7409 | |||