[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-AUCTeX] Cite lookup failure in presence of escaped %
From: |
sword |
Subject: |
[Bug-AUCTeX] Cite lookup failure in presence of escaped % |
Date: |
Wed, 17 Dec 2008 15:36:41 -0600 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Hi Auctex maints and devs,
Great package, thanks for making life with LaTeX easy.
I've encountered a problem with RefTeX's cite lookup. I've got a
document where I use a lot of percents (escaped) and that happens to
be causing cite lookup to fail.
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. AIUI, \% is a legal escape - LaTeX is
accepting it, so I think it's okay to have it in my document. I
can make it kinda work by redefining in my .emacs with the
following code based on the current defun:
; Ensure that the comment char isn't escaped.
; We are in a comment if % is there and the character before it is not \
(defun reftex-in-comment ()
(save-excursion
(skip-chars-backward "^%\n\r")
(and (eq (char-before) ?%)
(not (eq ?\ (char-before (- (point) 2)))))))
However, this simple version should fail in the presence of mixed \%
and %, like this:
Blah \% foo % in mumble \%.\cite{abcd:efg}
since it will only go back to the last \% and thinks it's still a live
cite but the cite is still commented overall.
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.
- [Bug-AUCTeX] Cite lookup failure in presence of escaped %,
sword <=