2001-07-16 07:46:48 +00:00
|
|
|
;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
|
2006-12-09 03:59:33 +00:00
|
|
|
|
2006-12-09 03:59:52 +00:00
|
|
|
;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
2009-01-05 03:18:22 +00:00
|
|
|
;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
1999-12-30 02:57:12 +00:00
|
|
|
|
2002-07-22 10:38:32 +00:00
|
|
|
;; Author: Carsten Dominik <dominik@science.uva.nl>
|
2007-03-22 21:06:43 +00:00
|
|
|
;; Maintainer: auctex-devel@gnu.org
|
2006-02-22 07:21:49 +00:00
|
|
|
;; Version: 4.31
|
1999-12-30 02:57:12 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 04:34:22 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1999-12-30 02:57:12 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 04:34:22 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1999-12-30 02:57:12 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 04:34:22 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1999-08-16 07:42:41 +00:00
|
|
|
|
2001-07-16 07:46:48 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
* reftex.el (reftex-compile-variables): respect new structure of
`reftex-index-macro'
(reftex-compile-variables): Use the changed structure of
`reftex-label-alist'.
* reftex-vars.el (reftex-index-math-format,
(reftex-toc-max-level): New option.
reftex-index-phrases-search-whole-words,
reftex-index-phrases-case-fold-search,
reftex-index-phrases-skip-indexed-matches,
reftex-index-phrases-wrap-long-lines,
reftex-index-phrases-sort-prefers-entry,
reftex-index-phrases-sort-in-blocks): New options.
(reftex-index-macros): Option structure changed.
(reftex-index-macros-builtin): Added `repeat' item to each entry.
(reftex-label-alist): Additional item in each entry to specify if
the environment should be listed in the TOC.
(eval-when-compile (require 'cl)) added.
* reftex-index.el (reftex-index-selection-or-word): No longer
deals with "repeat".
(reftex-index): "repeat property in `reftex-index-macro-alist' is
now used.
(reftex-index-phrases-comment-regexp,
reftex-index-phrases-macrodef-regexp,
reftex-index-phrases-phrase-regexp1,
reftex-index-phrases-phrase-regexp2,
reftex-index-phrases-phrase-regexp12, reftex-index-phrases-help):
New constants.
(reftex-index-phrases-macro-data, reftex-index-phrases-files,
reftex-index-phrases-font-lock-keywords,
reftex-index-phrases-font-lock-defaults, reftex-index-phrases-map,
reftex-index-phrases-restrict-file): New variables.
(reftex-index-phrase-selection-or-word,
reftex-index-visit-phrases-buffer,
reftex-index-initialize-phrases-buffer,
reftex-index-phrases-save-and-return, reftex-index-phrases-mode,
reftex-index-next-phrase, reftex-index-this-phrase,
reftex-index-all-phrases, reftex-index-region-phrases,
reftex-index-phrases-parse-header,
reftex-index-phrases-toggle-restricted, reftex-index-new-phrase,
reftex-index-find-next-conflict-phrase, reftex-index-phrases-info,
reftex-index-phrases-set-macro-key, reftex-index-sort-phrases,
reftex-compare-phrase-lines, reftex-index-make-phrase-regexp,
reftex-index-simplify-phrase, reftex-index-phrases-find-dup-re,
reftex-index-make-replace-string,
reftex-query-index-phrase-globally, reftex-query-index-phrase,
reftex-index-phrase-match-is-indexed,
reftex-index-phrases-fixup-line,
reftex-index-phrases-replace-space,
reftex-index-select-phrases-macro): New functions.
(reftex-index-globalize, reftex-index-globally): functions removed
(eval-when-compile (require 'cl)) added.
* reftex-toc.el (reftex-toc-mode): Create new indicator for max
level.
(reftex-toc-max-level-indicator): New variable.
(reftex-toc-max-level): New command.
(reftex-toc-map): New keybinding `t'.
(reftex-toc-help): Constant updated.
(eval-when-compile (require 'cl)) added.
* reftex-ref.el (reftex-offer-label-menu): Prefix to `t' command key
can change `reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-sel (reftex-insert-docstruct): Respect
`reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-auc.el (eval-when-compile (require 'cl)) added.
* reftex-vcr.el (eval-when-compile (require 'cl)) added.
* reftex-cite.el (reftex-citep, reftex-citet): New commands.
(reftex-citation, reftex-do-citation,
reftex-figure-out-cite-format): Additional argument FORMAT-KEY to
preselect a citation format.
(eval-when-compile (require 'cl)) added.
* reftex-parse.el (reftex-context-substring): Optional parameter
to-end
(reftex-section-info): Deal with environment matches.
(eval-when-compile (require 'cl)) added.
* reftex-global.el (eval-when-compile (require 'cl)) added.
1999-12-15 17:02:38 +00:00
|
|
|
(eval-when-compile (require 'cl))
|
2000-01-05 09:15:48 +00:00
|
|
|
(provide 'reftex-dcr)
|
2000-01-05 15:15:41 +00:00
|
|
|
(provide 'reftex-vcr)
|
1999-08-16 07:42:41 +00:00
|
|
|
(require 'reftex)
|
|
|
|
;;;
|
|
|
|
|
2006-02-22 07:21:49 +00:00
|
|
|
(defun reftex-view-crossref (&optional arg auto-how fail-quietly)
|
1999-08-16 07:42:41 +00:00
|
|
|
"View cross reference of macro at point. Point must be on the KEY
|
2001-03-19 16:47:40 +00:00
|
|
|
argument. When at at `\\ref' macro, show corresponding `\\label'
|
1999-08-16 07:42:41 +00:00
|
|
|
definition, also in external documents (`xr'). When on a label, show
|
|
|
|
a locations where KEY is referenced. Subsequent calls find additional
|
2001-03-19 16:47:40 +00:00
|
|
|
locations. When on a `\\cite', show the associated `\\bibitem' macro or
|
|
|
|
the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro
|
|
|
|
which uses this KEY. When on an `\\index', show other locations marked
|
1999-08-16 07:42:41 +00:00
|
|
|
by the same index entry.
|
|
|
|
To define additional cross referencing items, use the option
|
|
|
|
`reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'.
|
|
|
|
With one or two C-u prefixes, enforce rescanning of the document.
|
|
|
|
With argument 2, select the window showing the cross reference.
|
|
|
|
AUTO-HOW is only for the automatic crossref display and is handed through
|
|
|
|
to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'."
|
|
|
|
|
|
|
|
(interactive "P")
|
|
|
|
;; See where we are.
|
|
|
|
(let* ((macro (car (reftex-what-macro-safe 1)))
|
2000-12-19 11:09:28 +00:00
|
|
|
(key (reftex-this-word "^{}%\n\r, \t"))
|
2003-08-11 12:27:02 +00:00
|
|
|
dw)
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(if (or (null macro) (reftex-in-comment))
|
2006-02-22 07:21:49 +00:00
|
|
|
(or fail-quietly
|
|
|
|
(error "Not on a crossref macro argument"))
|
|
|
|
|
|
|
|
(setq reftex-call-back-to-this-buffer (current-buffer))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro)
|
|
|
|
;; A citation macro: search for bibitems or BibTeX entries
|
|
|
|
(setq dw (reftex-view-cr-cite arg key auto-how)))
|
|
|
|
((string-match "\\`\\\\ref\\|ref\\(range\\)?\\*?\\'" macro)
|
|
|
|
;; A reference macro: search for labels
|
|
|
|
(setq dw (reftex-view-cr-ref arg key auto-how)))
|
|
|
|
(auto-how nil) ;; No further action for automatic display (speed)
|
|
|
|
((or (equal macro "\\label")
|
|
|
|
(member macro reftex-macros-with-labels))
|
|
|
|
;; A label macro: search for reference macros
|
|
|
|
(reftex-access-scan-info arg)
|
|
|
|
(setq dw (reftex-view-regexp-match
|
|
|
|
(format reftex-find-reference-format (regexp-quote key))
|
|
|
|
4 nil nil)))
|
|
|
|
((equal macro "\\bibitem")
|
|
|
|
;; A bibitem macro: search for citations
|
|
|
|
(reftex-access-scan-info arg)
|
|
|
|
(setq dw (reftex-view-regexp-match
|
|
|
|
(format reftex-find-citation-regexp-format (regexp-quote key))
|
|
|
|
4 nil nil)))
|
|
|
|
((member macro reftex-macros-with-index)
|
|
|
|
(reftex-access-scan-info arg)
|
|
|
|
(setq dw (reftex-view-regexp-match
|
|
|
|
(format reftex-find-index-entry-regexp-format
|
|
|
|
(regexp-quote key))
|
|
|
|
3 nil nil)))
|
|
|
|
(t
|
|
|
|
(reftex-access-scan-info arg)
|
|
|
|
(catch 'exit
|
|
|
|
(let ((list reftex-view-crossref-extra)
|
|
|
|
entry mre action group)
|
|
|
|
(while (setq entry (pop list))
|
|
|
|
(setq mre (car entry)
|
|
|
|
action (nth 1 entry)
|
|
|
|
group (nth 2 entry))
|
|
|
|
(when (string-match mre macro)
|
|
|
|
(setq dw (reftex-view-regexp-match
|
|
|
|
(format action key) group nil nil))
|
|
|
|
(throw 'exit t))))
|
|
|
|
(error "Not on a crossref macro argument"))))
|
|
|
|
(if (and (eq arg 2) (windowp dw)) (select-window dw)))))
|
2003-08-11 12:27:02 +00:00
|
|
|
|
1999-08-16 07:42:41 +00:00
|
|
|
(defun reftex-view-cr-cite (arg key how)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; View crossreference of a ref cite. HOW can have the values
|
1999-08-16 07:42:41 +00:00
|
|
|
;; nil: Show in another window.
|
|
|
|
;; echo: Show one-line info in echo area.
|
|
|
|
;; tmp-window: Show in small window and arrange for window to disappear.
|
|
|
|
|
|
|
|
;; Ensure access to scanning info
|
|
|
|
(reftex-access-scan-info (or arg current-prefix-arg))
|
|
|
|
|
|
|
|
(if (eq how 'tmp-window)
|
|
|
|
;; Remember the window configuration
|
2003-08-11 12:27:02 +00:00
|
|
|
(put 'reftex-auto-view-crossref 'last-window-conf
|
|
|
|
(current-window-configuration)))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
2002-08-20 10:42:52 +00:00
|
|
|
(let (files size item (pos (point)) (win (selected-window)) pop-win
|
2003-08-11 12:27:02 +00:00
|
|
|
(bibtype (reftex-bib-or-thebib)))
|
1999-08-16 07:42:41 +00:00
|
|
|
;; Find the citation mode and the file list
|
|
|
|
(cond
|
2002-08-20 10:42:52 +00:00
|
|
|
; ((assq 'bib (symbol-value reftex-docstruct-symbol))
|
|
|
|
((eq bibtype 'bib)
|
1999-08-16 07:42:41 +00:00
|
|
|
(setq item nil
|
2003-08-11 12:27:02 +00:00
|
|
|
files (reftex-get-bibfile-list)))
|
2002-08-20 10:42:52 +00:00
|
|
|
; ((assq 'thebib (symbol-value reftex-docstruct-symbol))
|
|
|
|
((eq bibtype 'thebib)
|
1999-08-16 07:42:41 +00:00
|
|
|
(setq item t
|
2003-08-11 12:27:02 +00:00
|
|
|
files (reftex-uniquify
|
|
|
|
(mapcar 'cdr
|
|
|
|
(reftex-all-assq
|
|
|
|
'thebib (symbol-value reftex-docstruct-symbol))))))
|
1999-08-16 07:42:41 +00:00
|
|
|
(reftex-default-bibliography
|
|
|
|
(setq item nil
|
2003-08-11 12:27:02 +00:00
|
|
|
files (reftex-default-bibliography)))
|
1999-08-16 07:42:41 +00:00
|
|
|
(how) ;; don't throw for special display
|
|
|
|
(t (error "Cannot display crossref")))
|
|
|
|
|
|
|
|
(if (eq how 'echo)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; Display in Echo area
|
|
|
|
(reftex-echo-cite key files item)
|
1999-08-16 07:42:41 +00:00
|
|
|
;; Display in a window
|
|
|
|
(if (not (eq how 'tmp-window))
|
2003-08-11 12:27:02 +00:00
|
|
|
;; Normal display
|
|
|
|
(reftex-pop-to-bibtex-entry key files nil t item)
|
|
|
|
;; A temporary window
|
|
|
|
(condition-case nil
|
|
|
|
(reftex-pop-to-bibtex-entry key files nil t item)
|
|
|
|
(error (goto-char pos)
|
|
|
|
(message "cite: no such citation key %s" key)
|
|
|
|
(error "")))
|
|
|
|
;; Resize the window
|
|
|
|
(setq size (max 1 (count-lines (point)
|
|
|
|
(reftex-end-of-bib-entry item))))
|
|
|
|
(let ((window-min-height 2))
|
|
|
|
(shrink-window (1- (- (window-height) size)))
|
|
|
|
(recenter 0))
|
|
|
|
;; Arrange restoration
|
|
|
|
(add-hook 'pre-command-hook 'reftex-restore-window-conf))
|
|
|
|
|
|
|
|
;; Normal display in other window
|
1999-08-16 07:42:41 +00:00
|
|
|
(add-hook 'pre-command-hook 'reftex-highlight-shall-die)
|
|
|
|
(setq pop-win (selected-window))
|
|
|
|
(select-window win)
|
|
|
|
(goto-char pos)
|
|
|
|
(when (equal arg 2)
|
2003-08-11 12:27:02 +00:00
|
|
|
(select-window pop-win)))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defun reftex-view-cr-ref (arg label how)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; View crossreference of a ref macro. HOW can have the values
|
1999-08-16 07:42:41 +00:00
|
|
|
;; nil: Show in another window.
|
|
|
|
;; echo: Show one-line info in echo area.
|
|
|
|
;; tmp-window: Show in small window and arrange for window to disappear.
|
|
|
|
|
|
|
|
;; Ensure access to scanning info
|
|
|
|
(reftex-access-scan-info (or arg current-prefix-arg))
|
2003-08-11 12:27:02 +00:00
|
|
|
|
1999-08-16 07:42:41 +00:00
|
|
|
(if (eq how 'tmp-window)
|
|
|
|
;; Remember the window configuration
|
2003-08-11 12:27:02 +00:00
|
|
|
(put 'reftex-auto-view-crossref 'last-window-conf
|
|
|
|
(current-window-configuration)))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol)))
|
2003-08-11 12:27:02 +00:00
|
|
|
(xr-re (nth 2 xr-data))
|
|
|
|
(entry (assoc label (symbol-value reftex-docstruct-symbol)))
|
|
|
|
(win (selected-window)) pop-win (pos (point)))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(if (and (not entry) (stringp label) xr-re (string-match xr-re label))
|
2003-08-11 12:27:02 +00:00
|
|
|
;; Label is defined in external document
|
|
|
|
(save-excursion
|
|
|
|
(save-match-data
|
|
|
|
(set-buffer
|
|
|
|
(or (reftex-get-file-buffer-force
|
|
|
|
(cdr (assoc (match-string 1 label) (nth 1
|
|
|
|
xr-data))))
|
|
|
|
(error "Problem with external label %s" label))))
|
|
|
|
(setq label (substring label (match-end 1)))
|
|
|
|
(reftex-access-scan-info)
|
|
|
|
(setq entry
|
|
|
|
(assoc label (symbol-value reftex-docstruct-symbol)))))
|
1999-08-16 07:42:41 +00:00
|
|
|
(if (eq how 'echo)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; Display in echo area
|
|
|
|
(reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol))
|
1999-08-16 07:42:41 +00:00
|
|
|
(let ((window-conf (current-window-configuration)))
|
2003-08-11 12:27:02 +00:00
|
|
|
(condition-case nil
|
|
|
|
(reftex-show-label-location entry t nil t t)
|
|
|
|
(error (set-window-configuration window-conf)
|
|
|
|
(message "ref: Label %s not found" label)
|
|
|
|
(error "ref: Label %s not found" label)))) ;; 2nd is line OK
|
1999-08-16 07:42:41 +00:00
|
|
|
(add-hook 'pre-command-hook 'reftex-highlight-shall-die)
|
|
|
|
|
|
|
|
(when (eq how 'tmp-window)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; Resize window and arrange restauration
|
|
|
|
(shrink-window (1- (- (window-height) 9)))
|
|
|
|
(recenter '(4))
|
|
|
|
(add-hook 'pre-command-hook 'reftex-restore-window-conf))
|
1999-08-16 07:42:41 +00:00
|
|
|
(setq pop-win (selected-window))
|
|
|
|
(select-window win)
|
|
|
|
(goto-char pos)
|
|
|
|
(when (equal arg 2)
|
2003-08-11 12:27:02 +00:00
|
|
|
(select-window pop-win)))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defun reftex-mouse-view-crossref (ev)
|
|
|
|
"View cross reference of \\ref or \\cite macro where you click.
|
|
|
|
If the macro at point is a \\ref, show the corresponding label definition.
|
|
|
|
If it is a \\cite, show the BibTeX database entry.
|
|
|
|
If there is no such macro at point, search forward to find one.
|
|
|
|
With argument, actually select the window showing the cross reference."
|
|
|
|
(interactive "e")
|
|
|
|
(mouse-set-point ev)
|
|
|
|
(reftex-view-crossref current-prefix-arg))
|
|
|
|
|
|
|
|
(defun reftex-view-crossref-when-idle ()
|
|
|
|
;; Display info about crossref at point in echo area or a window.
|
|
|
|
;; This function was desigend to work with an idle timer.
|
|
|
|
;; We try to get out of here as quickly as possible if the call is useless.
|
|
|
|
(and reftex-mode
|
|
|
|
;; Make sure message area is free if we need it.
|
|
|
|
(or (eq reftex-auto-view-crossref 'window) (not (current-message)))
|
|
|
|
;; Make sure we are not already displaying this one
|
|
|
|
(not (memq last-command '(reftex-view-crossref
|
2003-08-11 12:27:02 +00:00
|
|
|
reftex-mouse-view-crossref)))
|
1999-08-16 07:42:41 +00:00
|
|
|
;; Quick precheck if this might be a relevant spot
|
2006-02-22 07:21:49 +00:00
|
|
|
;; `reftex-view-crossref' will do a more thorough check.
|
2003-08-11 12:27:02 +00:00
|
|
|
(save-excursion
|
|
|
|
(search-backward "\\" nil t)
|
|
|
|
(looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(condition-case nil
|
2003-08-11 12:27:02 +00:00
|
|
|
(let ((current-prefix-arg nil))
|
|
|
|
(cond
|
|
|
|
((eq reftex-auto-view-crossref t)
|
2006-02-22 07:21:49 +00:00
|
|
|
(reftex-view-crossref -1 'echo 'quiet))
|
2003-08-11 12:27:02 +00:00
|
|
|
((eq reftex-auto-view-crossref 'window)
|
2006-02-22 07:21:49 +00:00
|
|
|
(reftex-view-crossref -1 'tmp-window 'quiet))
|
2003-08-11 12:27:02 +00:00
|
|
|
(t nil)))
|
|
|
|
(error nil))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defun reftex-restore-window-conf ()
|
|
|
|
(set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf))
|
|
|
|
(put 'reftex-auto-view-crossref 'last-window-conf nil)
|
|
|
|
(remove-hook 'pre-command-hook 'reftex-restore-window-conf))
|
2003-08-11 12:27:02 +00:00
|
|
|
|
1999-08-16 07:42:41 +00:00
|
|
|
(defun reftex-echo-ref (label entry docstruct)
|
|
|
|
;; Display crossref info in echo area.
|
|
|
|
(cond
|
|
|
|
((null docstruct)
|
2006-02-22 07:21:49 +00:00
|
|
|
(message "%s"
|
|
|
|
(substitute-command-keys (format reftex-no-info-message "ref"))))
|
1999-08-16 07:42:41 +00:00
|
|
|
((null entry)
|
|
|
|
(message "ref: unknown label: %s" label))
|
|
|
|
(t
|
|
|
|
(when (stringp (nth 2 entry))
|
|
|
|
(message "ref(%s): %s" (nth 1 entry) (nth 2 entry)))
|
|
|
|
(let ((buf (get-buffer " *Echo Area*")))
|
|
|
|
(when buf
|
2003-08-11 12:27:02 +00:00
|
|
|
(save-excursion
|
|
|
|
(set-buffer buf)
|
|
|
|
(run-hooks 'reftex-display-copied-context-hook)))))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defun reftex-echo-cite (key files item)
|
|
|
|
;; Display citation info in echo area.
|
|
|
|
(let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol)))
|
2003-08-11 12:27:02 +00:00
|
|
|
(cache-entry (assoc key (cdr cache)))
|
|
|
|
entry string buf (all-files files))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(if (and reftex-cache-cite-echo cache-entry)
|
2003-08-11 12:27:02 +00:00
|
|
|
;; We can just use the cache
|
|
|
|
(setq string (cdr cache-entry))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
;; Need to look in the database
|
|
|
|
(unless reftex-revisit-to-echo
|
2003-08-11 12:27:02 +00:00
|
|
|
(setq files (reftex-visited-files files)))
|
|
|
|
|
|
|
|
(setq entry
|
|
|
|
(condition-case nil
|
|
|
|
(save-excursion
|
|
|
|
(reftex-pop-to-bibtex-entry key files nil nil item t))
|
|
|
|
(error
|
|
|
|
(if (and files (= (length all-files) (length files)))
|
|
|
|
(message "cite: no such database entry: %s" key)
|
2005-09-18 12:28:30 +00:00
|
|
|
(message "%s" (substitute-command-keys
|
2006-02-22 07:21:49 +00:00
|
|
|
(format reftex-no-info-message "cite"))))
|
2003-08-11 12:27:02 +00:00
|
|
|
nil)))
|
1999-08-16 07:42:41 +00:00
|
|
|
(when entry
|
2003-08-11 12:27:02 +00:00
|
|
|
(if item
|
|
|
|
(setq string (reftex-nicify-text entry))
|
|
|
|
(setq string (reftex-make-cite-echo-string
|
|
|
|
(reftex-parse-bibtex-entry entry)
|
|
|
|
reftex-docstruct-symbol)))))
|
1999-08-16 07:42:41 +00:00
|
|
|
(unless (or (null string) (equal string ""))
|
|
|
|
(message "cite: %s" string))
|
|
|
|
(when (setq buf (get-buffer " *Echo Area*"))
|
|
|
|
(save-excursion
|
2003-08-11 12:27:02 +00:00
|
|
|
(set-buffer buf)
|
|
|
|
(run-hooks 'reftex-display-copied-context-hook)))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defvar reftex-use-itimer-in-xemacs nil
|
|
|
|
"*Non-nil means use the idle timers in XEmacs for crossref display.
|
|
|
|
Currently, idle timer restart is broken and we use the post-command-hook.")
|
|
|
|
|
|
|
|
(defun reftex-toggle-auto-view-crossref ()
|
|
|
|
"Toggle the automatic display of crossref information in the echo area.
|
|
|
|
When active, leaving point idle in the argument of a \\ref or \\cite macro
|
|
|
|
will display info in the echo area."
|
|
|
|
(interactive)
|
|
|
|
(if reftex-auto-view-crossref-timer
|
|
|
|
(progn
|
2003-08-11 12:27:02 +00:00
|
|
|
(if (featurep 'xemacs)
|
|
|
|
(if reftex-use-itimer-in-xemacs
|
|
|
|
(delete-itimer reftex-auto-view-crossref-timer)
|
|
|
|
(remove-hook 'post-command-hook 'reftex-start-itimer-once))
|
|
|
|
(cancel-timer reftex-auto-view-crossref-timer))
|
|
|
|
(setq reftex-auto-view-crossref-timer nil)
|
|
|
|
(message "Automatic display of crossref information was turned off"))
|
1999-08-16 07:42:41 +00:00
|
|
|
(setq reftex-auto-view-crossref-timer
|
2003-08-11 12:27:02 +00:00
|
|
|
(if (featurep 'xemacs)
|
|
|
|
(if reftex-use-itimer-in-xemacs
|
|
|
|
(start-itimer "RefTeX Idle Timer"
|
|
|
|
'reftex-view-crossref-when-idle
|
|
|
|
reftex-idle-time reftex-idle-time t)
|
|
|
|
(add-hook 'post-command-hook 'reftex-start-itimer-once)
|
|
|
|
t)
|
|
|
|
(run-with-idle-timer
|
|
|
|
reftex-idle-time t 'reftex-view-crossref-when-idle)))
|
1999-08-16 07:42:41 +00:00
|
|
|
(unless reftex-auto-view-crossref
|
|
|
|
(setq reftex-auto-view-crossref t))
|
|
|
|
(message "Automatic display of crossref information was turned on")))
|
|
|
|
|
|
|
|
(defun reftex-start-itimer-once ()
|
* smime.el (from):
* rfc2047.el (message-posting-charset):
* qp.el (mm-use-ultra-safe-encoding):
* pop3.el (parse-time-months):
* nnrss.el (mm-text-html-renderer, mm-text-html-washer-alist):
* nnml.el (files):
* nnheader.el (gnus-newsgroup-name, nnheader-file-coding-system)
(jka-compr-compression-info-list, ange-ftp-path-format)
(efs-path-regexp):
* nndiary.el (files):
* mml2015.el (mc-default-scheme, mc-schemes, pgg-default-user-id)
(pgg-errors-buffer, pgg-output-buffer, epg-user-id-alist)
(epg-digest-algorithm-alist, inhibit-redisplay)
(password-cache-expiry):
* mml1991.el (pgg-default-user-id, pgg-errors-buffer)
(pgg-output-buffer, password-cache-expiry):
* mml.el (mml-dnd-protocol-alist, ange-ftp-name-format)
(efs-path-regexp):
* mml-smime.el (epg-user-id-alist, epg-digest-algorithm-alist)
(inhibit-redisplay):
* mm-uu.el (file-name, start-point, end-point, entry)
(gnus-newsgroup-name, gnus-newsgroup-charset):
* mm-util.el (mm-mime-mule-charset-alist, latin-unity-coding-systems)
(latin-unity-ucs-list):
* mm-bodies.el (mm-uu-yenc-decode-function, mm-uu-decode-function)
(mm-uu-binhex-decode-function):
* message.el (gnus-message-group-art, gnus-list-identifiers, )
(rmail-enable-mime-composing, gnus-local-organization)
(gnus-post-method, gnus-select-method, gnus-active-hashtb)
(gnus-read-active-file, facemenu-add-face-function)
(facemenu-remove-face-function, gnus-article-decoded-p)
(tool-bar-mode):
* mail-source.el (display-time-mail-function):
* gnus-util.el (nnmail-pathname-coding-system)
(nnmail-active-file-coding-system, gnus-emphasize-whitespace-regexp)
(gnus-original-article-buffer, gnus-user-agent)
(rmail-default-rmail-file, mm-text-coding-system, tool-bar-mode)
(xemacs-codename, sxemacs-codename, emacs-program-version):
* gnus-sum.el (tool-bar-mode, gnus-tmp-header, number):
* gnus-start.el (gnus-agent-covered-methods)
(gnus-agent-file-loading-local, gnus-agent-file-loading-cache)
(gnus-current-headers, gnus-thread-indent-array, gnus-newsgroup-name)
(gnus-newsgroup-headers, gnus-group-list-mode)
(gnus-group-mark-positions, gnus-newsgroup-data)
(gnus-newsgroup-unreads, nnoo-state-alist)
(gnus-current-select-method, mail-sources)
(nnmail-scan-directory-mail-source-once, nnmail-split-history)
(nnmail-spool-file, gnus-cache-active-hashtb):
* gnus-mh.el (mh-lib-progs):
* gnus-ems.el (gnus-tmp-unread, gnus-tmp-replied)
(gnus-tmp-score-char, gnus-tmp-indentation, gnus-tmp-opening-bracket)
(gnus-tmp-lines, gnus-tmp-name, gnus-tmp-closing-bracket)
(gnus-tmp-subject-or-nil, gnus-check-before-posting, gnus-mouse-face)
(gnus-group-buffer):
* gnus-cite.el (font-lock-defaults-computed, font-lock-keywords)
(font-lock-set-defaults):
* gnus-art.el (tool-bar-map, w3m-minor-mode-map)
(gnus-face-properties-alist, charset, gnus-summary-article-menu)
(gnus-summary-post-menu, total-parts, type, condition, length):
* gnus-agent.el (gnus-agent-read-agentview):
* flow-fill.el (show-trailing-whitespace):
* gnus-group.el (tool-bar-mode, nnrss-group-alist): Remove unnecessary
eval-and-compile wrappers for byte compiler pacifiers.
* mm-view.el (mm-inline-image-xemacs): Only do something for XEmacs.
(mm-display-inline-fontify): Check for featurep 'xemacs not
extent-list.
* mm-decode.el (mm-display-external): Check for featurep 'xemacs not
itimer-list.
(mm-create-image-xemacs): Only do something for XEmacs.
(mm-image-fit-p): Check for featurep 'xemacs not glyph-width.
* mm-util.el (mm-find-buffer-file-coding-system): Add check for XEmacs.
* gnus-registry.el (gnus-adaptive-word-syntax-table):
* gnus-fun.el (gnus-face-properties-alist): Pacify byte compiler.
* textmodes/reftex-dcr.el (reftex-start-itimer-once): Add check
for XEmacs.
* calc/calc-menu.el (calc-mode-map): Pacify byte compiler.
* doc-view.el (doc-view-resolution): Add missing :group.
2007-11-16 16:50:35 +00:00
|
|
|
(and (featurep 'xemacs) reftex-mode
|
2003-08-11 12:27:02 +00:00
|
|
|
(not (itimer-live-p reftex-auto-view-crossref-timer))
|
|
|
|
(setq reftex-auto-view-crossref-timer
|
|
|
|
(start-itimer "RefTeX Idle Timer"
|
|
|
|
'reftex-view-crossref-when-idle
|
|
|
|
reftex-idle-time nil t))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
2007-11-20 00:57:10 +00:00
|
|
|
(declare-function bibtex-beginning-of-entry "bibtex" ())
|
|
|
|
|
1999-08-16 07:42:41 +00:00
|
|
|
(defun reftex-view-crossref-from-bibtex (&optional arg)
|
|
|
|
"View location in a LaTeX document which cites the BibTeX entry at point.
|
|
|
|
Since BibTeX files can be used by many LaTeX documents, this function
|
|
|
|
prompts upon first use for a buffer in RefTeX mode. To reset this
|
|
|
|
link to a document, call the function with with a prefix arg.
|
|
|
|
Calling this function several times find successive citation locations."
|
|
|
|
(interactive "P")
|
2003-08-11 12:27:02 +00:00
|
|
|
(when arg
|
1999-08-16 07:42:41 +00:00
|
|
|
;; Break connection to reference buffer
|
2000-06-20 12:52:00 +00:00
|
|
|
(put 'reftex-bibtex-view-cite-locations :ref-buffer nil))
|
1999-08-16 07:42:41 +00:00
|
|
|
(let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer)))
|
|
|
|
;; Establish connection to reference buffer
|
|
|
|
(unless ref-buffer
|
|
|
|
(setq ref-buffer
|
2003-08-11 12:27:02 +00:00
|
|
|
(save-excursion
|
|
|
|
(completing-read
|
|
|
|
"Reference buffer: "
|
|
|
|
(delq nil
|
|
|
|
(mapcar
|
|
|
|
(lambda (b)
|
|
|
|
(set-buffer b)
|
|
|
|
(if reftex-mode (list (buffer-name b)) nil))
|
|
|
|
(buffer-list)))
|
|
|
|
nil t)))
|
1999-08-16 07:42:41 +00:00
|
|
|
(put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer))
|
|
|
|
;; Search for citations
|
|
|
|
(bibtex-beginning-of-entry)
|
|
|
|
(if (looking-at
|
2003-08-11 12:27:02 +00:00
|
|
|
"@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)")
|
|
|
|
(progn
|
|
|
|
(goto-char (match-beginning 1))
|
|
|
|
(reftex-view-regexp-match
|
|
|
|
(format reftex-find-citation-regexp-format
|
|
|
|
(regexp-quote (match-string 1)))
|
|
|
|
4 arg ref-buffer))
|
1999-08-16 07:42:41 +00:00
|
|
|
(error "Cannot find citation key in BibTeX entry"))))
|
|
|
|
|
|
|
|
(defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer)
|
|
|
|
;; Search for RE in current document or in the document of REF-BUFFER.
|
|
|
|
;; Continue the search, if the same re was searched last.
|
|
|
|
;; Highlight the group HIGHLIGHT-GROUP of the match.
|
|
|
|
;; When NEW is non-nil, start a new search regardless.
|
|
|
|
;; Match point is displayed in another window.
|
|
|
|
;; Upon success, returns the window which displays the match.
|
|
|
|
|
|
|
|
;;; Decide if new search or continued search
|
|
|
|
(let* ((oldprop (get 'reftex-view-regexp-match :props))
|
2003-08-11 12:27:02 +00:00
|
|
|
(newprop (list (current-buffer) re))
|
|
|
|
(cont (and (not new) (equal oldprop newprop)))
|
|
|
|
(cnt (if cont (get 'reftex-view-regexp-match :cnt) 0))
|
|
|
|
(current-window (selected-window))
|
|
|
|
(window-conf (current-window-configuration))
|
|
|
|
match pop-window)
|
1999-08-16 07:42:41 +00:00
|
|
|
(switch-to-buffer-other-window (or ref-buffer (current-buffer)))
|
|
|
|
;; Search
|
|
|
|
(condition-case nil
|
2003-08-11 12:27:02 +00:00
|
|
|
(if cont
|
|
|
|
(setq match (reftex-global-search-continue))
|
|
|
|
(reftex-access-scan-info)
|
|
|
|
(setq match (reftex-global-search re (reftex-all-document-files))))
|
1999-08-16 07:42:41 +00:00
|
|
|
(error nil))
|
|
|
|
;; Evaluate the match.
|
|
|
|
(if match
|
2003-08-11 12:27:02 +00:00
|
|
|
(progn
|
|
|
|
(put 'reftex-view-regexp-match :props newprop)
|
|
|
|
(put 'reftex-view-regexp-match :cnt (incf cnt))
|
|
|
|
(reftex-highlight 0 (match-beginning highlight-group)
|
|
|
|
(match-end highlight-group))
|
|
|
|
(add-hook 'pre-command-hook 'reftex-highlight-shall-die)
|
|
|
|
(setq pop-window (selected-window)))
|
2000-06-20 12:52:00 +00:00
|
|
|
(put 'reftex-view-regexp-match :props nil)
|
1999-08-16 07:42:41 +00:00
|
|
|
(or cont (set-window-configuration window-conf)))
|
|
|
|
(select-window current-window)
|
|
|
|
(if match
|
2003-08-11 12:27:02 +00:00
|
|
|
(progn
|
|
|
|
(message "Match Nr. %s" cnt)
|
|
|
|
pop-window)
|
1999-08-16 07:42:41 +00:00
|
|
|
(if cont
|
2003-08-11 12:27:02 +00:00
|
|
|
(error "No further matches (total number of matches: %d)" cnt)
|
|
|
|
(error "No matches")))))
|
1999-08-16 07:42:41 +00:00
|
|
|
|
|
|
|
(defvar reftex-global-search-marker (make-marker))
|
|
|
|
(defun reftex-global-search (regexp file-list)
|
|
|
|
;; Start a search for REGEXP in all files of FILE-LIST
|
|
|
|
(put 'reftex-global-search :file-list file-list)
|
|
|
|
(put 'reftex-global-search :regexp regexp)
|
|
|
|
(move-marker reftex-global-search-marker nil)
|
|
|
|
(reftex-global-search-continue))
|
|
|
|
|
|
|
|
(defun reftex-global-search-continue ()
|
|
|
|
;; Continue a global search started with `reftex-global-search'
|
|
|
|
(unless (get 'reftex-global-search :file-list)
|
|
|
|
(error "No global search to continue"))
|
|
|
|
(let* ((file-list (get 'reftex-global-search :file-list))
|
2003-08-11 12:27:02 +00:00
|
|
|
(regexp (get 'reftex-global-search :regexp))
|
|
|
|
(buf (or (marker-buffer reftex-global-search-marker)
|
|
|
|
(reftex-get-file-buffer-force (car file-list))))
|
|
|
|
(pos (or (marker-position reftex-global-search-marker) 1))
|
|
|
|
file)
|
1999-08-16 07:42:41 +00:00
|
|
|
;; Take up starting position
|
|
|
|
(unless buf (error "No such buffer %s" buf))
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
(widen)
|
|
|
|
(goto-char pos)
|
|
|
|
;; Search and switch file if necessary
|
|
|
|
(if (catch 'exit
|
2003-08-11 12:27:02 +00:00
|
|
|
(while t
|
|
|
|
(when (re-search-forward regexp nil t)
|
|
|
|
(move-marker reftex-global-search-marker (point))
|
|
|
|
(throw 'exit t))
|
|
|
|
;; No match - goto next file
|
|
|
|
(pop file-list)
|
|
|
|
(or file-list (throw 'exit nil))
|
|
|
|
(setq file (car file-list)
|
|
|
|
buf (reftex-get-file-buffer-force file))
|
|
|
|
(unless buf (error "Cannot access file %s" file))
|
|
|
|
(put 'reftex-global-search :file-list file-list)
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
(widen)
|
|
|
|
(goto-char 1)))
|
|
|
|
t
|
1999-08-16 07:42:41 +00:00
|
|
|
(move-marker reftex-global-search-marker nil)
|
|
|
|
(error "All files processed"))))
|
|
|
|
|
2008-04-10 14:10:46 +00:00
|
|
|
;; arch-tag: d2f52b56-744e-44ad-830d-1fc193b90eda
|
2000-01-05 09:15:48 +00:00
|
|
|
;;; reftex-dcr.el ends here
|