Subject: bug#38258: 12.2.0; reftex-view-crossref on citation pre- and postnotes

From: Gustavo Barros <[email-masked]>
Date: Tue, 25 Aug 2020 17:42:46 -0300

Hi Arash,

On Tue, 25 Aug 2020 at 17:11, Arash Esbati <[email-masked]> wrote:

>> The point is that the command will do a bibfile search when it is not
>> on the key argument, and on top of that, gives the user the wrong
>> error message of "no such database argument", when it should be 
>> giving
>> "Not on a crossref macro argument".
>
> If I take your example and put point on the optional argument [45] and
> hit `C-c &', RefTeX says:
>
>     No BibTeX entry with citation key \cite[45]
>
> which makes sense.
>
>> Besides, one does not even need to call it to get the spurious echo 
>> of
>> "no such database entry", by just leaving point on a 
>> prenote/postnote.
>
> True.  You can disable this by setting the variable
> `reftex-auto-view-crossref':
>

I know, Arash... I like `reftex-auto-view-crossref' and enable it, but 
the problem is not with the intended behavior, but with the not useful 
and annoying echo which comes when point is idle *outside* a key 
argument, if it happens to be in a pre/postnote.  And why should 
`reftex-view-crossref' behave differently when point is between "4" and 
"5", in the MWE, and when it is in the following line, outside the 
citation macro altogether?  Why run `reftex-view-cr-cite' when we 
already know we are not in a citation key, but in a postnote?

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).

Best,
Gustavo.