[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RefTeX - signals not-on-macro error when idle
From: |
David Reitter |
Subject: |
RefTeX - signals not-on-macro error when idle |
Date: |
Fri, 18 Nov 2005 11:57:17 +0000 |
Reftex signaled an error whenever idle when the point was in a
position shortly after a commented out citation, for instance in
positions 0 and 1, but not in 2 in the following example:
% those of \cite{gries2005corpusbased} and
% \cite{dubey2005parallelism}). Quantitatively, (0) they do not: priming
(1)
\subsection{Black box experiments}
(2)
The error signals caused annoying `ding's.
The reason was that reftex-view-crossref-when-idle just did a quick
cursory check of the argument. Calling (reftex-in-comment) would have
been redundant and still wouldn't catch potential other cases.
The simple fix below still lets reftex-view-crossref do the real
check, but won't signal an error if an optional argument FAIL-
SILENTLY is given.
Would that be a good solution?
*** lisp/textmodes/reftex-dcr.el 21 Sep 2005 12:40:14 +0100 1.22
--- lisp/textmodes/reftex-dcr.el 18 Nov 2005 11:48:51 +0000
***************
*** 33,39 ****
(require 'reftex)
;;;
! (defun reftex-view-crossref (&optional arg auto-how)
"View cross reference of macro at point. Point must be on the KEY
argument. When at at `\\ref' macro, show corresponding `\\label'
definition, also in external documents (`xr'). When on a label, show
--- 33,39 ----
(require 'reftex)
;;;
! (defun reftex-view-crossref (&optional arg auto-how fail-silently)
"View cross reference of macro at point. Point must be on the KEY
argument. When at at `\\ref' macro, show corresponding `\\label'
definition, also in external documents (`xr'). When on a label, show
***************
*** 47,53 ****
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.
--- 47,55 ----
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'.
! If FAIL-SILENTLY is non-nil, do not signal an error in case there
is no
! valid argument at point."
(interactive "P")
;; See where we are.
***************
*** 56,107 ****
dw)
(if (or (null macro) (reftex-in-comment))
! (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))))
(defun reftex-view-cr-cite (arg key how)
;; View crossreference of a ref cite. HOW can have the values
--- 58,112 ----
dw)
(if (or (null macro) (reftex-in-comment))
! (if fail-silently
! nil
! (error "Not on a crossref macro argument")
! )
! ;; valid 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)))))
(defun reftex-view-cr-cite (arg key how)
;; View crossreference of a ref cite. HOW can have the values
***************
*** 243,249 ****
(not (memq last-command '(reftex-view-crossref
reftex-mouse-view-crossref)))
;; Quick precheck if this might be a relevant spot
! ;; FIXME: Can fail with backslash in comment
(save-excursion
(search-backward "\\" nil t)
(looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))
--- 248,255 ----
(not (memq last-command '(reftex-view-crossref
reftex-mouse-view-crossref)))
;; Quick precheck if this might be a relevant spot
! ;; this will at times, e.g. backslash in argument
! ;; reftex-view-crossref will do the more thorough check.
(save-excursion
(search-backward "\\" nil t)
(looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))
***************
*** 252,260 ****
(let ((current-prefix-arg nil))
(cond
((eq reftex-auto-view-crossref t)
! (reftex-view-crossref -1 'echo))
((eq reftex-auto-view-crossref 'window)
! (reftex-view-crossref -1 'tmp-window))
(t nil)))
(error nil))))
--- 258,266 ----
(let ((current-prefix-arg nil))
(cond
((eq reftex-auto-view-crossref t)
! (reftex-view-crossref -1 'echo 'fail-silently))
((eq reftex-auto-view-crossref 'window)
! (reftex-view-crossref -1 'tmp-window 'fail-silently))
(t nil)))
(error nil))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RefTeX - signals not-on-macro error when idle,
David Reitter <=