bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-AUCTeX] Cite lookup failure in presence of escaped %


From: Ralf Angeli
Subject: Re: [Bug-AUCTeX] Cite lookup failure in presence of escaped %
Date: Thu, 18 Dec 2008 22:07:23 +0100

* address@hidden (2008-12-17) writes:

> To reproduce, in emacs-snapshot of October, reftex 4.31, with -Q, with
> my long LaTeX document which works otherwise, after turning on reftex,
> etc:
>
> Blah \% in mumble.\cite{abcd:efg}
>
> When point is placed in the cite and C-c & (reftex-view-crossref) I
> get "Not on a crossref macro argument". I can make it look it up by
> deleting the \% however, so it's not a problem with the biblio, etc.
>
> I believe this is related to a simplistic lookup in reftex-in-comment
> (reftex.el) where it only scans backwards for a % and ignores
> that it can be escaped.

Thanks for the report.  This is fixed in the CVS repository of RefTeX.

> It would be best to start at the beginning of the current line and
> look forwards for a % not preceeded by a \:
>
> (defun reftex-in-comment ()
>   (save-excursion
>     (beginning-of-line)
>     (re-search-forward 
>      (rx (not (any "\\")) "%")
>      ; If you prefer, "\\(?:[^\\]%\\)" is what the rx evals to
>      (line-end-position)
>      t)))
>
> and this appears to work in the above mixed case.

AFAICS `rx' is not available in XEmacs.  And the regular expression you
propose leads to a false negative in case of something like "foo\\%".
In addition the search has to be limited to the current point because
point may be located before the comment start.  Also, you have to make
sure that the match data is not changed outside of the function.

So, what I've commited now is the following:

(defun reftex-in-comment ()
  "Return non-nil if point is in a comment."
  (save-excursion
    (save-match-data
      (let ((pos (point)))
        (beginning-of-line)
        (re-search-forward comment-start-skip pos t)))))

-- 
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]