aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorKarl Heuer1998-02-25 23:05:37 +0000
committerKarl Heuer1998-02-25 23:05:37 +0000
commit29d593f89ce98b2d8fcfddfaac96873b57dd71d5 (patch)
tree81fee28fece4c9094aac8970d253c6bba815632b /lisp/textmodes
parent9f0ef3ebed7ed909bb9c680d099feb3c47e359f2 (diff)
downloademacs-29d593f89ce98b2d8fcfddfaac96873b57dd71d5.tar.gz
emacs-29d593f89ce98b2d8fcfddfaac96873b57dd71d5.zip
(reftex-toc-mode, reftex-select-label-mode):
(reftex-select-bib-mode): New major modes for RefTeX's special buffers. (reftex-offer-label-menu): Put selection buffer into `reftex-select-label-mode'. Make selection buffer read-only. Use `reftex-erase-buffer'. (reftex-do-citation): Put selection buffer into `reftex-select-bib-mode'. Make selection buffer read-only. Use `reftex-erase-buffer'. Set `reftex-select-return-marker'. (reftex-toc): Put *toc* buffer into reftex-toc-mode. Add mouse-face property. (reftex-select-item): Use recursive edit instead of selfmade command loop. Removed unnecessary local bindings. Changed the tag for catch, to avoid problems with `exit' tag in recursive-edit. Moved the code around old command loop to pre- and post-command-hook. (reftex-select-pre-command-hook, reftex-select-post-command-hook): (reftex-select-show-insertion-point): New functions. (reftex-reference): Set `reftex-select-return-marker'. (reftex-check-recursive-edit): Error message changed. (reftex-select-search-minibuffer-map): Obsolete constant removed. (reftex-select-next, reftex-select-previous, reftex-select-scroll-up): (reftex-select-scroll-down, reftex-select-next-heading): (reftex-select-previous-heading): Handle prefix arguments. (reftex-toc, reftex-make-and-insert-label-list): (reftex-insert-bib-matches): Add mouse-face property. (reftex-highlight-selection): New option. (reftex-select-mouse-accept): New command. (reftex-select-recursive-edit, reftex-select-search-forward): (reftex-select-search-backward, reftex-select-search): (reftex-select-scroll-up, reftex-select-scroll-down): (reftex-scroll-other-window, reftex-scroll-other-window-down): (reftex-empty-toc-buffer): Removed obsolete functions. (reftex-highlight-overlays): Removed obsolete 3rd overlay. (reftex-select-label-map, reftex-select-bib-map): Removed obsolete bindings, added mouse bindings, `digit-argument', `negative-argument', `reftex-select-show-insertion-point'. (reftex-erase-buffer): BUFFER now defaults to current buffer. (reftex-label-alist-builtin): Added sidecap packages support. (reftex-last-follow-point, reftex-select-return-marker): New variables. (reftex-toc, reftex-select-item): Set `reftex-last-follow-point'. (reftex-toc-post-command-hook): Use `reftex-last-follow-point'. (reftex-get-file-buffer-force): Turn off `enable-local-variables' when reading a file literally.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/reftex.el542
1 files changed, 294 insertions, 248 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 7ef86a5af6b..b9b6e71c122 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -230,6 +230,10 @@
230 (("sidewaysfigure" ?f nil nil caption) 230 (("sidewaysfigure" ?f nil nil caption)
231 ("sidewaystable" ?t nil nil caption))) 231 ("sidewaystable" ?t nil nil caption)))
232 232
233 (sidecap "CSfigure and SCtable"
234 (("SCfigure" ?f nil nil caption)
235 ("SCtable" ?t nil nil caption)))
236
233 (subfigure "Subfigure environments/macro" 237 (subfigure "Subfigure environments/macro"
234 (("subfigure" ?f nil nil caption) 238 (("subfigure" ?f nil nil caption)
235 ("subfigure*" ?f nil nil caption) 239 ("subfigure*" ?f nil nil caption)
@@ -403,7 +407,7 @@ The following conventions are valid for all alist entries:
403 407
404(defcustom reftex-default-label-alist-entries 408(defcustom reftex-default-label-alist-entries
405 '(amsmath endnotes fancybox floatfig longtable picinpar 409 '(amsmath endnotes fancybox floatfig longtable picinpar
406 rotating subfigure supertab wrapfig LaTeX) 410 rotating sidecap subfigure supertab wrapfig LaTeX)
407 "Default label alist specifications. LaTeX should be the last entry. 411 "Default label alist specifications. LaTeX should be the last entry.
408This list describes the default label environments RefTeX should always use. 412This list describes the default label environments RefTeX should always use.
409It is probably a mistake to remove the LaTeX symbol from this list. 413It is probably a mistake to remove the LaTeX symbol from this list.
@@ -752,13 +756,13 @@ NO-CONTEXT Non-nil means do NOT show the short context.
752FOLLOW Follow full context in other window. 756FOLLOW Follow full context in other window.
753SHOW-COMMENTED Show labels from regions which are commented out. 757SHOW-COMMENTED Show labels from regions which are commented out.
754MATCH-IN-TOC Searches in label menu will also match in toc lines. 758MATCH-IN-TOC Searches in label menu will also match in toc lines.
755SHOW FILES Show Begin and end of included files. 759SHOW FILES Show begin and end of included files.
756 760
757Each of these flags can be set to t or nil, or to a string of type letters 761Each of these flags can be set to t or nil, or to a string of type letters
758indicating the label types for which it should be true. These strings work 762indicating the label types for which it should be true. These strings work
759like character classes in regular expressions. Thus, setting one of the 763like character classes in regular expressions. Thus, setting one of the
760flags to \"sf\" makes the flag true for section and figure labels, nil 764flags to \"sf\" makes the flag true for section and figure labels, nil
761for everything else. Setting it to \"^ft\" makes it the other way round. 765for everything else. Setting it to \"^sf\" makes it the other way round.
762The available label types are: s (section), f (figure), t (table), i (item), 766The available label types are: s (section), f (figure), t (table), i (item),
763e (equation), n (footnote), plus any definitions in `reftex-label-alist'. 767e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
764 768
@@ -1125,6 +1129,25 @@ Font-lock must be loaded as well to actually get fontified display."
1125 :group 'reftex-miscellaneous-configurations 1129 :group 'reftex-miscellaneous-configurations
1126 :type '(boolean)) 1130 :type '(boolean))
1127 1131
1132(defcustom reftex-highlight-selection 'cursor
1133 "*Non-nil mean, highlight selected text in selection and *toc* buffers.
1134Normally, the text near the cursor is the selected text, and it is
1135highlighted. This is the entry most keys in the selction and *toc*
1136buffers act on. However, if you mainly use the mouse to select an
1137item, you may find it nice to have mouse-triggered highlighting
1138instead or as well. The varaiable may have one of these values:
1139
1140 nil No highlighting.
1141 cursor Highlighting is cursor driven.
1142 mouse Highlighting is mouse driven.
1143 both Both cursor and mouse trigger highlighting."
1144 :group 'reftex-miscellaneous-configurations
1145 :type '(choice
1146 (const :tag "Never" nil)
1147 (const :tag "Cursor driven" cursor)
1148 (const :tag "Mouse driven" mouse)
1149 (const :tag "Mouse and Cursor driven." both)))
1150
1128(defcustom reftex-auto-show-entry 'copy 1151(defcustom reftex-auto-show-entry 'copy
1129 "*Non-nil means, do something when context in other window is hidden. 1152 "*Non-nil means, do something when context in other window is hidden.
1130Some modes like `outline-mode' or `folding-mode' hide parts of buffers. 1153Some modes like `outline-mode' or `folding-mode' hide parts of buffers.
@@ -1161,7 +1184,7 @@ When nil, follow-mode will be suspended for stuff in unvisited files."
1161;;; Define the formal stuff for a minor mode named RefTeX. 1184;;; Define the formal stuff for a minor mode named RefTeX.
1162;;; 1185;;;
1163 1186
1164;; This file corresponds to RefTeX version 3.17 1187;; This file corresponds to RefTeX version 3.18.0.2
1165 1188
1166(defvar reftex-mode nil 1189(defvar reftex-mode nil
1167 "Determines if RefTeX minor mode is active.") 1190 "Determines if RefTeX minor mode is active.")
@@ -1609,9 +1632,11 @@ labels."
1609(defvar reftex-default-context-position nil) 1632(defvar reftex-default-context-position nil)
1610(defvar reftex-location-start nil) 1633(defvar reftex-location-start nil)
1611(defvar reftex-call-back-to-this-buffer nil) 1634(defvar reftex-call-back-to-this-buffer nil)
1635(defvar reftex-select-return-marker (make-marker))
1612(defvar reftex-active-toc nil) 1636(defvar reftex-active-toc nil)
1613(defvar reftex-tex-path nil) 1637(defvar reftex-tex-path nil)
1614(defvar reftex-bib-path nil) 1638(defvar reftex-bib-path nil)
1639(defvar reftex-last-follow-point nil)
1615(defvar reftex-prefix) 1640(defvar reftex-prefix)
1616 1641
1617;; List of buffers created temporarily for lookup, which should be killed. 1642;; List of buffers created temporarily for lookup, which should be killed.
@@ -2313,15 +2338,36 @@ This function is controlled by the settings of reftex-insert-label-flags."
2313 t i c # % Toggle: [i]ncl. file borders, [t]able of contents, [c]ontext 2338 t i c # % Toggle: [i]ncl. file borders, [t]able of contents, [c]ontext
2314 [#] label counters, [%] labels in comments 2339 [#] label counters, [%] labels in comments
2315 SPC / f Show full context in other window / Toggle follow mode 2340 SPC / f Show full context in other window / Toggle follow mode
2316 v / e Toggle \\ref <-> \\vref / Recursive Edit into other window 2341 v / . Toggle \\ref <-> \\vref / Show insertion point in other window
2317 TAB Enter a label with completion 2342 TAB Enter a label with completion
2318 q / RET Quit without accepting label / Accept current label") 2343 q / RET Quit without referencing / Accept current label (also on mouse-2)")
2319 2344
2320(defvar reftex-select-label-map nil 2345(defvar reftex-select-label-map nil
2321 "Keymap used for *RefTeX Select* buffer, when selecting a label. 2346 "Keymap used for *RefTeX Select* buffer, when selecting a label.
2322This keymap can be used to configure the label selection process which is 2347This keymap can be used to configure the label selection process which is
2323started with the command \\[reftex-reference].") 2348started with the command \\[reftex-reference].")
2324 2349
2350(defun reftex-select-label-mode ()
2351 "Major mode for selecting a label in a LaTeX document.
2352This buffer was created with RefTeX.
2353It only has a meaningful keymap when you are in the middle of a
2354selection process.
2355To select a label, move the cursor to it and press RET.
2356Press `?' for a summary of important key bindings.
2357
2358During a selection process, these are the local bindings.
2359
2360\\{reftex-select-label-map}"
2361
2362 (interactive)
2363 (kill-all-local-variables)
2364 (make-local-hook 'pre-command-hook)
2365 (make-local-hook 'post-command-hook)
2366 (setq major-mode 'reftex-select-label-mode
2367 mode-name "RefTeX Select Label")
2368 ;; We do not set a local map - reftex-select-item does this.
2369 (run-hooks 'reftex-select-label-mode-hook))
2370
2325(defun reftex-reference (&optional type no-insert cut) 2371(defun reftex-reference (&optional type no-insert cut)
2326 "Make a LaTeX reference. Look only for labels of a certain TYPE. 2372 "Make a LaTeX reference. Look only for labels of a certain TYPE.
2327With prefix arg, force to rescan buffer for labels. This should only be 2373With prefix arg, force to rescan buffer for labels. This should only be
@@ -2355,8 +2401,10 @@ When called with 2 C-u prefix args, disable magic word recognition."
2355 label pair) 2401 label pair)
2356 2402
2357 ;; Have the user select a label 2403 ;; Have the user select a label
2404 (set-marker reftex-select-return-marker (point))
2358 (setq pair (save-excursion 2405 (setq pair (save-excursion
2359 (reftex-offer-label-menu type))) 2406 (reftex-offer-label-menu type)))
2407 (set-marker reftex-select-return-marker nil)
2360 (setq label (car pair) 2408 (setq label (car pair)
2361 type (cdr pair) 2409 type (cdr pair)
2362 form (or (cdr (assoc type reftex-typekey-to-format-alist)) 2410 form (or (cdr (assoc type reftex-typekey-to-format-alist))
@@ -2430,13 +2478,16 @@ When called with 2 C-u prefix args, disable magic word recognition."
2430 (save-window-excursion 2478 (save-window-excursion
2431 (delete-other-windows) 2479 (delete-other-windows)
2432 (setq reftex-call-back-to-this-buffer buf) 2480 (setq reftex-call-back-to-this-buffer buf)
2433 (if reftex-use-multiple-selection-buffers 2481 (let ((default-major-mode 'reftex-select-label-mode))
2434 (switch-to-buffer-other-window 2482 (if reftex-use-multiple-selection-buffers
2435 (save-excursion 2483 (switch-to-buffer-other-window
2436 (set-buffer buf) 2484 (save-excursion
2437 (reftex-make-selection-buffer-name typekey))) 2485 (set-buffer buf)
2438 (switch-to-buffer-other-window "*RefTeX Select*") 2486 (reftex-make-selection-buffer-name typekey)))
2439 (erase-buffer)) 2487 (switch-to-buffer-other-window "*RefTeX Select*")
2488 (reftex-erase-buffer)))
2489 (unless (eq major-mode 'reftex-select-label-mode)
2490 (reftex-select-label-mode))
2440 (add-to-list 'selection-buffers (current-buffer)) 2491 (add-to-list 'selection-buffers (current-buffer))
2441 (setq truncate-lines t) 2492 (setq truncate-lines t)
2442 (setq mode-line-format 2493 (setq mode-line-format
@@ -2447,12 +2498,14 @@ When called with 2 C-u prefix args, disable magic word recognition."
2447 " -%-")) 2498 " -%-"))
2448 (cond 2499 (cond
2449 ((= 0 (buffer-size)) 2500 ((= 0 (buffer-size))
2450 (setq offset (reftex-make-and-insert-label-list 2501 (let ((buffer-read-only nil))
2451 typekey buf toc files context counter commented 2502 (setq offset (reftex-make-and-insert-label-list
2452 (or here-I-am offset) prefix))) 2503 typekey buf toc files context counter commented
2504 (or here-I-am offset) prefix))))
2453 (here-I-am 2505 (here-I-am
2454 (setq offset (reftex-get-offset buf here-I-am typekey))) 2506 (setq offset (reftex-get-offset buf here-I-am typekey)))
2455 (t (setq offset t))) 2507 (t (setq offset t)))
2508 (setq buffer-read-only t)
2456 (setq offset (or offset t)) 2509 (setq offset (or offset t))
2457 2510
2458 (setq here-I-am nil) ; turn off determination of offset 2511 (setq here-I-am nil) ; turn off determination of offset
@@ -2472,15 +2525,15 @@ When called with 2 C-u prefix args, disable magic word recognition."
2472 (cond 2525 (cond
2473 ((eq key ?g) 2526 ((eq key ?g)
2474 ;; update buffer 2527 ;; update buffer
2475 (erase-buffer)) 2528 (reftex-erase-buffer))
2476 ((or (eq key ?r) 2529 ((or (eq key ?r)
2477 (eq key ?R)) 2530 (eq key ?R))
2478 ;; rescan buffer 2531 ;; rescan buffer
2479 (erase-buffer) 2532 (reftex-erase-buffer)
2480 (reftex-parse-document buf last-data key)) 2533 (reftex-parse-document buf last-data key))
2481 ((eq key ?c) 2534 ((eq key ?c)
2482 ;; toggle context mode 2535 ;; toggle context mode
2483 (erase-buffer) 2536 (reftex-erase-buffer)
2484 (setq context (not context))) 2537 (setq context (not context)))
2485 ((eq key ?s) 2538 ((eq key ?s)
2486 ;; switch type 2539 ;; switch type
@@ -2488,19 +2541,19 @@ When called with 2 C-u prefix args, disable magic word recognition."
2488 (setq typekey (reftex-query-label-type))) 2541 (setq typekey (reftex-query-label-type)))
2489 ((eq key ?t) 2542 ((eq key ?t)
2490 ;; toggle table of contents display 2543 ;; toggle table of contents display
2491 (erase-buffer) 2544 (reftex-erase-buffer)
2492 (setq toc (not toc))) 2545 (setq toc (not toc)))
2493 ((eq key ?i) 2546 ((eq key ?i)
2494 ;; toggle display of included file borders 2547 ;; toggle display of included file borders
2495 (erase-buffer) 2548 (reftex-erase-buffer)
2496 (setq files (not files))) 2549 (setq files (not files)))
2497 ((eq key ?#) 2550 ((eq key ?#)
2498 ;; toggle counter display 2551 ;; toggle counter display
2499 (erase-buffer) 2552 (reftex-erase-buffer)
2500 (setq counter (not counter))) 2553 (setq counter (not counter)))
2501 ((eq key ?%) 2554 ((eq key ?%)
2502 ;; toggle display of commented labels 2555 ;; toggle display of commented labels
2503 (erase-buffer) 2556 (reftex-erase-buffer)
2504 (setq commented (not commented))) 2557 (setq commented (not commented)))
2505 ((eq key ?l) 2558 ((eq key ?l)
2506 ;; reuse the last referenced label again 2559 ;; reuse the last referenced label again
@@ -2614,6 +2667,10 @@ When called with 2 C-u prefix args, disable magic word recognition."
2614 (context-indent 2667 (context-indent
2615 (concat ". " 2668 (concat ". "
2616 (if toc (make-string (* 7 reftex-level-indent) ?\ ) ""))) 2669 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
2670 (mouse-face
2671 (cond ((eq reftex-highlight-selection 'mouse) 'highlight)
2672 ((eq reftex-highlight-selection 'both) 'secondary-selection)
2673 (t nil)))
2617 all cell text label typekey note comment master-dir-re 2674 all cell text label typekey note comment master-dir-re
2618 offset from to docstruct-symbol) 2675 offset from to docstruct-symbol)
2619 2676
@@ -2711,6 +2768,9 @@ When called with 2 C-u prefix args, disable magic word recognition."
2711 (insert context-indent text "\n") 2768 (insert context-indent text "\n")
2712 (setq to (point))) 2769 (setq to (point)))
2713 (put-text-property from to ':data cell) 2770 (put-text-property from to ':data cell)
2771 (when mouse-face
2772 (put-text-property from (1- to)
2773 'mouse-face mouse-face))
2714 (goto-char to))))) 2774 (goto-char to)))))
2715 2775
2716 (when (reftex-refontify) 2776 (when (reftex-refontify)
@@ -3362,6 +3422,28 @@ When called with 2 C-u prefix args, disable magic word recognition."
3362(defvar reftex-toc-map (make-sparse-keymap) 3422(defvar reftex-toc-map (make-sparse-keymap)
3363 "Keymap used for *toc* buffer.") 3423 "Keymap used for *toc* buffer.")
3364 3424
3425(defun reftex-toc-mode ()
3426 "Major mode for managing Table of Contents for LaTeX files.
3427This buffer was created with RefTeX.
3428Press `?' for a summary of important key bindings.
3429
3430Here are all local bindings.
3431
3432\\{reftex-toc-map}"
3433 (interactive)
3434 (kill-all-local-variables)
3435 (setq major-mode 'reftex-toc-mode
3436 mode-name "RefTeX Table of Contents")
3437 (use-local-map reftex-toc-map)
3438 (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert)
3439 (setq truncate-lines t)
3440 (make-local-hook 'post-command-hook)
3441 (make-local-hook 'pre-command-hook)
3442 (make-local-variable 'reftex-last-follow-point)
3443 (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
3444 (add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t)
3445 (run-hooks 'reftex-toc-mode-hook))
3446
3365(defvar reftex-last-toc-master nil 3447(defvar reftex-last-toc-master nil
3366 "Stores the name of the tex file that `reftex-toc' was last run on.") 3448 "Stores the name of the tex file that `reftex-toc' was last run on.")
3367 3449
@@ -3393,7 +3475,7 @@ When called with a raw C-u prefix, rescan the document first."
3393 3475
3394 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file))) 3476 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file)))
3395 current-prefix-arg) 3477 current-prefix-arg)
3396 (reftex-empty-toc-buffer)) 3478 (reftex-erase-buffer "*toc*"))
3397 3479
3398 (setq reftex-last-toc-file (buffer-file-name)) 3480 (setq reftex-last-toc-file (buffer-file-name))
3399 (setq reftex-last-toc-master (reftex-TeX-master-file)) 3481 (setq reftex-last-toc-master (reftex-TeX-master-file))
@@ -3411,7 +3493,11 @@ When called with a raw C-u prefix, rescan the document first."
3411 (xr-data (assq 'xr all)) 3493 (xr-data (assq 'xr all))
3412 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) 3494 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
3413 (where (reftex-nearest-section)) 3495 (where (reftex-nearest-section))
3414 toc1 cell startpos) 3496 (mouse-face
3497 (cond ((eq reftex-highlight-selection 'mouse) 'highlight)
3498 ((eq reftex-highlight-selection 'both) 'secondary-selection)
3499 (t nil)))
3500 toc1 cell startpos)
3415 3501
3416 (if (get-buffer-window "*toc*") 3502 (if (get-buffer-window "*toc*")
3417 (select-window (get-buffer-window "*toc*")) 3503 (select-window (get-buffer-window "*toc*"))
@@ -3419,21 +3505,17 @@ When called with a raw C-u prefix, rescan the document first."
3419 (delete-other-windows)) 3505 (delete-other-windows))
3420 (setq reftex-last-window-height (window-height)) ; remember 3506 (setq reftex-last-window-height (window-height)) ; remember
3421 (split-window) 3507 (split-window)
3422 (switch-to-buffer (get-buffer-create "*toc*"))) 3508 (let ((default-major-mode 'reftex-toc-mode))
3509 (switch-to-buffer "*toc*")))
3510
3511 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode))
3423 3512
3424 (cond 3513 (cond
3425 ;; buffer is empty - fill it with the table of contents 3514 ;; buffer is empty - fill it with the table of contents
3426 ((= (buffer-size) 0) 3515 ((= (buffer-size) 0)
3427 (message "Building *toc* buffer...") 3516 (message "Building *toc* buffer...")
3428 (make-local-variable 'revert-buffer-function)
3429 (setq revert-buffer-function 'reftex-toc-revert)
3430 (setq truncate-lines t)
3431 (make-local-hook 'post-command-hook)
3432 (make-local-hook 'pre-command-hook)
3433 (setq post-command-hook '(reftex-toc-post-command-hook))
3434 (setq pre-command-hook '(reftex-toc-pre-command-hook))
3435 (use-local-map reftex-toc-map)
3436 3517
3518 (setq buffer-read-only nil)
3437 (insert (format 3519 (insert (format
3438"TABLE-OF-CONTENTS on %s 3520"TABLE-OF-CONTENTS on %s
3439SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help 3521SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
@@ -3452,6 +3534,9 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3452 (when (eq (car cell) 'toc) 3534 (when (eq (car cell) 'toc)
3453 (setq toc1 (concat (nth 2 cell) "\n")) 3535 (setq toc1 (concat (nth 2 cell) "\n"))
3454 (put-text-property 0 (length toc1) 'toc cell toc1) 3536 (put-text-property 0 (length toc1) 'toc cell toc1)
3537 (when mouse-face
3538 (put-text-property 0 (1- (length toc1))
3539 'mouse-face mouse-face toc1))
3455 (insert toc1))) 3540 (insert toc1)))
3456 3541
3457 (backward-delete-char 1) 3542 (backward-delete-char 1)
@@ -3468,7 +3553,8 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3468 (beginning-of-line) 3553 (beginning-of-line)
3469 (while (and (> (point) startpos) 3554 (while (and (> (point) startpos)
3470 (not (eq (get-text-property (point) 'toc) where))) 3555 (not (eq (get-text-property (point) 'toc) where)))
3471 (beginning-of-line 0)))) 3556 (beginning-of-line 0))
3557 (setq reftex-last-follow-point (point))))
3472 3558
3473(defun reftex-nearest-section () 3559(defun reftex-nearest-section ()
3474 ;; Return (file . find) of nearest section command 3560 ;; Return (file . find) of nearest section command
@@ -3484,6 +3570,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3484(defun reftex-toc-post-command-hook () 3570(defun reftex-toc-post-command-hook ()
3485 ;; used in the post-command-hook for the *toc* buffer 3571 ;; used in the post-command-hook for the *toc* buffer
3486 (and (> (point) 1) 3572 (and (> (point) 1)
3573 (memq reftex-highlight-selection '(cursor both))
3487 (save-excursion 3574 (save-excursion
3488 (reftex-highlight 1 3575 (reftex-highlight 1
3489 (progn (beginning-of-line) (point)) 3576 (progn (beginning-of-line) (point))
@@ -3492,19 +3579,14 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3492 ((integerp reftex-toc-follow-mode) 3579 ((integerp reftex-toc-follow-mode)
3493 ;; remove delayed action 3580 ;; remove delayed action
3494 (setq reftex-toc-follow-mode t)) 3581 (setq reftex-toc-follow-mode t))
3495 (reftex-toc-follow-mode 3582 ((and reftex-toc-follow-mode
3583 (not (equal reftex-last-follow-point (point))))
3496 ;; show context in other window 3584 ;; show context in other window
3585 (setq reftex-last-follow-point (point))
3497 (condition-case nil 3586 (condition-case nil
3498 (reftex-toc-visit-line nil (not reftex-revisit-to-follow)) 3587 (reftex-toc-visit-line nil (not reftex-revisit-to-follow))
3499 (error t))))) 3588 (error t)))))
3500 3589
3501(defun reftex-empty-toc-buffer ()
3502 (if (get-buffer "*toc*")
3503 (save-excursion
3504 (set-buffer "*toc*")
3505 (setq buffer-read-only nil)
3506 (erase-buffer))))
3507
3508(defun reftex-re-enlarge () 3590(defun reftex-re-enlarge ()
3509 (enlarge-window 3591 (enlarge-window
3510 (max 0 (- (or reftex-last-window-height (window-height)) 3592 (max 0 (- (or reftex-last-window-height (window-height))
@@ -3527,6 +3609,11 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3527 "View document location in other window." 3609 "View document location in other window."
3528 (interactive) 3610 (interactive)
3529 (reftex-toc-visit-line)) 3611 (reftex-toc-visit-line))
3612(defun reftex-toc-mouse-view-line (ev)
3613 "View document location in other window."
3614 (interactive "e")
3615 (mouse-set-point ev)
3616 (reftex-toc-visit-line))
3530(defun reftex-toc-goto-line-and-hide () 3617(defun reftex-toc-goto-line-and-hide ()
3531 "Go to document location in other window. Hide the *toc* window." 3618 "Go to document location in other window. Hide the *toc* window."
3532 (interactive) 3619 (interactive)
@@ -3580,7 +3667,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3580 (interactive) 3667 (interactive)
3581 (switch-to-buffer-other-window 3668 (switch-to-buffer-other-window
3582 (reftex-get-file-buffer-force reftex-last-toc-file)) 3669 (reftex-get-file-buffer-force reftex-last-toc-file))
3583 (reftex-empty-toc-buffer) 3670 (reftex-erase-buffer "*toc*")
3584 (setq current-prefix-arg nil) 3671 (setq current-prefix-arg nil)
3585 (reftex-toc)) 3672 (reftex-toc))
3586(defun reftex-toc-external (&rest ignore) 3673(defun reftex-toc-external (&rest ignore)
@@ -3694,16 +3781,37 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
3694 g / r Start over with new regexp / Refine with additional regexp. 3781 g / r Start over with new regexp / Refine with additional regexp.
3695 SPC Show full database entry in other window. 3782 SPC Show full database entry in other window.
3696 f Toggle follow mode: Other window will follow with full db entry. 3783 f Toggle follow mode: Other window will follow with full db entry.
3784 . Show insertion point.
3697 q Quit without inserting \\cite macro into buffer. 3785 q Quit without inserting \\cite macro into buffer.
3698 e Recursive edit into other window.
3699 TAB Enter citation key with completion. 3786 TAB Enter citation key with completion.
3700 RET / a Accept current entry / Accept all entries.") 3787 RET Accept current entry (also on mouse-2)
3788 a Accept all entries.")
3701 3789
3702(defvar reftex-select-bib-map nil 3790(defvar reftex-select-bib-map nil
3703 "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry. 3791 "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
3704This keymap can be used to configure the BibTeX selection process which is 3792This keymap can be used to configure the BibTeX selection process which is
3705started with the command \\[reftex-citation].") 3793started with the command \\[reftex-citation].")
3706 3794
3795(defun reftex-select-bib-mode ()
3796 "Major mode for selecting a citation key in a LaTeX document.
3797This buffer was created with RefTeX.
3798It only has a meaningful keymap when you are in the middle of a
3799selection process.
3800In order to select a citation, move the cursor to it and press RET.
3801Press `?' for a summary of important key bindings.
3802
3803During a selection process, these are the local bindings.
3804
3805\\{reftex-select-label-map}"
3806 (interactive)
3807 (kill-all-local-variables)
3808 (make-local-hook 'pre-command-hook)
3809 (make-local-hook 'post-command-hook)
3810 (setq major-mode 'reftex-select-bib-mode
3811 mode-name "RefTeX Select Bib")
3812 ;; We do not set a local map - reftex-select-item does this.
3813 (run-hooks 'reftex-select-bib-mode-hook))
3814
3707;; Find bibtex files 3815;; Find bibtex files
3708 3816
3709(defun reftex-get-bibfile-list () 3817(defun reftex-get-bibfile-list ()
@@ -4255,13 +4363,19 @@ bibliography statement (e.g. if it was changed)."
4255 4363
4256 ;; remember where we came from 4364 ;; remember where we came from
4257 (setq reftex-call-back-to-this-buffer (current-buffer)) 4365 (setq reftex-call-back-to-this-buffer (current-buffer))
4366 (set-marker reftex-select-return-marker (point))
4258 4367
4259 ;; offer selection 4368 ;; offer selection
4260 (save-window-excursion 4369 (save-window-excursion
4261 (delete-other-windows) 4370 (delete-other-windows)
4262 (switch-to-buffer-other-window "*RefTeX Select*") 4371 (let ((default-major-mode 'reftex-select-bib-mode))
4263 (erase-buffer) 4372 (switch-to-buffer-other-window "*RefTeX Select*")
4264 (reftex-insert-bib-matches found-list) 4373 (unless (eq major-mode 'reftex-select-bib-mode)
4374 (reftex-select-bib-mode))
4375 (let ((buffer-read-only nil))
4376 (erase-buffer)
4377 (reftex-insert-bib-matches found-list)))
4378 (setq buffer-read-only t)
4265 (if (= 0 (buffer-size)) 4379 (if (= 0 (buffer-size))
4266 (error "Sorry, no matches found")) 4380 (error "Sorry, no matches found"))
4267 (setq truncate-lines t) 4381 (setq truncate-lines t)
@@ -4285,8 +4399,9 @@ bibliography statement (e.g. if it was changed)."
4285 (set-buffer reftex-call-back-to-this-buffer) 4399 (set-buffer reftex-call-back-to-this-buffer)
4286 (reftex-extract-bib-entries 4400 (reftex-extract-bib-entries
4287 (reftex-get-bibfile-list)))) 4401 (reftex-get-bibfile-list))))
4288 (erase-buffer) 4402 (let ((buffer-read-only nil))
4289 (reftex-insert-bib-matches found-list) 4403 (erase-buffer)
4404 (reftex-insert-bib-matches found-list))
4290 (if (= 0 (buffer-size)) 4405 (if (= 0 (buffer-size))
4291 (error "Sorry, no matches found")) 4406 (error "Sorry, no matches found"))
4292 (goto-char 1)) 4407 (goto-char 1))
@@ -4314,8 +4429,9 @@ bibliography statement (e.g. if it was changed)."
4314 (if found-list-r 4429 (if found-list-r
4315 (setq found-list found-list-r) 4430 (setq found-list found-list-r)
4316 (ding)) 4431 (ding))
4317 (erase-buffer) 4432 (let ((buffer-read-only nil))
4318 (reftex-insert-bib-matches found-list) 4433 (erase-buffer)
4434 (reftex-insert-bib-matches found-list))
4319 (goto-char 1)) 4435 (goto-char 1))
4320 ((eq key ?a) 4436 ((eq key ?a)
4321 (setq entry 'all) 4437 (setq entry 'all)
@@ -4352,6 +4468,7 @@ bibliography statement (e.g. if it was changed)."
4352 (reftex-format-citation entry format))))) 4468 (reftex-format-citation entry format)))))
4353 (setq ins-string "") 4469 (setq ins-string "")
4354 (message "Quit"))) 4470 (message "Quit")))
4471 (set-marker reftex-select-return-marker (point))
4355 (kill-buffer "*RefTeX Select*") 4472 (kill-buffer "*RefTeX Select*")
4356 4473
4357 (unless no-insert 4474 (unless no-insert
@@ -4376,12 +4493,18 @@ bibliography statement (e.g. if it was changed)."
4376 4493
4377(defun reftex-insert-bib-matches (list) 4494(defun reftex-insert-bib-matches (list)
4378 ;; Insert the bib matches and number them correctly 4495 ;; Insert the bib matches and number them correctly
4379 (let (tmp) 4496 (let ((mouse-face
4497 (cond ((eq reftex-highlight-selection 'mouse) 'highlight)
4498 ((eq reftex-highlight-selection 'both) 'secondary-selection)
4499 (t nil)))
4500 tmp len)
4380 (mapcar 4501 (mapcar
4381 (function 4502 (function
4382 (lambda (x) 4503 (lambda (x)
4383 (setq tmp (cdr (assoc "&formatted" x))) 4504 (setq tmp (cdr (assoc "&formatted" x))
4384 (put-text-property 0 (length tmp) ':data x tmp) 4505 len (length tmp))
4506 (put-text-property 0 len ':data x tmp)
4507 (put-text-property 0 (1- len) 'mouse-face mouse-face tmp)
4385 (insert tmp))) 4508 (insert tmp)))
4386 list))) 4509 list)))
4387 4510
@@ -4509,7 +4632,7 @@ bibliography statement (e.g. if it was changed)."
4509 (if (marker-position reftex-recursive-edit-marker) 4632 (if (marker-position reftex-recursive-edit-marker)
4510 (error 4633 (error
4511 (substitute-command-keys 4634 (substitute-command-keys
4512 "In unfinished recursive edit. Finish (\\[exit-recursive-edit]) or abort (\\[abort-recursive-edit]).")))) 4635 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]."))))
4513 4636
4514(defun reftex-select-item (prompt help-string keymap 4637(defun reftex-select-item (prompt help-string keymap
4515 &optional offset 4638 &optional offset
@@ -4528,12 +4651,10 @@ bibliography statement (e.g. if it was changed)."
4528;; When MATCH-EVERYWHERE is t, searches will also match in non-selectable 4651;; When MATCH-EVERYWHERE is t, searches will also match in non-selectable
4529;; places. 4652;; places.
4530 4653
4531 (let* (key-sq b e ev data last-data cmd skip-callback 4654 (let* (ev data last-data callback-fwd)
4532 (orig-buffer (current-buffer))
4533 (search-str "") last-cmd callback-fwd)
4534 4655
4535 (setq ev 4656 (setq ev
4536 (catch 'exit 4657 (catch 'myexit
4537 (save-window-excursion 4658 (save-window-excursion
4538 (setq truncate-lines t) 4659 (setq truncate-lines t)
4539 4660
@@ -4556,130 +4677,101 @@ bibliography statement (e.g. if it was changed)."
4556 (point-min)))) 4677 (point-min))))
4557 (t (goto-char (point-min)))) 4678 (t (goto-char (point-min))))
4558 (beginning-of-line 1) 4679 (beginning-of-line 1)
4680 (set (make-local-variable 'reftex-last-follow-point) (point))
4559 4681
4560 (unwind-protect 4682 (unwind-protect
4561 (progn 4683 (progn
4562 (use-local-map keymap) 4684 (use-local-map keymap)
4563 (while t 4685 (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t)
4564 (setq data (get-text-property (point) ':data)) 4686 (add-hook 'post-command-hook 'reftex-select-post-command-hook nil t)
4565 (setq last-data (or data last-data)) 4687 (princ prompt)
4566 4688 (set-marker reftex-recursive-edit-marker (point))
4567 (if (and data cb-flag call-back (not skip-callback)) 4689 (run-hooks 'post-command-hook) ;; because XEmacs does not do it
4568 (funcall call-back data callback-fwd 4690 (recursive-edit))
4569 (not reftex-revisit-to-follow))) 4691
4570 (setq skip-callback nil) 4692 (use-local-map nil)
4571 (if data 4693 (remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
4572 (setq b (or (previous-single-property-change 4694 (remove-hook 'post-command-hook 'reftex-select-post-command-hook t)
4573 (1+ (point)) ':data) 4695 (set-marker reftex-recursive-edit-marker nil)))))
4574 (point-min))
4575 e (or (next-single-property-change
4576 (point) ':data)
4577 (point-max)))
4578 (setq b (point) e (point)))
4579 (reftex-highlight 1 b e)
4580 (if (or (not (pos-visible-in-window-p b))
4581 (not (pos-visible-in-window-p e)))
4582 (recenter (/ (window-height) 2)))
4583
4584 (setq last-cmd cmd
4585 cmd nil)
4586
4587 (setq key-sq (read-key-sequence prompt))
4588 (setq cmd (lookup-key keymap key-sq))
4589
4590 (reftex-unhighlight 2)
4591 (reftex-unhighlight 1)
4592 (reftex-unhighlight 0)
4593
4594 (if cmd
4595 (condition-case nil
4596 (progn
4597 (command-execute cmd)
4598 ;FIXME: (run-hooks 'post-command-hook)
4599 )
4600 (error (ding)))
4601 (ding))
4602
4603 (unless (equal (current-buffer) orig-buffer)
4604 (error "Selection commands must return to *RefTeX Select* buffer."))))
4605 (use-local-map nil)))))
4606 4696
4607 (set (make-local-variable 'reftex-last-line) 4697 (set (make-local-variable 'reftex-last-line)
4608 (+ (count-lines (point-min) (point)) (if (bolp) 1 0))) 4698 (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))
4609 (set (make-local-variable 'reftex-last-data) last-data) 4699 (set (make-local-variable 'reftex-last-data) last-data)
4610 (and (get-buffer "*RefTeX Help*") (kill-buffer "*RefTeX Help*")) 4700 (reftex-kill-buffer "*RefTeX Help*")
4611 (message "") 4701 (message "")
4612 (list ev data last-data))) 4702 (list ev data last-data)))
4613 4703
4614;; The following variables are all bound dynamically in `reftex-select-item'. 4704;; The following variables are all bound dynamically in `reftex-select-item'.
4615;; The defvars are here only to silence the byte compiler. 4705;; The defvars are here only to silence the byte compiler.
4616 4706
4617(defvar last-cmd)
4618(defvar found-list) 4707(defvar found-list)
4619(defvar cb-flag) 4708(defvar cb-flag)
4620(defvar data) 4709(defvar data)
4710(defvar prompt)
4711(defvar last-data)
4621(defvar call-back) 4712(defvar call-back)
4622(defvar help-string) 4713(defvar help-string)
4623(defvar skip-callback)
4624(defvar search-str)
4625(defvar match-everywhere) 4714(defvar match-everywhere)
4626(defvar forward)
4627(defvar keymap)
4628(defvar callback-fwd) 4715(defvar callback-fwd)
4629(defvar varioref) 4716(defvar varioref)
4630(defconst reftex-select-search-minibuffer-map
4631 (let ((map (copy-keymap minibuffer-local-map)))
4632 (define-key map "\C-s"
4633 (function (lambda() (interactive) (setq forward t) (exit-minibuffer))))
4634 (define-key map "\C-r"
4635 (function (lambda() (interactive) (setq forward nil) (exit-minibuffer))))
4636 (define-key map "\C-m" 'exit-minibuffer)
4637 map))
4638 4717
4639;; The selection commands 4718;; The selection commands
4640 4719
4641(defun reftex-select-next () 4720(defun reftex-select-pre-command-hook ()
4642 (interactive) 4721 (reftex-unhighlight 1)
4722 (reftex-unhighlight 0))
4723
4724(defun reftex-select-post-command-hook ()
4725 (let (b e)
4726 (setq data (get-text-property (point) ':data))
4727 (setq last-data (or data last-data))
4728
4729 (when (and data cb-flag
4730 (not (equal reftex-last-follow-point (point))))
4731 (setq reftex-last-follow-point (point))
4732 (funcall call-back data callback-fwd
4733 (not reftex-revisit-to-follow)))
4734 (if data
4735 (setq b (or (previous-single-property-change
4736 (1+ (point)) ':data)
4737 (point-min))
4738 e (or (next-single-property-change
4739 (point) ':data)
4740 (point-max)))
4741 (setq b (point) e (point)))
4742 (and (memq reftex-highlight-selection '(cursor both))
4743 (reftex-highlight 1 b e))
4744 (if (or (not (pos-visible-in-window-p b))
4745 (not (pos-visible-in-window-p e)))
4746 (recenter (/ (window-height) 2)))
4747 (when (and (fboundp 'current-message)
4748 (not (current-message)))
4749 (princ prompt))))
4750
4751(defun reftex-select-next (&optional arg)
4752 (interactive "p")
4643 (setq callback-fwd t) 4753 (setq callback-fwd t)
4644 (or (eobp) (forward-char 1)) 4754 (or (eobp) (forward-char 1))
4645 (re-search-forward "^[^. \t\n\r]" nil t 1) 4755 (re-search-forward "^[^. \t\n\r]" nil t arg)
4646 (beginning-of-line 1)) 4756 (beginning-of-line 1))
4647(defun reftex-select-previous () 4757(defun reftex-select-previous (&optional arg)
4648 (interactive) 4758 (interactive "p")
4649 (setq callback-fwd nil)
4650 (re-search-backward "^[^. \t\n\r]" nil t))
4651(defun reftex-select-scroll-up ()
4652 (interactive)
4653 (setq callback-fwd t)
4654 (while (and (pos-visible-in-window-p)
4655 (re-search-forward "^[^. \t\n\r]" nil t)))
4656 (beginning-of-line 1)
4657 (recenter 1))
4658(defun reftex-select-scroll-down ()
4659 (interactive)
4660 (setq callback-fwd nil) 4759 (setq callback-fwd nil)
4661 (while (and (pos-visible-in-window-p) 4760 (re-search-backward "^[^. \t\n\r]" nil t arg))
4662 (re-search-backward "^[^. \t\n\r]" nil t))) 4761(defun reftex-select-next-heading (&optional arg)
4663 (recenter (- (window-height) 4))) 4762 (interactive "p")
4664(defun reftex-select-next-heading ()
4665 (interactive)
4666 (end-of-line) 4763 (end-of-line)
4667 (re-search-forward "^ " nil t) 4764 (re-search-forward "^ " nil t arg)
4668 (beginning-of-line)) 4765 (beginning-of-line))
4669(defun reftex-select-previous-heading () 4766(defun reftex-select-previous-heading (&optional arg)
4670 (interactive) 4767 (interactive "p")
4671 (re-search-backward "^ " nil t)) 4768 (re-search-backward "^ " nil t arg))
4672(defun reftex-select-scroll-other-window ()
4673 (interactive)
4674 (setq skip-callback t)
4675 (scroll-other-window))
4676(defun reftex-select-scroll-other-window-down ()
4677 (interactive)
4678 (setq skip-callback t)
4679 (scroll-other-window-down nil))
4680(defun reftex-select-quit () 4769(defun reftex-select-quit ()
4681 (interactive) 4770 (interactive)
4682 (throw 'exit nil)) 4771 (throw 'myexit nil))
4772(defun reftex-select-keyboard-quit ()
4773 (interactive)
4774 (throw 'exit t))
4683(defun reftex-select-jump-to-previous () 4775(defun reftex-select-jump-to-previous ()
4684 (interactive) 4776 (interactive)
4685 (let (pos) 4777 (let (pos)
@@ -4702,19 +4794,35 @@ bibliography statement (e.g. if it was changed)."
4702 (setq varioref "\\vref") 4794 (setq varioref "\\vref")
4703 (setq varioref "\\ref")) 4795 (setq varioref "\\ref"))
4704 (force-mode-line-update)) 4796 (force-mode-line-update))
4797(defun reftex-select-show-insertion-point ()
4798 (interactive)
4799 (let ((this-window (selected-window)))
4800 (unwind-protect
4801 (progn
4802 (switch-to-buffer-other-window
4803 (marker-buffer reftex-select-return-marker))
4804 (goto-char (marker-position reftex-select-return-marker))
4805 (recenter (/ (window-height) 2)))
4806 (select-window this-window))))
4705(defun reftex-select-callback () 4807(defun reftex-select-callback ()
4706 (interactive) 4808 (interactive)
4707 (if data (funcall call-back data callback-fwd nil) (ding))) 4809 (if data (funcall call-back data callback-fwd nil) (ding)))
4708(defun reftex-select-accept () 4810(defun reftex-select-accept ()
4709 (interactive) 4811 (interactive)
4710 (throw 'exit 'return)) 4812 (throw 'myexit 'return))
4813(defun reftex-select-mouse-accept (ev)
4814 (interactive "e")
4815 (mouse-set-point ev)
4816 (setq data (get-text-property (point) ':data))
4817 (setq last-data (or data last-data))
4818 (throw 'myexit 'return))
4711(defun reftex-select-read-label () 4819(defun reftex-select-read-label ()
4712 (interactive) 4820 (interactive)
4713 (let ((label (completing-read 4821 (let ((label (completing-read
4714 "Label: " (symbol-value reftex-docstruct-symbol) 4822 "Label: " (symbol-value reftex-docstruct-symbol)
4715 nil nil reftex-prefix))) 4823 nil nil reftex-prefix)))
4716 (unless (or (equal label "") (equal label reftex-prefix)) 4824 (unless (or (equal label "") (equal label reftex-prefix))
4717 (throw 'exit label)))) 4825 (throw 'myexit label))))
4718(defun reftex-select-read-cite () 4826(defun reftex-select-read-cite ()
4719 (interactive) 4827 (interactive)
4720 (let* ((list (mapcar (lambda (x) 4828 (let* ((list (mapcar (lambda (x)
@@ -4722,70 +4830,12 @@ bibliography statement (e.g. if it was changed)."
4722 found-list)) 4830 found-list))
4723 (key (completing-read "Citation key: " list))) 4831 (key (completing-read "Citation key: " list)))
4724 (unless (equal key "") 4832 (unless (equal key "")
4725 (throw 'exit key)))) 4833 (throw 'myexit key))))
4726(defun reftex-select-help () 4834(defun reftex-select-help ()
4727 (interactive) 4835 (interactive)
4728 (with-output-to-temp-buffer "*RefTeX Help*" 4836 (with-output-to-temp-buffer "*RefTeX Help*"
4729 (princ help-string)) 4837 (princ help-string))
4730 (reftex-enlarge-to-fit "*RefTeX Help*" t) 4838 (reftex-enlarge-to-fit "*RefTeX Help*" t))
4731 (setq skip-callback t))
4732(defun reftex-select-recursive-edit ()
4733 (interactive)
4734 (set-marker reftex-recursive-edit-marker (point))
4735 (unwind-protect
4736 (progn
4737 (save-window-excursion
4738 (save-excursion
4739 (other-window 1)
4740 (message
4741 (substitute-command-keys
4742 "Recursive edit. Return to selection with \\[exit-recursive-edit]"))
4743 (recursive-edit)))
4744 (unless (equal (marker-buffer
4745 reftex-recursive-edit-marker)
4746 (current-buffer))
4747 (error "Cannot continue RefTeX from this buffer."))
4748 (goto-char reftex-recursive-edit-marker))
4749 (set-marker reftex-recursive-edit-marker nil)))
4750
4751(defun reftex-select-search-forward ()
4752 (interactive)
4753 (reftex-select-search t))
4754(defun reftex-select-search-backward ()
4755 (interactive)
4756 (reftex-select-search nil))
4757(defun reftex-select-search (forward)
4758 (let (tmp search-start matched)
4759 (if (or (and (not (eq last-cmd 'reftex-select-search-forward))
4760 (not (eq last-cmd 'reftex-select-search-backward)))
4761 (string= search-str ""))
4762 (setq tmp ; get a new string
4763 (read-from-minibuffer
4764 (if (string= search-str "")
4765 "Search: "
4766 (format "Search [%s]:" search-str))
4767 nil reftex-select-search-minibuffer-map)
4768 search-str (if (string= tmp "")
4769 search-str tmp)))
4770 (setq search-start (point))
4771 (and (not (string= search-str ""))
4772 (progn
4773 (while
4774 (and (setq matched
4775 (if forward
4776 (search-forward search-str nil 1)
4777 (search-backward search-str nil 1)))
4778 (or (>= (save-excursion
4779 (goto-char (match-beginning 0))
4780 (current-column))
4781 (window-width))
4782 (not (or (get-text-property (point) ':data)
4783 match-everywhere)))))
4784 (if matched
4785 (reftex-highlight 2 (match-beginning 0)
4786 (match-end 0))
4787 (ding)
4788 (goto-char search-start))))))
4789 4839
4790;;; =========================================================================== 4840;;; ===========================================================================
4791;;; 4841;;;
@@ -5033,16 +5083,22 @@ With argument, actually select the window showing the cross reference."
5033 (buffer-substring-no-properties (match-beginning n) (match-end n)))) 5083 (buffer-substring-no-properties (match-beginning n) (match-end n))))
5034 5084
5035(defun reftex-kill-buffer (buffer) 5085(defun reftex-kill-buffer (buffer)
5036;; Kill buffer if it exists. 5086 ;; Kill buffer if it exists.
5037 (and (setq buffer (get-buffer buffer)) 5087 (and (setq buffer (get-buffer buffer))
5038 (kill-buffer buffer))) 5088 (kill-buffer buffer)))
5039 5089
5040(defun reftex-erase-buffer (buffer) 5090(defun reftex-erase-buffer (&optional buffer)
5041;; Erase buffer if it exists. 5091 ;; Erase BUFFER if it exists. BUFFER defaults to current buffer.
5042 (and (setq buffer (get-buffer buffer)) 5092 ;; This even erases read-only buffers.
5043 (save-excursion 5093 (cond
5044 (set-buffer buffer) 5094 ((null buffer)
5045 (erase-buffer)))) 5095 ;; erase current buffer
5096 (let ((buffer-read-only nil)) (erase-buffer)))
5097 ((setq buffer (get-buffer buffer))
5098 ;; buffer exists
5099 (save-excursion
5100 (set-buffer buffer)
5101 (let ((buffer-read-only nil)) (erase-buffer))))))
5046 5102
5047(defun reftex-this-word (&optional class) 5103(defun reftex-this-word (&optional class)
5048 ;; Grab the word around point. 5104 ;; Grab the word around point.
@@ -5269,6 +5325,7 @@ With argument, actually select the window showing the cross reference."
5269 (let ((format-alist nil) 5325 (let ((format-alist nil)
5270 (auto-mode-alist (reftex-auto-mode-alist)) 5326 (auto-mode-alist (reftex-auto-mode-alist))
5271 (default-major-mode 'fundamental-mode) 5327 (default-major-mode 'fundamental-mode)
5328 (enable-local-variables nil)
5272 (after-insert-file-functions nil)) 5329 (after-insert-file-functions nil))
5273 (setq buf (find-file-noselect file))) 5330 (setq buf (find-file-noselect file)))
5274 5331
@@ -5371,16 +5428,13 @@ With argument, actually select the window showing the cross reference."
5371 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)")))) 5428 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)"))))
5372 5429
5373;; We keep a vector with several different overlays to do our highlighting. 5430;; We keep a vector with several different overlays to do our highlighting.
5374(defvar reftex-highlight-overlays [nil nil nil]) 5431(defvar reftex-highlight-overlays [nil nil])
5375 5432
5376;; Initialize the overlays 5433;; Initialize the overlays
5377(aset reftex-highlight-overlays 0 (make-overlay 1 1)) 5434(aset reftex-highlight-overlays 0 (make-overlay 1 1))
5378(overlay-put (aref reftex-highlight-overlays 0) 'face 'highlight) 5435(overlay-put (aref reftex-highlight-overlays 0) 'face 'highlight)
5379(aset reftex-highlight-overlays 1 (make-overlay 1 1)) 5436(aset reftex-highlight-overlays 1 (make-overlay 1 1))
5380(overlay-put (aref reftex-highlight-overlays 1) 'face 'highlight) 5437(overlay-put (aref reftex-highlight-overlays 1) 'face 'highlight)
5381(aset reftex-highlight-overlays 2 (make-overlay 1 1))
5382(overlay-put (aref reftex-highlight-overlays 2) 'face
5383 (if (string-match "XEmacs" emacs-version) 'zmacs-region 'region))
5384 5438
5385;; Two functions for activating and deactivation highlight overlays 5439;; Two functions for activating and deactivation highlight overlays
5386(defun reftex-highlight (index begin end &optional buffer) 5440(defun reftex-highlight (index begin end &optional buffer)
@@ -5442,7 +5496,7 @@ these variables."
5442 "Reset the symbols containing information from buffer scanning. 5496 "Reset the symbols containing information from buffer scanning.
5443This enforces rescanning the buffer on next use." 5497This enforces rescanning the buffer on next use."
5444 (if (string= reftex-last-toc-master (reftex-TeX-master-file)) 5498 (if (string= reftex-last-toc-master (reftex-TeX-master-file))
5445 (reftex-empty-toc-buffer)) 5499 (reftex-erase-buffer "*toc*"))
5446 (let ((symlist reftex-multifile-symbols) 5500 (let ((symlist reftex-multifile-symbols)
5447 symbol) 5501 symbol)
5448 (while symlist 5502 (while symlist
@@ -5673,23 +5727,9 @@ This enforces rescanning the buffer on next use."
5673 (substitute-key-definition 5727 (substitute-key-definition
5674 'previous-line 'reftex-select-previous map global-map) 5728 'previous-line 'reftex-select-previous map global-map)
5675 (substitute-key-definition 5729 (substitute-key-definition
5676 'scroll-up 'reftex-select-scroll-up map global-map) 5730 'keyboard-quit 'reftex-select-keyboard-quit map global-map)
5677 (substitute-key-definition
5678 'scroll-down 'reftex-select-scroll-down map global-map)
5679 (substitute-key-definition
5680 'scroll-other-window 'reftex-select-scroll-other-window map global-map)
5681 (substitute-key-definition
5682 'scroll-other-window-down 'reftex-select-scroll-other-window-down map global-map)
5683 (substitute-key-definition
5684 'beginning-of-buffer 'beginning-of-buffer map global-map)
5685 (substitute-key-definition
5686 'end-of-buffer 'end-of-buffer map global-map)
5687 (substitute-key-definition
5688 'keyboard-quit 'keyboard-quit map global-map)
5689 (substitute-key-definition 5731 (substitute-key-definition
5690 'newline 'reftex-select-accept map global-map) 5732 'newline 'reftex-select-accept map global-map)
5691 (substitute-key-definition
5692 'delete-other-windows 'delete-other-windows map global-map)
5693 (define-key map " " 'reftex-select-callback) 5733 (define-key map " " 'reftex-select-callback)
5694 (define-key map "n" 'reftex-select-next) 5734 (define-key map "n" 'reftex-select-next)
5695 (define-key map [(down)] 'reftex-select-next) 5735 (define-key map [(down)] 'reftex-select-next)
@@ -5698,11 +5738,16 @@ This enforces rescanning the buffer on next use."
5698 (define-key map "f" 'reftex-select-toggle-follow) 5738 (define-key map "f" 'reftex-select-toggle-follow)
5699 (define-key map "\C-m" 'reftex-select-accept) 5739 (define-key map "\C-m" 'reftex-select-accept)
5700 (define-key map [(return)] 'reftex-select-accept) 5740 (define-key map [(return)] 'reftex-select-accept)
5701 (define-key map "\C-s" 'reftex-select-search-forward)
5702 (define-key map "\C-r" 'reftex-select-search-backward)
5703 (define-key map "e" 'reftex-select-recursive-edit)
5704 (define-key map "q" 'reftex-select-quit) 5741 (define-key map "q" 'reftex-select-quit)
5742 (define-key map "." 'reftex-select-show-insertion-point)
5705 (define-key map "?" 'reftex-select-help) 5743 (define-key map "?" 'reftex-select-help)
5744 (if (string-match "XEmacs" emacs-version)
5745 (define-key map [(button2)] 'reftex-select-mouse-accept) ; XEmacs
5746 (define-key map [(mouse-2)] 'reftex-select-mouse-accept)) ; Emacs
5747
5748 (loop for key across "0123456789" do
5749 (define-key map (vector (list key)) 'digit-argument))
5750 (define-key map "-" 'negative-argument)
5706 5751
5707 (setq reftex-select-label-map map) 5752 (setq reftex-select-label-map map)
5708 (setq reftex-select-bib-map (copy-keymap map)) 5753 (setq reftex-select-bib-map (copy-keymap map))
@@ -5711,7 +5756,7 @@ This enforces rescanning the buffer on next use."
5711 5756
5712 (loop for key across "cgilrRstx#%" do 5757 (loop for key across "cgilrRstx#%" do
5713 (define-key reftex-select-label-map (vector (list key)) 5758 (define-key reftex-select-label-map (vector (list key))
5714 (list 'lambda '() '(interactive) (list 'throw '(quote exit) key)))) 5759 (list 'lambda '() '(interactive) (list 'throw '(quote myexit) key))))
5715 (define-key reftex-select-label-map "b" 'reftex-select-jump-to-previous) 5760 (define-key reftex-select-label-map "b" 'reftex-select-jump-to-previous)
5716 (define-key reftex-select-label-map "v" 'reftex-select-toggle-varioref) 5761 (define-key reftex-select-label-map "v" 'reftex-select-toggle-varioref)
5717 (define-key reftex-select-label-map [(tab)] 'reftex-select-read-label) 5762 (define-key reftex-select-label-map [(tab)] 'reftex-select-read-label)
@@ -5721,14 +5766,15 @@ This enforces rescanning the buffer on next use."
5721 5766
5722 (loop for key across "grRa" do 5767 (loop for key across "grRa" do
5723 (define-key reftex-select-bib-map (vector (list key)) 5768 (define-key reftex-select-bib-map (vector (list key))
5724 (list 'lambda '() '(interactive) (list 'throw '(quote exit) key)))) 5769 (list 'lambda '() '(interactive) (list 'throw '(quote myexit) key))))
5725 (define-key reftex-select-bib-map "\C-i" 'reftex-select-read-cite) 5770 (define-key reftex-select-bib-map "\C-i" 'reftex-select-read-cite)
5726 (define-key reftex-select-bib-map [(tab)] 'reftex-select-read-cite)) 5771 (define-key reftex-select-bib-map [(tab)] 'reftex-select-read-cite))
5727 5772
5728;; Table of Contents map 5773;; Table of Contents map
5729(let ((map reftex-toc-map)) 5774(let ((map reftex-toc-map))
5730 (define-key map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide); Emacs 5775 (if (string-match "XEmacs" emacs-version)
5731 (define-key map [(button2)] 'reftex-toc-mouse-goto-line-and-hide); XEmacs 5776 (define-key map [(button2)] 'reftex-toc-mouse-goto-line-and-hide);XEmacs
5777 (define-key map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide)) ;Emacs
5732 (define-key map "n" 'next-line) 5778 (define-key map "n" 'next-line)
5733 (define-key map "p" 'previous-line) 5779 (define-key map "p" 'previous-line)
5734 (define-key map "?" 'reftex-toc-show-help) 5780 (define-key map "?" 'reftex-toc-show-help)