GNU bug report logs - #38258
12.2.0; reftex-view-crossref on citation pre- and postnotes

Previous Next

Package: auctex;

Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>

Date: Mon, 18 Nov 2019 17:17:02 UTC

Severity: normal

Found in version 12.2.0

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 38258 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Gustavo Barros <gusbrs.2016 <at> gmail.com>
Cc: 38258 <at> debbugs.gnu.org
Subject: Re: bug#38258: 12.2.0; reftex-view-crossref on citation pre- and
 postnotes
Date: Wed, 10 Apr 2024 11:21:02 +0200
Hi Gustavo,

Gustavo Barros <gusbrs.2016 <at> gmail.com> writes:

> To be very explicit, the command in question is
> `reftex-view-crossref`, and it is also called by
> `reftex-view-crossref-when-idle' which is responsible for the echo
> message.  `reftex-view-crossref` checks if point is within a macro
> with `(car (reftex-what-macro-safe 1))', and later checks if it is a
> citation macro with `(string-match
> "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro)'. My
> suggestion is just to add a further check to see if we are indeed in a
> mandatory argument (a citation key).

Thanks for the explicit pointer.  I can think of something like this:

--8<---------------cut here---------------start------------->8---
(defun reftex-view-crossref-when-idle ()
  ;; Display info about crossref at point in echo area or a window.
  ;; This function was designed 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
                                 reftex-mouse-view-crossref)))
       ;; Quick precheck if this might be a relevant spot
       ;; `reftex-view-crossref' will do a more thorough check.
       (save-excursion
         (search-backward "\\" nil t)
         (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)"))

       ;; Also check if point is inside a mandatory argument where the
       ;; cite/ref key usually resides: (bug#38258)
       (save-excursion
         (condition-case nil
             (let ((forward-sexp-function nil))
               (up-list -1)
               (= (following-char) ?\{))
           (error nil)))

       (condition-case nil
           (let ((current-prefix-arg nil))
             (cond
              ((eq reftex-auto-view-crossref t)
               (reftex-view-crossref -1 'echo 'quiet))
              ((eq reftex-auto-view-crossref 'window)
               (reftex-view-crossref -1 'tmp-window 'quiet))
              (t nil)))
         (error nil))))
--8<---------------cut here---------------end--------------->8---

Do you want to give it a try and see if it works as expected?  I think
you see the addition.

Best, Arash




This bug report was last modified 1 year and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.