From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: RefTeX - signals not-on-macro error when idle Date: Fri, 18 Nov 2005 11:57:17 +0000 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1132317300 15057 80.91.229.2 (18 Nov 2005 12:35:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Nov 2005 12:35:00 +0000 (UTC) Cc: dominik@science.uva.nl Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 18 13:34:54 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ed5Qn-0002V3-HZ for ged-emacs-devel@m.gmane.org; Fri, 18 Nov 2005 13:33:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ed5Qm-0007vO-Qo for ged-emacs-devel@m.gmane.org; Fri, 18 Nov 2005 07:33:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ed4rt-00043N-Md for emacs-devel@gnu.org; Fri, 18 Nov 2005 06:57:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ed4rr-00042P-IK for emacs-devel@gnu.org; Fri, 18 Nov 2005 06:57:24 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ed4rq-000429-TN for emacs-devel@gnu.org; Fri, 18 Nov 2005 06:57:22 -0500 Original-Received: from [64.233.162.205] (helo=zproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ed4rr-00013w-2a for emacs-devel@gnu.org; Fri, 18 Nov 2005 06:57:23 -0500 Original-Received: by zproxy.gmail.com with SMTP id 40so165574nzk for ; Fri, 18 Nov 2005 03:57:21 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=gra9n59TebHDlpQ9a0LHF7GbzcBUi6Sc9vy/7K3lfgpZVFMmjh6JOrB5WtlyZGrj/QjDBF+07j2fcFvhd3IxnQhN9h/c8l0F/MBLAJZIOcGw3wozHtV/5QnLeUs67iJSIwdnCUlLjabrgxqAGxZbZ61kAYjW+bLy5ryz4oHCT64= Original-Received: by 10.65.239.12 with SMTP id q12mr1156935qbr; Fri, 18 Nov 2005 03:57:21 -0800 (PST) Original-Received: from ?129.215.174.81? ( [129.215.174.81]) by mx.gmail.com with ESMTP id q19sm599241qbq.2005.11.18.03.57.20; Fri, 18 Nov 2005 03:57:21 -0800 (PST) Original-To: Emacs-Devel ' X-Mailer: Apple Mail (2.746.2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:46217 Archived-At: 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))))