aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-10-24 19:53:43 +0000
committerKarl Heuer1997-10-24 19:53:43 +0000
commitbaec12503b9db8becf3e66b81b7a02f95cd304e3 (patch)
treef2a6956191cd78b7ce422e22a80237883e07b5fe
parentdd557bb8a2195c072896a379c48a586235a98be2 (diff)
downloademacs-baec12503b9db8becf3e66b81b7a02f95cd304e3.tar.gz
emacs-baec12503b9db8becf3e66b81b7a02f95cd304e3.zip
The menu now used toggle and radio for some items.
(reftex-default-context-regexps): `caption' now prefers the optional short caption. (reftex-offer-label-menu): Fixed bug which could kill master buffer of external document. (reftex-select-item,reftex-get-buffer-visiting): Compatibility code works now the other way round. (reftex-select-external-document): Now gives a message when no external documents are available. (reftex-find-duplicate-labels): Single key strokes to exit or to do a query replace. Made more user friendly in general. (reftex-section-levels,reftex-default-context-regexps): Move definition of these variables to configuration section.
-rw-r--r--lisp/textmodes/reftex.el167
1 files changed, 98 insertions, 69 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index b4383a6ddbf..7a7de9d0325 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -304,9 +304,9 @@
304;; ;; Defining label environments 304;; ;; Defining label environments
305;; reftex-default-label-alist-entries 305;; reftex-default-label-alist-entries
306;; reftex-label-alist 306;; reftex-label-alist
307;; reftex-use-text-after-label-as-context
308;; reftex-section-levels 307;; reftex-section-levels
309;; reftex-default-context-regexps 308;; reftex-default-context-regexps
309;; reftex-use-text-after-label-as-context
310;; ;; Label insertion 310;; ;; Label insertion
311;; reftex-insert-label-flags 311;; reftex-insert-label-flags
312;; reftex-derive-label-parameters 312;; reftex-derive-label-parameters
@@ -424,7 +424,7 @@
424;; 424;;
425;; The default settings of RefTeX ensure a safe ride for beginners and 425;; The default settings of RefTeX ensure a safe ride for beginners and
426;; casual users. However, when using RefTeX for a large project and/or on 426;; casual users. However, when using RefTeX for a large project and/or on
427;; a small computer, there are ways to improve speed and memory usage. 427;; a small computer, there are ways to improve speed or memory usage.
428;; 428;;
429;; o RefTeX will load other parts of a multifile document as well as BibTeX 429;; o RefTeX will load other parts of a multifile document as well as BibTeX
430;; database files for lookup purposes. These buffers are kept, so that 430;; database files for lookup purposes. These buffers are kept, so that
@@ -451,7 +451,7 @@
451;; o Even with partial scans enabled, RefTeX still has to make one full 451;; o Even with partial scans enabled, RefTeX still has to make one full
452;; scan, when you start working with a document. To avoid this, parsing 452;; scan, when you start working with a document. To avoid this, parsing
453;; information can stored in a file. The file `MASTER.rel' is used for 453;; information can stored in a file. The file `MASTER.rel' is used for
454;; storing information about a document with master file MASTER.tex. 454;; storing information about a document with master file `MASTER.tex'.
455;; It is written each time RefTeX parses (part of) the document, and 455;; It is written each time RefTeX parses (part of) the document, and
456;; restored when you begin working with a document in a new editing 456;; restored when you begin working with a document in a new editing
457;; session. To use this feature, put into .emacs: 457;; session. To use this feature, put into .emacs:
@@ -940,7 +940,7 @@ one of its arguments. The elements of each list entry are:
940 1000 means to get text after the last macro argument. 940 1000 means to get text after the last macro argument.
941 - If a string, use as regexp to search *backward* from the label. Context 941 - If a string, use as regexp to search *backward* from the label. Context
942 is then the text following the end of the match. E.g. putting this to 942 is then the text following the end of the match. E.g. putting this to
943 \"\\\\\\\\caption{\" will use the caption in a figure or table 943 \"\\\\\\\\caption[[{]\" will use the caption in a figure or table
944 environment. 944 environment.
945 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays. 945 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays.
946 - If any of `caption', `item', `eqnarray-like', `alignat-like', this 946 - If any of `caption', `item', `eqnarray-like', `alignat-like', this
@@ -1022,6 +1022,39 @@ variable `reftex-default-label-alist-entries."
1022 (nth 0 x)))) 1022 (nth 0 x))))
1023 reftex-label-alist-builtin))))) 1023 reftex-label-alist-builtin)))))
1024 1024
1025;; LaTeX section commands and level numbers
1026(defcustom reftex-section-levels
1027 '(
1028 ("part" . 0)
1029 ("chapter" . 1)
1030 ("section" . 2)
1031 ("subsection" . 3)
1032 ("subsubsection" . 4)
1033 ("paragraph" . 5)
1034 ("subparagraph" . 6)
1035 ("subsubparagraph" . 7)
1036 )
1037 "Commands and levels used for defining sections in the document.
1038The car of each cons cell is the name of the section macro. The cdr is a
1039number indicating its level."
1040 :group 'reftex-defining-label-environments
1041 :set 'reftex-set-dirty
1042 :type '(repeat
1043 (cons (string :tag "sectioning macro" "")
1044 (number :tag "level " 0))))
1045
1046(defcustom reftex-default-context-regexps
1047 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
1048 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
1049 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
1050 (alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
1051"Alist with default regular expressions for finding context.
1052The form (format regexp (regexp-quote environment)) is used to calculate
1053the final regular expression - so %s will be replaced with the environment
1054or macro."
1055 :group 'reftex-defining-label-environments
1056 :type '(repeat (cons (symbol) (regexp))))
1057
1025(defcustom reftex-use-text-after-label-as-context nil 1058(defcustom reftex-use-text-after-label-as-context nil
1026 "*t means, grab context from directly after the \\label{..} macro. 1059 "*t means, grab context from directly after the \\label{..} macro.
1027This is the fastest method for obtaining context of the label definition, but 1060This is the fastest method for obtaining context of the label definition, but
@@ -1477,6 +1510,8 @@ context to a temporary buffer (value 'copy)."
1477;;; Define the formal stuff for a minor mode named RefTeX. 1510;;; Define the formal stuff for a minor mode named RefTeX.
1478;;; 1511;;;
1479 1512
1513;; This file corresponds to RefTeX version 3.7
1514
1480(defvar reftex-mode nil 1515(defvar reftex-mode nil
1481 "Determines if RefTeX minor mode is active.") 1516 "Determines if RefTeX minor mode is active.")
1482(make-variable-buffer-local 'reftex-mode) 1517(make-variable-buffer-local 'reftex-mode)
@@ -1923,27 +1958,6 @@ This works also without an active TAGS table."
1923(defvar reftex-find-label-regexp-format nil) 1958(defvar reftex-find-label-regexp-format nil)
1924(defvar reftex-find-label-regexp-format2 nil) 1959(defvar reftex-find-label-regexp-format2 nil)
1925 1960
1926;; LaTeX section commands and level numbers
1927(defcustom reftex-section-levels
1928 '(
1929 ("part" . 0)
1930 ("chapter" . 1)
1931 ("section" . 2)
1932 ("subsection" . 3)
1933 ("subsubsection" . 4)
1934 ("paragraph" . 5)
1935 ("subparagraph" . 6)
1936 ("subsubparagraph" . 7)
1937 )
1938 "Commands and levels used for defining sections in the document.
1939The car of each cons cell is the name of the section macro. The cdr is a
1940number indicating its level."
1941 :group 'reftex-defining-label-environments
1942 :set 'reftex-set-dirty
1943 :type '(repeat
1944 (cons (string :tag "sectioning macro" "")
1945 (number :tag "level " 0))))
1946
1947;; The parser functions ---------------------------------- 1961;; The parser functions ----------------------------------
1948 1962
1949(defvar reftex-memory nil 1963(defvar reftex-memory nil
@@ -2728,7 +2742,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
2728 (setq xr-index (reftex-select-external-document 2742 (setq xr-index (reftex-select-external-document
2729 xr-alist xr-index)) 2743 xr-alist xr-index))
2730 (setq buf (or (reftex-get-file-buffer-force 2744 (setq buf (or (reftex-get-file-buffer-force
2731 (cdr (nth xr-index xr-alist)) t) 2745 (cdr (nth xr-index xr-alist)))
2732 (error "Cannot switch document")) 2746 (error "Cannot switch document"))
2733 prefix (or (car (nth xr-index xr-alist)) "") 2747 prefix (or (car (nth xr-index xr-alist)) "")
2734 offset nil)) 2748 offset nil))
@@ -2752,6 +2766,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
2752 ;; Return index of an external document. 2766 ;; Return index of an external document.
2753 (cond 2767 (cond
2754 ((= (length xr-alist) 1) 2768 ((= (length xr-alist) 1)
2769 (message "No external douments available")
2755 (ding) 0) 2770 (ding) 0)
2756 ((= (length xr-alist) 2) 2771 ((= (length xr-alist) 2)
2757 (- 1 xr-index)) 2772 (- 1 xr-index))
@@ -3380,6 +3395,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
3380 (reftex-access-scan-info t) 3395 (reftex-access-scan-info t)
3381 3396
3382 (let ((master (reftex-TeX-master-file)) 3397 (let ((master (reftex-TeX-master-file))
3398 (cnt 0)
3383 (dlist 3399 (dlist
3384 (mapcar 3400 (mapcar
3385 '(lambda(x) 3401 '(lambda(x)
@@ -3398,6 +3414,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
3398 (abbreviate-file-name (nth 3 x))) x1)) 3414 (abbreviate-file-name (nth 3 x))) x1))
3399 (list nil)))))) 3415 (list nil))))))
3400 (reftex-uniquify (symbol-value reftex-docstruct-symbol))))) 3416 (reftex-uniquify (symbol-value reftex-docstruct-symbol)))))
3417
3401 (setq dlist (reftex-uniquify dlist)) 3418 (setq dlist (reftex-uniquify dlist))
3402 (if (null dlist) (error "No duplicate labels in document")) 3419 (if (null dlist) (error "No duplicate labels in document"))
3403 (switch-to-buffer-other-window "*Duplicate Labels*") 3420 (switch-to-buffer-other-window "*Duplicate Labels*")
@@ -3405,16 +3422,26 @@ When called with 2 C-u prefix args, disable magic word recognition."
3405 (setq TeX-master master) 3422 (setq TeX-master master)
3406 (erase-buffer) 3423 (erase-buffer)
3407 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") 3424 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
3408 (insert " Move point to label and type `M-x reftex-change-label'\n" 3425 (insert
3409 " This will run a query-replace on the label and its references\n") 3426 " Move point to label and type `r' to run a query-replace on the label\n"
3427 " and its references. Type `q' to exit this buffer.\n\n")
3410 (insert " LABEL FILE\n") 3428 (insert " LABEL FILE\n")
3411 (insert " -------------------------------------------------------------\n") 3429 (insert " -------------------------------------------------------------\n")
3430 (use-local-map (make-sparse-keymap))
3431 (local-set-key [?q] '(lambda () (interactive)
3432 (kill-buffer (current-buffer)) (delete-window)))
3433 (local-set-key [?r] 'reftex-change-label)
3412 (while dlist 3434 (while dlist
3413 (when (and (car (car dlist)) 3435 (when (and (car (car dlist))
3414 (cdr (car dlist))) 3436 (cdr (car dlist)))
3437 (incf cnt)
3415 (insert (mapconcat '(lambda(x) x) (car dlist) "\n ") "\n")) 3438 (insert (mapconcat '(lambda(x) x) (car dlist) "\n ") "\n"))
3416 (pop dlist)) 3439 (pop dlist))
3417 (goto-char (point-min)))) 3440 (goto-char (point-min))
3441 (when (= cnt 0)
3442 (kill-buffer (current-buffer))
3443 (delete-window)
3444 (message "Document does not contain duplicate labels."))))
3418 3445
3419(defun reftex-all-assq (key list) 3446(defun reftex-all-assq (key list)
3420 ;; Return a list of all associations of KEY in LIST. Comparison with string= 3447 ;; Return a list of all associations of KEY in LIST. Comparison with string=
@@ -4555,10 +4582,10 @@ bibliography statement (e.g. if it was changed)."
4555 (setq last-key key) 4582 (setq last-key key)
4556 (setq key (car 4583 (setq key (car
4557 (cond 4584 (cond
4558 ((fboundp 'listify-key-sequence) ; Emacs
4559 (listify-key-sequence key-sq))
4560 ((fboundp 'event-to-character) ; XEmacs 4585 ((fboundp 'event-to-character) ; XEmacs
4561 (mapcar 'event-to-character key-sq)) 4586 (mapcar 'event-to-character key-sq))
4587 ((fboundp 'listify-key-sequence) ; Emacs
4588 (listify-key-sequence key-sq))
4562 (t (error "Please report this problem to dominik@strw.leidenuniv.nl"))))) 4589 (t (error "Please report this problem to dominik@strw.leidenuniv.nl")))))
4563 4590
4564 (setq cmd (key-binding key-sq)) 4591 (setq cmd (key-binding key-sq))
@@ -4939,6 +4966,7 @@ With argument, actually select the window showing the cross reference."
4939 (progn (skip-chars-backward class) (point)) 4966 (progn (skip-chars-backward class) (point))
4940 (progn (skip-chars-forward class) (point))))) 4967 (progn (skip-chars-forward class) (point)))))
4941 4968
4969(defvar enable-multibyte-characters)
4942(defun reftex-truncate (string ncols &optional ellipses padding) 4970(defun reftex-truncate (string ncols &optional ellipses padding)
4943 ;; Truncate a string to NCHAR characters. 4971 ;; Truncate a string to NCHAR characters.
4944 ;; Works fast with ASCII and correctly with Mule characters. 4972 ;; Works fast with ASCII and correctly with Mule characters.
@@ -5099,11 +5127,11 @@ With argument, actually select the window showing the cross reference."
5099(defun reftex-get-buffer-visiting (file) 5127(defun reftex-get-buffer-visiting (file)
5100 ;; return a buffer visiting FILE 5128 ;; return a buffer visiting FILE
5101 (cond 5129 (cond
5102 ((fboundp 'find-buffer-visiting) ; Emacs
5103 (find-buffer-visiting file))
5104 ((boundp 'find-file-compare-truenames) ; XEmacs 5130 ((boundp 'find-file-compare-truenames) ; XEmacs
5105 (let ((find-file-compare-truenames t)) 5131 (let ((find-file-compare-truenames t))
5106 (get-file-buffer file))) 5132 (get-file-buffer file)))
5133 ((fboundp 'find-buffer-visiting) ; Emacs
5134 (find-buffer-visiting file))
5107 (t (error "Please report this problem to dominik@strw.leidenuniv.nl")))) 5135 (t (error "Please report this problem to dominik@strw.leidenuniv.nl"))))
5108 5136
5109(defun reftex-get-file-buffer-force (file &optional mark-to-kill) 5137(defun reftex-get-file-buffer-force (file &optional mark-to-kill)
@@ -5283,18 +5311,6 @@ This enforces rescanning the buffer on next use."
5283 (not (null (symbol-value symbol)))) 5311 (not (null (symbol-value symbol))))
5284 (set (symbol-value symbol) nil))))) 5312 (set (symbol-value symbol) nil)))))
5285 5313
5286(defcustom reftex-default-context-regexps
5287 '((caption . "\\\\\\(rot\\)?caption\\*?\\(\\[[^]]*\\]\\)?{")
5288 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
5289 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
5290 (alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
5291"Alist with default regular expressions for finding context.
5292The form (format regexp (regexp-quote environment)) is used to calculate
5293the final regular expression - so %s will be replaced with the environment
5294or macro."
5295 :group 'reftex-defining-label-environments
5296 :type '(repeat (cons (symbol) (regexp))))
5297
5298(defun reftex-compute-ref-cite-tables () 5314(defun reftex-compute-ref-cite-tables ()
5299 ;; Update ref and cite tables 5315 ;; Update ref and cite tables
5300 5316
@@ -5490,46 +5506,59 @@ or macro."
5490 ["\\cite" reftex-citation t] 5506 ["\\cite" reftex-citation t]
5491 ["View Crossref" reftex-view-crossref t] 5507 ["View Crossref" reftex-view-crossref t]
5492 "----" 5508 "----"
5493 ("Multifile"
5494 ["Search Whole Document" reftex-search-document t]
5495 ["Replace in Document" reftex-query-replace-document t]
5496 ["Grep on Document" reftex-grep-document t]
5497 "----"
5498 ["Create TAGS File" reftex-create-tags-file t]
5499 "----"
5500 ["Find Duplicate Labels" reftex-find-duplicate-labels t]
5501 ["Change Label and Refs" reftex-change-label t])
5502 ("Parse Document" 5509 ("Parse Document"
5503 ["Only this File" reftex-parse-one t] 5510 ["Only this File" reftex-parse-one t]
5504 ["Entire Document" reftex-parse-all (reftex-is-multi)] 5511 ["Entire Document" reftex-parse-all (reftex-is-multi)]
5505 ["Save to file" (reftex-access-parse-file 'write) 5512 ["Save to File" (reftex-access-parse-file 'write)
5506 (> (length (symbol-value reftex-docstruct-symbol)) 0)] 5513 (> (length (symbol-value reftex-docstruct-symbol)) 0)]
5507 ["Restore from File" (reftex-access-parse-file 'restore) 5514 ["Restore from File" (reftex-access-parse-file 'restore)
5508 (reftex-access-parse-file 'readable)] 5515 (reftex-access-parse-file 'readable)]
5509 "----" 5516 "----"
5510 ["Turn Auto-Save On" (setq reftex-save-parse-info t) 5517 ["Enable Partial Scans"
5511 (not reftex-save-parse-info)] 5518 (setq reftex-enable-partial-scans (not reftex-enable-partial-scans))
5512 ["Turn Auto-Save Off" (setq reftex-save-parse-info nil) 5519 :style toggle :selected reftex-enable-partial-scans]
5513 reftex-save-parse-info] 5520 ["Auto-Save Parse Info"
5521 (setq reftex-save-parse-info (not reftex-save-parse-info))
5522 :style toggle :selected reftex-save-parse-info]
5514 "---" 5523 "---"
5515 ["Reset RefTeX Mode" reftex-reset-mode t]) 5524 ["Reset RefTeX Mode" reftex-reset-mode t])
5516 "----" 5525 ("Multifile"
5517 ["Customize RefTeX" reftex-customize t] 5526 ["Search Whole Document" reftex-search-document t]
5518 ("Set Citation Format" 5527 ["Replace in Document" reftex-query-replace-document t]
5528 ["Grep on Document" reftex-grep-document t]
5529 "----"
5530 ["Create TAGS File" reftex-create-tags-file t]
5531 "----"
5532 ["Find Duplicate Labels" reftex-find-duplicate-labels t]
5533 ["Change Label and Refs" reftex-change-label t])
5534 ("Citation Options"
5535 "Citation Style"
5519 ,@(mapcar 5536 ,@(mapcar
5520 (function 5537 (function
5521 (lambda (x) 5538 (lambda (x)
5522 (vector 5539 (vector
5523 (symbol-name (car x)) 5540 (symbol-name (car x))
5524 (list 'setq 'reftex-cite-format (list 'quote (car x))) 5541 (list 'setq 'reftex-cite-format (list 'quote (car x)))
5525 (list 'not (list 'eq 'reftex-cite-format 5542 :style 'radio :selected
5526 (list 'quote (car x))))))) 5543 (list 'eq 'reftex-cite-format (list 'quote (car x))))))
5527 reftex-cite-format-builtin) 5544 reftex-cite-format-builtin)
5528 "----" 5545 "----"
5529 ["Turn Comments On" (setq reftex-comment-citations t) 5546 "Bibinfo in Comments"
5530 (not reftex-comment-citations)] 5547 ["Attach Comments"
5531 ["Turn Comments Off" (setq reftex-comment-citations nil) 5548 (setq reftex-comment-citations (not reftex-comment-citations))
5532 reftex-comment-citations]) 5549 :style toggle :selected reftex-comment-citations]
5550 "---"
5551 "Sort Database Matches"
5552 ["by Author" (setq reftex-sort-bibtex-matches 'author)
5553 :style radio :selected (eq reftex-sort-bibtex-matches 'author)]
5554 ["by Year" (setq reftex-sort-bibtex-matches 'year)
5555 :style radio :selected (eq reftex-sort-bibtex-matches 'year)]
5556 ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year)
5557 :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)]
5558 ["Not" (setq reftex-sort-bibtex-matches nil)
5559 :style radio :selected (eq reftex-sort-bibtex-matches nil)])
5560 "----"
5561 ["Customize RefTeX" reftex-customize t]
5533 "----" 5562 "----"
5534 ["Show Documentation" reftex-show-commentary t])) 5563 ["Show Documentation" reftex-show-commentary t]))
5535 5564