Received: (at 31132) by debbugs.gnu.org; 22 Apr 2018 00:54:37 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 21 20:54:37 2018 Received: from localhost ([127.0.0.1]:35261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1fA3H2-0000p7-8M for submit <at> debbugs.gnu.org; Sat, 21 Apr 2018 20:54:37 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:46229) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <gusbrs.2016@HIDDEN>) id 1fA3Gz-0000oq-5u for 31132 <at> debbugs.gnu.org; Sat, 21 Apr 2018 20:54:34 -0400 Received: by mail-pf0-f196.google.com with SMTP id h69so6323805pfe.13 for <31132 <at> debbugs.gnu.org>; Sat, 21 Apr 2018 17:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=iRumVHKeCIz2LK9GJhrrjwzFW5UzqPFppnfQY5Az+F0=; b=f+iN/WU7SwzBDb6LK9aza6GvO3rJMb7cdn3c60QhF5hDq5kM3ZUl6JmdJ9GbKh4g7Z IcHemZJk+5S3ODtluT1SLfofSICR/RrWc7GFFSIrPpF47EJO7O3j35LSShv/cWrEqMQO JhhYHcPX/2PwFxYX25naYddXftS7s/f01UVJYV/rWObhq39bba7gcacBTS1uwGsNB0+l ahF8yvbhA0ThYDQubY3cPQx2QoCvPTSGKbMD6ZQyRI1Rs0TIMjSsfXO+I1Ynb7NKziS0 6ZaRChkzqPR6xqsTvurvkbIb3Td9HjlxNWyxUQiAU2pA9fj/d8HibRqkOllTN7SdKgXb XUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:references:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=iRumVHKeCIz2LK9GJhrrjwzFW5UzqPFppnfQY5Az+F0=; b=Q9GP5iurmNxMQMmQQqaKg01JRNTHHM34AE7YguS+uR+UmNzkkT6IywxYKiBkVU4ReQ FMcBQZshsF0qLfdS48ygovFRKX70Vx/ZRxelv83SEtL6yUOPH0kT0Piy95FKGfISuL/l nTUpqOKcBxmXJZOZPLMx7hnKgmCSryj6BUgKk+QQaMLMlmm3+73wBwJrZwyForRJSC3T e3cOPteVtNAnm0wOsl+sTW87jXYbelhR4BpFWRLN5yjcT3yKfzgCtLKBQeRtY84NLHcj e8Dc0HAuRa13Dp4AapgLQ5iHcnGKOg2lksi866kURPubFErlt/ccLuIezXbGyNpP9fLZ mYDw== X-Gm-Message-State: ALQs6tBwtVpknpB/p8zAjr06fBsoXEkPLtkWt4TO587HWbkGZn+FoG/q yWL9ue1fgb/AHkTHr2aZoxlp1Tej X-Google-Smtp-Source: AIpwx4+VRQ6NnY3gmTYm5MJuU4j6n4UoO6ctCgpdHF7cxJSS6b6IWVXwDucXzGffM5zRnvRx8wqIpQ== X-Received: by 10.99.98.69 with SMTP id w66mr12620129pgb.55.1524358466211; Sat, 21 Apr 2018 17:54:26 -0700 (PDT) Received: from [10.13.10.6] (ip-97-228-239-173.router.siliconvalleywifi.com. [173.239.228.97]) by smtp.gmail.com with ESMTPSA id e83sm22944123pfd.175.2018.04.21.17.54.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Apr 2018 17:54:25 -0700 (PDT) Subject: Re: bug#31132: AUCTeX, RefTeX and biblatex's multicite commands From: Gustavo Barros <gusbrs.2016@HIDDEN> To: Arash Esbati <arash@HIDDEN> References: <2040bd1a-7ee5-d7eb-a546-f35b66697686@HIDDEN> <867ep3q8sw.fsf@HIDDEN> <280a40e2-24ee-e2f7-12ef-e46fc779d133@HIDDEN> Message-ID: <e71e3851-8189-d337-b431-2f4ca0e42235@HIDDEN> Date: Sat, 21 Apr 2018 21:54:21 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <280a40e2-24ee-e2f7-12ef-e46fc779d133@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 31132 Cc: 31132 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.7 (/) Hi Arash, I did observe something else, as I closed my file after testing, and was cleaning up things. I had observed the behavior before, but was unsure if my "noobiness" was to blame. (So please be understanding). The behavior is the following. When I first open the file, if I try to issue 'C-c &' on a multicite command key, it returns "Not on a crossref macro argument". 'C-c [' works though. And *after* I have either issued 'C-c [' on a key or issued successfully 'C-c &' on a regular citation command, then 'C-c &' will work also on multicite commands. It's a small glitch in my view, and was somehow hard to spot. But I can reproduce this behavior with the test file I sent previously. Sorry for the previous incomplete report. But I only could figure the logic of what was going on, after I closed and reopened things. Thank you once again. Best, gusbrs On 21/04/18 21:29, Gustavo Barros wrote: > Hi Arash, > > thank you very much for the patches. They are really appreciated. > And sorry for the delay in reporting back. I didn't have the time > these last couple of days to look at this with due care. > > I've performed some tests with the patches you sent on the full set of > biblatex's citation commands, and can gladly report that both "C-c &" > (reftex-view-crossref) and "C-c [" (reftex-citation) (when issued on > the key of an existing citation command) work flawlessly on all of them. > > But, in performing the tests, I observed some other things associated > with biblatex's citation commands (some related to this issue, some > not) that I might as well report too, in the hope they will be useful. > As a regular biblatex user, I consider them minor. > > 1 - The multicite variants of 'volcite' are neither fontified nor call > RefTeX when inserted (with "C-c RET"). They are inserted "plain" but, > once inserted, "C-c [" will work on them. They are the following: > -volcites > -Volcites > -pvolcites > -Pvolcites > -fvolcites > -Fvolcites > -svolcites > -Svolcites > -tvolcites > -Tvolcites > -avolcites > -Avolcites > > 2 - A couple of 'volcite' variants are fontified, but don't call > RefTeX when inserted: > -pvolcite > -ftvolcite > > 3 - One command is not fontified: > -footfullcite > > 4 - 'mcite'-like citation commands are neither fontified, nor call > RefTeX when inserted: > -mcite > -Mcite > -mparencite > -Mparencite > -mfootcite > -mfootcitetext > -mtextcite > -Mtextcite > > > I can report something else too. In the last couple of weeks, for all > the critical issues for my regular workflow with LaTeX I found my way > around with Emacs, so I think the "potential deal breakers" are > overcome. Even though I'm clearly still in the steep part of the > learning curve with Emacs, I do believe I've been hooked. Still > struggling, but already bewitched. :) > So I'm looking forward to sticking around. > > Thank you very much once again. > > Best, > gusbrs > > > PS: The test file used was the following: > > \documentclass{article} > > \begin{filecontents}{biblatex-bib.bib} > @book{lamp:94, > author = {Leslie Lamport}, > title = {LaTeX - {A} Document Preparation System: User's Guide > and Reference Manual, Second Edition}, > publisher = {Pearson / Prentice Hall}, > year = {1994}, > isbn = {978-0-201-52983-8}, > timestamp = {Fri, 08 Apr 2011 18:21:00 +0200}, > } > > @book{mitt:97, > author = {Michel Goossens and > Sebastian Rahtz and > Frank Mittelbach}, > title = {The LaTeX Graphics Companion - Illustrating documents > with TeX and PostScript}, > series = {Addison-Wesley series on tools and techniques > for computer typesetting}, > publisher = {Addison-Wesley}, > year = {1997}, > isbn = {978-0-201-85469-5}, > } > \end{filecontents} > > \usepackage[style=authoryear, natbib=true, mcite=true]{biblatex} > > \addbibresource{biblatex-bib.bib} > > \begin{document} > > % Standard commands > \cite[pre][pos]{mitt:97} > \Cite[pre][pos]{lamp:94} > \parencite[pre][pos]{mitt:97} > \Parencite[pre][pos]{lamp:94} > \footcite[pre][pos]{mitt:97} > \footcitetext[pre][pos]{lamp:94} > % Style specific commands > \textcite[pre][pos]{mitt:97} > \Textcite[pre][pos]{lamp:94,} > \smartcite[pre][pos]{mitt:97} > \Smartcite[pre][pos]{lamp:94} > \cite*[pre][pos]{mitt:97} > \parencite*[pre][pos]{lamp:94} > % \supercite{mitt:97} > % Qualified citation lists > \cites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94}[pre][pos]{lamp:94} > > \Cites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \parencites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \Parencites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \footcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \footcitetexts(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \smartcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \Smartcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \textcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \Textcites(gpre)(gpos)[pre][pos]{lamp:94}[pre][pos]{mitt:97} > % \supercites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > % Style independent commands > \autocite[pre][pos]{mitt:97} > \Autocite[pre][pos]{lamp:94} > \autocite*[pre][pos]{mitt:97} > \Autocite*[pre][pos]{lamp:94} > \autocites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > \Autocites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} > % Text commands > \citeauthor[pre][pos]{mitt:97} > \citeauthor*[pre][pos]{mitt:97} > \Citeauthor[pre][pos]{lamp:94} > \Citeauthor*[pre][pos]{lamp:94} > \citetitle[pre][pos]{mitt:97,lamp:94} > \citetitle*[pre][pos]{lamp:94} > \citeyear[pre][pos]{mitt:97} > \citeyear*[pre][pos]{lamp:94} > \citedate[pre][pos]{mitt:97} > \citedate*[pre][pos]{lamp:94} > \citeurl[pre][pos]{mitt:97} > % Special commands > \nocite{mitt:97} > \fullcite[pre][pos]{lamp:94} > \footfullcite[pre][pos]{mitt:97} > \volcite[pre]{2}[pg]{mitt:97} > \Volcite[pre]{1}[pg]{lamp:94} > \volcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} > \Volcites(gpre)(gpos)[pre]{2}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} > \pvolcite[pre]{1}[pg]{lamp:94} > \Pvolcite[pre]{2}[pg]{mitt:97} > \pvolcites(gpre)(gpos)[pre]{1}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} > \Pvolcites(gpre)(gpos)[pre]{3}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} > \fvolcite[pre]{3}[pg]{lamp:94} > \ftvolcite[pre]{3}[pg]{lamp:94} > \fvolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} > \Fvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} > \svolcite[pre]{2}[pg]{lamp:94} > \Svolcite[pre]{4}[pg]{mitt:97} > \svolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} > \Svolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} > \tvolcite[pre]{5}[pg]{mitt:97} > \Tvolcite[pre]{2}[pg]{lamp:94} > \tvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} > \Tvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} > \avolcite[pre]{3}[pg]{lamp:94} > \Avolcite[pre]{1}[pg]{mitt:97} > \avolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} > \Avolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} > \notecite[pre][pos]{lamp:94} > \Notecite[pre][pos]{mitt:97} > \pnotecite[pre][pos]{mitt:97} > \Pnotecite[pre][pos]{lamp:94} > \fnotecite[pre][pos]{lamp:94} > % Low-level commands > \citename[pre][pos]{lamp:94}{author} > \citelist[pre][pos]{lamp:94}{publisher} > \citefield[pre][pos]{lamp:94}{isbn} > % natbib compatibility commands > \citet[pre][pos]{mitt:97} > \citet*[pre][pos]{lamp:94} > \citep[pre][pos]{lamp:94} > \citep*[pre][pos]{mitt:97} > \citealt[pre][pos]{lamp:94} > \citealt*[pre][pos]{mitt:97} > \citealp[pre][pos]{mitt:97} > \citealp*[pre][pos]{lamp:94} > \Citet[pre][pos]{lamp:94} > \Citet*[pre][pos]{mitt:97} > \Citep[pre][pos]{lamp:94} > \Citep*[pre][pos]{mitt:97} > % mcite-like citation commands > \mcite[pre][pos]{lamp:94,mitt:97} > \Mcite[pre][pos]{mitt:97,lamp:94} > \mparencite[pre][pos]{lamp:94,mitt:97} > \Mparencite[pre][pos]{lamp:94,mitt:97} > \mfootcite[pre][pos]{lamp:94,mitt:97} > \mfootcitetext[pre][pos]{lamp:94,mitt:97} > \mtextcite[pre][pos]{lamp:94,mitt:97} > \Mtextcite[pre][pos]{lamp:94,mitt:97} > % \msupercite[pre][pos]{lamp:94,mitt:97} > > \end{document} > %%% Local Variables: > %%% mode: latex > %%% TeX-master: t > %%% End: > > > > > On 19/04/18 16:45, Arash Esbati wrote: >> gusbrs.2016@HIDDEN writes: >> >>> From TeX.SX: https://tex.stackexchange.com/q/425883/105447 >>> >>> >>> RefTeX's relations biblatex's multicite commands (such as \parencites, >>> \footcites, \textcites and so on) leave some things to be desired >>> for. Namely, they do not seem to be recognized as citation >>> commands. This results in RefTeX's `reftex-view-crossref` (C-c &) >>> returning "Not on a crossref macro argument". Also, in adding an extra >>> bibkey to an already existing multicite command, it is not possible to >>> access RefTeX's facilities. >>> >>> Arash Esbati generously provided patches at TeX.SX that go a long way >>> in dealing with these problems. However, support for the presence of >>> global optional arguments (between parentheses) is still missing. At >>> their request, I write to report this issue. >> Hi Gusbrs, >> >> thanks for the report. I fiddled a little around and I think I have a >> working setup for this issue. I think with this patch, RefTeX will also >> recognize referencing commands provided by cleveref.sty. >> >> --8<---------------cut here---------------start------------->8--- >> diff --git a/lisp/textmodes/reftex-cite.el >> b/lisp/textmodes/reftex-cite.el >> index fd229a6..3f4965a 100644 >> --- a/lisp/textmodes/reftex-cite.el >> +++ b/lisp/textmodes/reftex-cite.el >> @@ -763,7 +763,9 @@ in order to only add another reference in the >> same cite command." >> (setq format "%l")) >> >> ((and (stringp macro) >> - (string-match "\\`\\\\cite\\|cite\\'" macro)) >> + (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" >> macro)) >> + ;; Match also commands from biblatex ending with `s' (\cites) or >> + ;; `*' (\parencite*) and `texts?' (\footcitetext and >> \footcitetexts). >> ;; We are already inside a cite macro >> (if (or (not arg) (not (listp arg))) >> (setq format >> diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el >> index 74a5e63..b93d05d 100644 >> --- a/lisp/textmodes/reftex-dcr.el >> +++ b/lisp/textmodes/reftex-dcr.el >> @@ -60,10 +60,13 @@ to the functions `reftex-view-cr-cite' and >> `reftex-view-cr-ref'." >> (setq reftex-call-back-to-this-buffer (current-buffer)) >> >> (cond >> - ((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro) >> + ((string-match >> "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) >> + ;; Match also commands from biblatex ending with `s' >> (\cites) or >> + ;; `*' (\parencite*) and `texts?' (\footcitetext and >> \footcitetexts). >> ;; 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) >> + ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) >> + ;; Match also commands from cleveref ending with `s' >> (\namecrefs). >> ;; 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) >> diff --git a/lisp/textmodes/reftex-parse.el >> b/lisp/textmodes/reftex-parse.el >> index 492f546..31e108c 100644 >> --- a/lisp/textmodes/reftex-parse.el >> +++ b/lisp/textmodes/reftex-parse.el >> @@ -788,12 +788,13 @@ move backward to the closing parenthesis of the >> previous argument. >> This function understands the splitting of macros over several lines >> in TeX." >> (cond >> - ;; Just to be quick: >> - ((memq (preceding-char) '(?\] ?\}))) >> + ;; Just to be quick: biblatex uses () as delimiters for optional >> + ;; arguments in qualified citation lists. >> + ((memq (preceding-char) '(?\] ?\) ?\}))) >> ;; Do a search >> ((and reftex-allow-detached-macro-args >> (re-search-backward >> - "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" >> bound t)) >> + "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" >> bound t)) >> (goto-char (1+ (match-beginning 0))) >> t) >> (t nil))) >> @@ -842,12 +843,22 @@ considered an argument of macro \\macro." >> (while (and (reftex-move-to-previous-arg bound) >> (condition-case nil >> (let ((forward-sexp-function nil)) >> - (backward-sexp) t) >> + (if (= (preceding-char) ?\)) >> + (let ((temp-table >> (make-syntax-table))) >> + (modify-syntax-entry ?\( "()" >> temp-table) >> + (modify-syntax-entry ?\) ")(" >> temp-table) >> + (with-syntax-table temp-table >> + (backward-sexp))) >> + (backward-sexp)) >> + t) >> (error nil))) >> - (if (eq (following-char) ?\[) (cl-incf cnt-opt)) >> + (if (or (eq (following-char) ?\[) >> + (eq (following-char) ?\()) >> + (cl-incf cnt-opt)) >> (cl-incf cnt)) >> (setq pos (point)) >> (when (and (or (= (following-char) ?\[) >> + (= (following-char) ?\() >> (= (following-char) ?\{)) >> (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) >> (setq cmd (reftex-match-string 0)) >> --8<---------------cut here---------------end--------------->8--- >> >> One thing I don't understand is why (backward-sexp) doesn't work on >> (Global Pre) arguments. Maybe somebody can enlighten me. For now, I >> added a trickery with `with-syntax-table'. >> >> Further, I think the functions `reftex-move-over-touching-args' and >> `reftex-move-to-next-arg' must also be patched in order to support >> optional arguments in parentheses. >> >> My test file for this looks like this. In case somebody wants to try >> this out, the complete functions are inserted below. Any comments >> welcome. >> >> >> --8<---------------cut here---------------start------------->8--- >> \documentclass{article} >> >> \begin{filecontents}{biblatex-bib.bib} >> @book{lamp:94, >> author = {Leslie Lamport}, >> title = {LaTeX - {A} Document Preparation System: User's Guide >> and Reference Manual, Second Edition}, >> publisher = {Pearson / Prentice Hall}, >> year = {1994}, >> isbn = {978-0-201-52983-8}, >> timestamp = {Fri, 08 Apr 2011 18:21:00 +0200}, >> } >> >> @book{mitt:97, >> author = {Michel Goossens and >> Sebastian Rahtz and >> Frank Mittelbach}, >> title = {The LaTeX Graphics Companion - Illustrating documents >> with TeX and PostScript}, >> series = {Addison-Wesley series on tools and techniques >> for computer typesetting}, >> publisher = {Addison-Wesley}, >> year = {1997}, >> isbn = {978-0-201-85469-5}, >> } >> \end{filecontents} >> >> \usepackage[style=authoryear]{biblatex} >> >> \addbibresource{biblatex-bib.bib} >> >> \begin{document} >> >> %% =============== RefTeX standard >> >> \cite{mitt:97} >> ==> \verb|C-c &| Ok, \verb|C-c [| Ok >> >> \cites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} >> ==> \verb|C-c &| Ok, \verb|C-c [| Ok >> >> \footcitetext[Pre][Post]{mitt:97} >> ==> \verb|C-c &| NOk, \verb|C-c [| NOk >> >> \parencite*[Pre][Post]{mitt:97} >> ==> \verb|C-c &| Ok, \verb|C-c [| NOk >> >> \parencites{mitt:97} >> \parencites(GPre)()[Pre][]{mitt:97}[Pre][]{lamp:94} >> \parencites(pre)()[pre][]{mitt:97} >> \parencites(post)[post]{mitt:97} >> ==> \verb|C-c &| NOk, \verb|C-c [| NOk >> >> %% ============== RefTeX patched >> >> \parencites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} >> ==> \verb|C-c &| Ok, \verb|C-c [| Ok >> >> \parencites(Global Pre)(Global >> Post)[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} >> ==> \verb|C-c &| Ok, \verb|C-c [| Ok >> >> >> \begin{verbatim} >> (defun reftex-view-crossref (&optional arg auto-how fail-quietly) >> "View cross reference of macro at point. Point must be on the KEY >> argument. When at a `\\ref' macro, show corresponding `\\label' >> definition, also in external documents (`xr'). When on a label, show >> a locations where KEY is referenced. Subsequent calls find additional >> locations. When on a `\\cite', show the associated `\\bibitem' macro or >> the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro >> which uses this KEY. When on an `\\index', show other locations marked >> by the same index entry. >> To define additional cross referencing items, use the option >> `reftex-view-crossref-extra'. See also >> `reftex-view-crossref-from-bibtex'. >> 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. >> (let* ((macro (car (reftex-what-macro-safe 1))) >> (key (reftex-this-word "^{}%\n\r, \t")) >> dw) >> >> (if (or (null macro) (reftex-in-comment)) >> (or fail-quietly >> (error "Not on a crossref macro argument")) >> >> (setq reftex-call-back-to-this-buffer (current-buffer)) >> >> (cond >> ((string-match >> "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) >> ;; Match also commands from biblatex ending with `s' >> (\cites) or >> ;; `*' (\parencite*) and `texts?' (\footcitetext and >> \footcitetexts). >> ;; A citation macro: search for bibitems or BibTeX entries >> (setq dw (reftex-view-cr-cite arg key auto-how))) >> ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) >> ;; Match also commands from cleveref ending with `s' >> (\namecrefs). >> ;; 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-figure-out-cite-format (arg &optional no-insert >> format-key) >> "Check if there is already a cite command at point and change cite >> format >> in order to only add another reference in the same cite command." >> (let ((macro (car (reftex-what-macro 1))) >> (cite-format-value (reftex-get-cite-format)) >> key format) >> (cond >> (no-insert >> ;; Format does not really matter because nothing will be >> inserted. >> (setq format "%l")) >> >> ((and (stringp macro) >> (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" >> macro)) >> ;; Match also commands from biblatex ending with `s' (\cites) or >> ;; `*' (\parencite*) and `texts?' (\footcitetext and >> \footcitetexts). >> ;; We are already inside a cite macro >> (if (or (not arg) (not (listp arg))) >> (setq format >> (concat >> (if (member (preceding-char) '(?\{ ?,)) >> "" >> reftex-cite-key-separator) >> "%l" >> (if (member (following-char) '(?\} ?,)) >> "" >> reftex-cite-key-separator))) >> (setq format "%l"))) >> (t >> ;; Figure out the correct format >> (setq format >> (if (and (symbolp cite-format-value) >> (assq cite-format-value >> reftex-cite-format-builtin)) >> (nth 2 (assq cite-format-value >> reftex-cite-format-builtin)) >> cite-format-value)) >> (when (listp format) >> (setq key >> (or format-key >> (reftex-select-with-char >> "" (concat "SELECT A CITATION FORMAT\n\n" >> (mapconcat >> (lambda (x) >> (format "[%c] %s %s" (car x) >> (if (> (car x) 31) " " "") >> (cdr x))) >> format "\n"))))) >> (if (assq key format) >> (setq format (cdr (assq key format))) >> (error "No citation format associated with key `%c'" key))))) >> format)) >> >> (defun reftex-move-to-previous-arg (&optional bound) >> "Assuming that we are in front of a macro argument, >> move backward to the closing parenthesis of the previous argument. >> This function understands the splitting of macros over several lines >> in TeX." >> (cond >> ;; Just to be quick: biblatex uses () as delimiters for optional >> ;; arguments in qualified citation lists. >> ((memq (preceding-char) '(?\] ?\) ?\}))) >> ;; Do a search >> ((and reftex-allow-detached-macro-args >> (re-search-backward >> "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" >> bound t)) >> (goto-char (1+ (match-beginning 0))) >> t) >> (t nil))) >> >> >> (defun reftex-what-macro (which &optional bound) >> "Find out if point is within the arguments of any TeX-macro. >> The return value is either (\"\\macro\" . (point)) or a list of them. >> >> If WHICH is nil, immediately return nil. >> If WHICH is 1, return innermost enclosing macro. >> If WHICH is t, return list of all macros enclosing point. >> If WHICH is a list of macros, look only for those macros and return the >> name of the first macro in this list found to enclose point. >> If the optional BOUND is an integer, bound backwards directed >> searches to this point. If it is nil, limit to nearest \\section - >> like statement. >> >> This function is pretty stable, but can be fooled if the text contains >> things like \\macro{aa}{bb} where \\macro is defined to take only one >> argument. As RefTeX cannot know this, the string \"bb\" would still be >> considered an argument of macro \\macro." >> (unless reftex-section-regexp (reftex-compile-variables)) >> (catch 'exit >> (if (null which) (throw 'exit nil)) >> (let ((bound (or bound (save-excursion (re-search-backward >> reftex-section-regexp nil 1) >> (point)))) >> pos cmd-list cmd cnt cnt-opt entry) >> (save-restriction >> (save-excursion >> (narrow-to-region (max (point-min) bound) (point-max)) >> ;; move back out of the current parenthesis >> (while (condition-case nil >> (let ((forward-sexp-function nil)) >> (up-list -1) t) >> (error nil)) >> (setq cnt 1 cnt-opt 0) >> ;; move back over any touching sexps >> (while (and (reftex-move-to-previous-arg bound) >> (condition-case nil >> (let ((forward-sexp-function nil)) >> (if (= (preceding-char) ?\)) >> (let ((temp-table >> (make-syntax-table))) >> (modify-syntax-entry ?\( "()" >> temp-table) >> (modify-syntax-entry ?\) ")(" >> temp-table) >> (with-syntax-table temp-table >> (backward-sexp))) >> (backward-sexp)) >> t) >> (error nil))) >> (if (or (eq (following-char) ?\[) >> (eq (following-char) ?\()) >> (cl-incf cnt-opt)) >> (cl-incf cnt)) >> (setq pos (point)) >> (when (and (or (= (following-char) ?\[) >> (= (following-char) ?\() >> (= (following-char) ?\{)) >> (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) >> (setq cmd (reftex-match-string 0)) >> (when (looking-at "\\\\begin{[^}]*}") >> (setq cmd (reftex-match-string 0) >> cnt (1- cnt))) >> ;; This does ignore optional arguments. Very hard to >> fix. >> (when (setq entry (assoc cmd reftex-env-or-mac-alist)) >> (if (> cnt (or (nth 4 entry) 100)) >> (setq cmd nil))) >> (cond >> ((null cmd)) >> ((eq t which) >> (push (cons cmd (point)) cmd-list)) >> ((or (eq 1 which) (member cmd which)) >> (throw 'exit (cons cmd (point)))))) >> (goto-char pos))) >> (nreverse cmd-list))))) >> >> \end{verbatim} >> >> \end{document} >> >> --8<---------------cut here---------------end--------------->8--- >> >> Best, Arash >
bug-auctex@HIDDEN
:bug#31132
; Package auctex
.
Full text available.Received: (at 31132) by debbugs.gnu.org; 22 Apr 2018 00:29:29 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 21 20:29:29 2018 Received: from localhost ([127.0.0.1]:35252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1fA2si-0000Es-7R for submit <at> debbugs.gnu.org; Sat, 21 Apr 2018 20:29:29 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:46212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <gusbrs.2016@HIDDEN>) id 1fA2sf-0000Ef-3q for 31132 <at> debbugs.gnu.org; Sat, 21 Apr 2018 20:29:26 -0400 Received: by mail-pg0-f51.google.com with SMTP id t12so5848211pgp.13 for <31132 <at> debbugs.gnu.org>; Sat, 21 Apr 2018 17:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=NrB8gHEd/DvexQOnGbUMar7WL/I9KWhdGwk61vKBzdA=; b=GEvMbUSi+Cxb5m2aXdGvjFlkwcZ7BodVbA/3mBSlNb8+6xUy0qXBcQUXYZJWexPi/i Hxjl8ovm2uPBrpUjZA/7D+xNE5IM6VB4cRn1XEv9W+L2J+QSx7s/a4sHb5pEp97oKD5T GHXLu5w/se4RmEhQhOgs2ccK8BaY59FVSDSgOfBUQmlS8HY4E32kwYQ9L3U04DiXurtI CgMVjKQ7vlKGtkO0GrqImISXsMhBxJvq9QZkbF4QwlKvM1tnHONvaGJeTn79wpyUjAl4 g3B16HJEioQFK5v61OGLzp43ggOwJ9GzVLHDmzL1z1b3oGcsZP7ZRlVnIDvQlb2F1QaJ hXCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=NrB8gHEd/DvexQOnGbUMar7WL/I9KWhdGwk61vKBzdA=; b=AYupmyxFOzld17lru8Ngvx2i3b0a5GLgtLPaGx2z9/KRSkUEtz5RL5uvrwEH1sFjLZ VR3SAvsAzyEMKokjhzyr9OwlxItZVufZfP7CUDMOwJvIt95D4Clbf/Sy/6mBRETiNrZe CJokOYFrDgcn+2QggkIvyHkI1q9LGcoim08YG7c5Pu46A1uyWEmlm7nCWioRfcggaah7 uRIvYWfs3tXe4OrdwdyXTPD01WeWykzAaYXWQiy0WiHyXskBaVFxKAvoGvWlyRwIbGy2 uNh5I2XyEFGjbs5rPhEvWFSGl4fNM1J92O3/8SNIfC9xRKPsRmOZQVXHB2GVuySM6ONq eicQ== X-Gm-Message-State: ALQs6tDJq06N6C/m8Huw9gTsq1hLtyG55ZsIdIZJlMevvqyLxSsIC39t SEGfgk6p5id0V2RC4siFJJ+dSfOr X-Google-Smtp-Source: AIpwx48GG7LiS5JOMeu1o5MYRacdmRSdV/Erk1EXp5fHHD+dhpYi3TEjF9Tq2vuuVTEr9Gy8dasTwQ== X-Received: by 10.98.165.8 with SMTP id v8mr14542530pfm.225.1524356958683; Sat, 21 Apr 2018 17:29:18 -0700 (PDT) Received: from [10.13.10.6] (ip-97-228-239-173.router.siliconvalleywifi.com. [173.239.228.97]) by smtp.gmail.com with ESMTPSA id 27sm18734870pfo.137.2018.04.21.17.29.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Apr 2018 17:29:17 -0700 (PDT) Subject: Re: bug#31132: AUCTeX, RefTeX and biblatex's multicite commands To: Arash Esbati <arash@HIDDEN> References: <2040bd1a-7ee5-d7eb-a546-f35b66697686@HIDDEN> <867ep3q8sw.fsf@HIDDEN> From: Gustavo Barros <gusbrs.2016@HIDDEN> Message-ID: <280a40e2-24ee-e2f7-12ef-e46fc779d133@HIDDEN> Date: Sat, 21 Apr 2018 21:29:13 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <867ep3q8sw.fsf@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 31132 Cc: 31132 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.7 (/) Hi Arash, thank you very much for the patches. They are really appreciated. And sorry for the delay in reporting back. I didn't have the time these last couple of days to look at this with due care. I've performed some tests with the patches you sent on the full set of biblatex's citation commands, and can gladly report that both "C-c &" (reftex-view-crossref) and "C-c [" (reftex-citation) (when issued on the key of an existing citation command) work flawlessly on all of them. But, in performing the tests, I observed some other things associated with biblatex's citation commands (some related to this issue, some not) that I might as well report too, in the hope they will be useful. As a regular biblatex user, I consider them minor. 1 - The multicite variants of 'volcite' are neither fontified nor call RefTeX when inserted (with "C-c RET"). They are inserted "plain" but, once inserted, "C-c [" will work on them. They are the following: -volcites -Volcites -pvolcites -Pvolcites -fvolcites -Fvolcites -svolcites -Svolcites -tvolcites -Tvolcites -avolcites -Avolcites 2 - A couple of 'volcite' variants are fontified, but don't call RefTeX when inserted: -pvolcite -ftvolcite 3 - One command is not fontified: -footfullcite 4 - 'mcite'-like citation commands are neither fontified, nor call RefTeX when inserted: -mcite -Mcite -mparencite -Mparencite -mfootcite -mfootcitetext -mtextcite -Mtextcite I can report something else too. In the last couple of weeks, for all the critical issues for my regular workflow with LaTeX I found my way around with Emacs, so I think the "potential deal breakers" are overcome. Even though I'm clearly still in the steep part of the learning curve with Emacs, I do believe I've been hooked. Still struggling, but already bewitched. :) So I'm looking forward to sticking around. Thank you very much once again. Best, gusbrs PS: The test file used was the following: \documentclass{article} \begin{filecontents}{biblatex-bib.bib} @book{lamp:94, author = {Leslie Lamport}, title = {LaTeX - {A} Document Preparation System: User's Guide and Reference Manual, Second Edition}, publisher = {Pearson / Prentice Hall}, year = {1994}, isbn = {978-0-201-52983-8}, timestamp = {Fri, 08 Apr 2011 18:21:00 +0200}, } @book{mitt:97, author = {Michel Goossens and Sebastian Rahtz and Frank Mittelbach}, title = {The LaTeX Graphics Companion - Illustrating documents with TeX and PostScript}, series = {Addison-Wesley series on tools and techniques for computer typesetting}, publisher = {Addison-Wesley}, year = {1997}, isbn = {978-0-201-85469-5}, } \end{filecontents} \usepackage[style=authoryear, natbib=true, mcite=true]{biblatex} \addbibresource{biblatex-bib.bib} \begin{document} % Standard commands \cite[pre][pos]{mitt:97} \Cite[pre][pos]{lamp:94} \parencite[pre][pos]{mitt:97} \Parencite[pre][pos]{lamp:94} \footcite[pre][pos]{mitt:97} \footcitetext[pre][pos]{lamp:94} % Style specific commands \textcite[pre][pos]{mitt:97} \Textcite[pre][pos]{lamp:94,} \smartcite[pre][pos]{mitt:97} \Smartcite[pre][pos]{lamp:94} \cite*[pre][pos]{mitt:97} \parencite*[pre][pos]{lamp:94} % \supercite{mitt:97} % Qualified citation lists \cites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94}[pre][pos]{lamp:94} \Cites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \parencites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \Parencites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \footcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \footcitetexts(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \smartcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \Smartcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \textcites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \Textcites(gpre)(gpos)[pre][pos]{lamp:94}[pre][pos]{mitt:97} % \supercites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} % Style independent commands \autocite[pre][pos]{mitt:97} \Autocite[pre][pos]{lamp:94} \autocite*[pre][pos]{mitt:97} \Autocite*[pre][pos]{lamp:94} \autocites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} \Autocites(gpre)(gpos)[pre][pos]{mitt:97}[pre][pos]{lamp:94} % Text commands \citeauthor[pre][pos]{mitt:97} \citeauthor*[pre][pos]{mitt:97} \Citeauthor[pre][pos]{lamp:94} \Citeauthor*[pre][pos]{lamp:94} \citetitle[pre][pos]{mitt:97,lamp:94} \citetitle*[pre][pos]{lamp:94} \citeyear[pre][pos]{mitt:97} \citeyear*[pre][pos]{lamp:94} \citedate[pre][pos]{mitt:97} \citedate*[pre][pos]{lamp:94} \citeurl[pre][pos]{mitt:97} % Special commands \nocite{mitt:97} \fullcite[pre][pos]{lamp:94} \footfullcite[pre][pos]{mitt:97} \volcite[pre]{2}[pg]{mitt:97} \Volcite[pre]{1}[pg]{lamp:94} \volcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} \Volcites(gpre)(gpos)[pre]{2}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} \pvolcite[pre]{1}[pg]{lamp:94} \Pvolcite[pre]{2}[pg]{mitt:97} \pvolcites(gpre)(gpos)[pre]{1}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} \Pvolcites(gpre)(gpos)[pre]{3}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} \fvolcite[pre]{3}[pg]{lamp:94} \ftvolcite[pre]{3}[pg]{lamp:94} \fvolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} \Fvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} \svolcite[pre]{2}[pg]{lamp:94} \Svolcite[pre]{4}[pg]{mitt:97} \svolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} \Svolcites(gpre)(gpos)[pre]{3}[pg]{mitt:97}[pre]{2}[pg]{lamp:94} \tvolcite[pre]{5}[pg]{mitt:97} \Tvolcite[pre]{2}[pg]{lamp:94} \tvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} \Tvolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{3}[pg]{mitt:97} \avolcite[pre]{3}[pg]{lamp:94} \Avolcite[pre]{1}[pg]{mitt:97} \avolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} \Avolcites(gpre)(gpos)[pre]{2}[pg]{lamp:94}[pre]{1}[pg]{mitt:97} \notecite[pre][pos]{lamp:94} \Notecite[pre][pos]{mitt:97} \pnotecite[pre][pos]{mitt:97} \Pnotecite[pre][pos]{lamp:94} \fnotecite[pre][pos]{lamp:94} % Low-level commands \citename[pre][pos]{lamp:94}{author} \citelist[pre][pos]{lamp:94}{publisher} \citefield[pre][pos]{lamp:94}{isbn} % natbib compatibility commands \citet[pre][pos]{mitt:97} \citet*[pre][pos]{lamp:94} \citep[pre][pos]{lamp:94} \citep*[pre][pos]{mitt:97} \citealt[pre][pos]{lamp:94} \citealt*[pre][pos]{mitt:97} \citealp[pre][pos]{mitt:97} \citealp*[pre][pos]{lamp:94} \Citet[pre][pos]{lamp:94} \Citet*[pre][pos]{mitt:97} \Citep[pre][pos]{lamp:94} \Citep*[pre][pos]{mitt:97} % mcite-like citation commands \mcite[pre][pos]{lamp:94,mitt:97} \Mcite[pre][pos]{mitt:97,lamp:94} \mparencite[pre][pos]{lamp:94,mitt:97} \Mparencite[pre][pos]{lamp:94,mitt:97} \mfootcite[pre][pos]{lamp:94,mitt:97} \mfootcitetext[pre][pos]{lamp:94,mitt:97} \mtextcite[pre][pos]{lamp:94,mitt:97} \Mtextcite[pre][pos]{lamp:94,mitt:97} % \msupercite[pre][pos]{lamp:94,mitt:97} \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End: On 19/04/18 16:45, Arash Esbati wrote: > gusbrs.2016@HIDDEN writes: > >> From TeX.SX: https://tex.stackexchange.com/q/425883/105447 >> >> >> RefTeX's relations biblatex's multicite commands (such as \parencites, >> \footcites, \textcites and so on) leave some things to be desired >> for. Namely, they do not seem to be recognized as citation >> commands. This results in RefTeX's `reftex-view-crossref` (C-c &) >> returning "Not on a crossref macro argument". Also, in adding an extra >> bibkey to an already existing multicite command, it is not possible to >> access RefTeX's facilities. >> >> Arash Esbati generously provided patches at TeX.SX that go a long way >> in dealing with these problems. However, support for the presence of >> global optional arguments (between parentheses) is still missing. At >> their request, I write to report this issue. > Hi Gusbrs, > > thanks for the report. I fiddled a little around and I think I have a > working setup for this issue. I think with this patch, RefTeX will also > recognize referencing commands provided by cleveref.sty. > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el > index fd229a6..3f4965a 100644 > --- a/lisp/textmodes/reftex-cite.el > +++ b/lisp/textmodes/reftex-cite.el > @@ -763,7 +763,9 @@ in order to only add another reference in the same cite command." > (setq format "%l")) > > ((and (stringp macro) > - (string-match "\\`\\\\cite\\|cite\\'" macro)) > + (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" macro)) > + ;; Match also commands from biblatex ending with `s' (\cites) or > + ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). > ;; We are already inside a cite macro > (if (or (not arg) (not (listp arg))) > (setq format > diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el > index 74a5e63..b93d05d 100644 > --- a/lisp/textmodes/reftex-dcr.el > +++ b/lisp/textmodes/reftex-dcr.el > @@ -60,10 +60,13 @@ to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." > (setq reftex-call-back-to-this-buffer (current-buffer)) > > (cond > - ((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro) > + ((string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) > + ;; Match also commands from biblatex ending with `s' (\cites) or > + ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). > ;; 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) > + ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) > + ;; Match also commands from cleveref ending with `s' (\namecrefs). > ;; 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) > diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el > index 492f546..31e108c 100644 > --- a/lisp/textmodes/reftex-parse.el > +++ b/lisp/textmodes/reftex-parse.el > @@ -788,12 +788,13 @@ move backward to the closing parenthesis of the previous argument. > This function understands the splitting of macros over several lines > in TeX." > (cond > - ;; Just to be quick: > - ((memq (preceding-char) '(?\] ?\}))) > + ;; Just to be quick: biblatex uses () as delimiters for optional > + ;; arguments in qualified citation lists. > + ((memq (preceding-char) '(?\] ?\) ?\}))) > ;; Do a search > ((and reftex-allow-detached-macro-args > (re-search-backward > - "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) > + "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) > (goto-char (1+ (match-beginning 0))) > t) > (t nil))) > @@ -842,12 +843,22 @@ considered an argument of macro \\macro." > (while (and (reftex-move-to-previous-arg bound) > (condition-case nil > (let ((forward-sexp-function nil)) > - (backward-sexp) t) > + (if (= (preceding-char) ?\)) > + (let ((temp-table (make-syntax-table))) > + (modify-syntax-entry ?\( "()" temp-table) > + (modify-syntax-entry ?\) ")(" temp-table) > + (with-syntax-table temp-table > + (backward-sexp))) > + (backward-sexp)) > + t) > (error nil))) > - (if (eq (following-char) ?\[) (cl-incf cnt-opt)) > + (if (or (eq (following-char) ?\[) > + (eq (following-char) ?\()) > + (cl-incf cnt-opt)) > (cl-incf cnt)) > (setq pos (point)) > (when (and (or (= (following-char) ?\[) > + (= (following-char) ?\() > (= (following-char) ?\{)) > (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) > (setq cmd (reftex-match-string 0)) > --8<---------------cut here---------------end--------------->8--- > > One thing I don't understand is why (backward-sexp) doesn't work on > (Global Pre) arguments. Maybe somebody can enlighten me. For now, I > added a trickery with `with-syntax-table'. > > Further, I think the functions `reftex-move-over-touching-args' and > `reftex-move-to-next-arg' must also be patched in order to support > optional arguments in parentheses. > > My test file for this looks like this. In case somebody wants to try > this out, the complete functions are inserted below. Any comments > welcome. > > > --8<---------------cut here---------------start------------->8--- > \documentclass{article} > > \begin{filecontents}{biblatex-bib.bib} > @book{lamp:94, > author = {Leslie Lamport}, > title = {LaTeX - {A} Document Preparation System: User's Guide > and Reference Manual, Second Edition}, > publisher = {Pearson / Prentice Hall}, > year = {1994}, > isbn = {978-0-201-52983-8}, > timestamp = {Fri, 08 Apr 2011 18:21:00 +0200}, > } > > @book{mitt:97, > author = {Michel Goossens and > Sebastian Rahtz and > Frank Mittelbach}, > title = {The LaTeX Graphics Companion - Illustrating documents > with TeX and PostScript}, > series = {Addison-Wesley series on tools and techniques > for computer typesetting}, > publisher = {Addison-Wesley}, > year = {1997}, > isbn = {978-0-201-85469-5}, > } > \end{filecontents} > > \usepackage[style=authoryear]{biblatex} > > \addbibresource{biblatex-bib.bib} > > \begin{document} > > %% =============== RefTeX standard > > \cite{mitt:97} > ==> \verb|C-c &| Ok, \verb|C-c [| Ok > > \cites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} > ==> \verb|C-c &| Ok, \verb|C-c [| Ok > > \footcitetext[Pre][Post]{mitt:97} > ==> \verb|C-c &| NOk, \verb|C-c [| NOk > > \parencite*[Pre][Post]{mitt:97} > ==> \verb|C-c &| Ok, \verb|C-c [| NOk > > \parencites{mitt:97} > \parencites(GPre)()[Pre][]{mitt:97}[Pre][]{lamp:94} > \parencites(pre)()[pre][]{mitt:97} > \parencites(post)[post]{mitt:97} > ==> \verb|C-c &| NOk, \verb|C-c [| NOk > > %% ============== RefTeX patched > > \parencites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} > ==> \verb|C-c &| Ok, \verb|C-c [| Ok > > \parencites(Global Pre)(Global Post)[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} > ==> \verb|C-c &| Ok, \verb|C-c [| Ok > > > \begin{verbatim} > (defun reftex-view-crossref (&optional arg auto-how fail-quietly) > "View cross reference of macro at point. Point must be on the KEY > argument. When at a `\\ref' macro, show corresponding `\\label' > definition, also in external documents (`xr'). When on a label, show > a locations where KEY is referenced. Subsequent calls find additional > locations. When on a `\\cite', show the associated `\\bibitem' macro or > the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro > which uses this KEY. When on an `\\index', show other locations marked > by the same index entry. > To define additional cross referencing items, use the option > `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. > 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. > (let* ((macro (car (reftex-what-macro-safe 1))) > (key (reftex-this-word "^{}%\n\r, \t")) > dw) > > (if (or (null macro) (reftex-in-comment)) > (or fail-quietly > (error "Not on a crossref macro argument")) > > (setq reftex-call-back-to-this-buffer (current-buffer)) > > (cond > ((string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) > ;; Match also commands from biblatex ending with `s' (\cites) or > ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). > ;; A citation macro: search for bibitems or BibTeX entries > (setq dw (reftex-view-cr-cite arg key auto-how))) > ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) > ;; Match also commands from cleveref ending with `s' (\namecrefs). > ;; 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-figure-out-cite-format (arg &optional no-insert format-key) > "Check if there is already a cite command at point and change cite format > in order to only add another reference in the same cite command." > (let ((macro (car (reftex-what-macro 1))) > (cite-format-value (reftex-get-cite-format)) > key format) > (cond > (no-insert > ;; Format does not really matter because nothing will be inserted. > (setq format "%l")) > > ((and (stringp macro) > (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" macro)) > ;; Match also commands from biblatex ending with `s' (\cites) or > ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). > ;; We are already inside a cite macro > (if (or (not arg) (not (listp arg))) > (setq format > (concat > (if (member (preceding-char) '(?\{ ?,)) > "" > reftex-cite-key-separator) > "%l" > (if (member (following-char) '(?\} ?,)) > "" > reftex-cite-key-separator))) > (setq format "%l"))) > (t > ;; Figure out the correct format > (setq format > (if (and (symbolp cite-format-value) > (assq cite-format-value reftex-cite-format-builtin)) > (nth 2 (assq cite-format-value reftex-cite-format-builtin)) > cite-format-value)) > (when (listp format) > (setq key > (or format-key > (reftex-select-with-char > "" (concat "SELECT A CITATION FORMAT\n\n" > (mapconcat > (lambda (x) > (format "[%c] %s %s" (car x) > (if (> (car x) 31) " " "") > (cdr x))) > format "\n"))))) > (if (assq key format) > (setq format (cdr (assq key format))) > (error "No citation format associated with key `%c'" key))))) > format)) > > (defun reftex-move-to-previous-arg (&optional bound) > "Assuming that we are in front of a macro argument, > move backward to the closing parenthesis of the previous argument. > This function understands the splitting of macros over several lines > in TeX." > (cond > ;; Just to be quick: biblatex uses () as delimiters for optional > ;; arguments in qualified citation lists. > ((memq (preceding-char) '(?\] ?\) ?\}))) > ;; Do a search > ((and reftex-allow-detached-macro-args > (re-search-backward > "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) > (goto-char (1+ (match-beginning 0))) > t) > (t nil))) > > > (defun reftex-what-macro (which &optional bound) > "Find out if point is within the arguments of any TeX-macro. > The return value is either (\"\\macro\" . (point)) or a list of them. > > If WHICH is nil, immediately return nil. > If WHICH is 1, return innermost enclosing macro. > If WHICH is t, return list of all macros enclosing point. > If WHICH is a list of macros, look only for those macros and return the > name of the first macro in this list found to enclose point. > If the optional BOUND is an integer, bound backwards directed > searches to this point. If it is nil, limit to nearest \\section - > like statement. > > This function is pretty stable, but can be fooled if the text contains > things like \\macro{aa}{bb} where \\macro is defined to take only one > argument. As RefTeX cannot know this, the string \"bb\" would still be > considered an argument of macro \\macro." > (unless reftex-section-regexp (reftex-compile-variables)) > (catch 'exit > (if (null which) (throw 'exit nil)) > (let ((bound (or bound (save-excursion (re-search-backward > reftex-section-regexp nil 1) > (point)))) > pos cmd-list cmd cnt cnt-opt entry) > (save-restriction > (save-excursion > (narrow-to-region (max (point-min) bound) (point-max)) > ;; move back out of the current parenthesis > (while (condition-case nil > (let ((forward-sexp-function nil)) > (up-list -1) t) > (error nil)) > (setq cnt 1 cnt-opt 0) > ;; move back over any touching sexps > (while (and (reftex-move-to-previous-arg bound) > (condition-case nil > (let ((forward-sexp-function nil)) > (if (= (preceding-char) ?\)) > (let ((temp-table (make-syntax-table))) > (modify-syntax-entry ?\( "()" temp-table) > (modify-syntax-entry ?\) ")(" temp-table) > (with-syntax-table temp-table > (backward-sexp))) > (backward-sexp)) > t) > (error nil))) > (if (or (eq (following-char) ?\[) > (eq (following-char) ?\()) > (cl-incf cnt-opt)) > (cl-incf cnt)) > (setq pos (point)) > (when (and (or (= (following-char) ?\[) > (= (following-char) ?\() > (= (following-char) ?\{)) > (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) > (setq cmd (reftex-match-string 0)) > (when (looking-at "\\\\begin{[^}]*}") > (setq cmd (reftex-match-string 0) > cnt (1- cnt))) > ;; This does ignore optional arguments. Very hard to fix. > (when (setq entry (assoc cmd reftex-env-or-mac-alist)) > (if (> cnt (or (nth 4 entry) 100)) > (setq cmd nil))) > (cond > ((null cmd)) > ((eq t which) > (push (cons cmd (point)) cmd-list)) > ((or (eq 1 which) (member cmd which)) > (throw 'exit (cons cmd (point)))))) > (goto-char pos))) > (nreverse cmd-list))))) > > \end{verbatim} > > \end{document} > > --8<---------------cut here---------------end--------------->8--- > > Best, Arash
bug-auctex@HIDDEN
:bug#31132
; Package auctex
.
Full text available.Received: (at 31132) by debbugs.gnu.org; 19 Apr 2018 19:46:36 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 19 15:46:36 2018 Received: from localhost ([127.0.0.1]:33217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1f9FVr-0002jQ-PN for submit <at> debbugs.gnu.org; Thu, 19 Apr 2018 15:46:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <arash@HIDDEN>) id 1f9FVp-0002jD-Jl for 31132 <at> debbugs.gnu.org; Thu, 19 Apr 2018 15:46:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <arash@HIDDEN>) id 1f9FVf-0002Sz-3t for 31132 <at> debbugs.gnu.org; Thu, 19 Apr 2018 15:46:28 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <arash@HIDDEN>) id 1f9FVe-0002SH-U0; Thu, 19 Apr 2018 15:46:23 -0400 Received: from p4fe3e094.dip0.t-ipconnect.de ([79.227.224.148]:51866 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from <arash@HIDDEN>) id 1f9FVe-0003FG-Fe; Thu, 19 Apr 2018 15:46:22 -0400 From: Arash Esbati <arash@HIDDEN> To: gusbrs.2016@HIDDEN Subject: Re: bug#31132: AUCTeX, RefTeX and biblatex's multicite commands References: <2040bd1a-7ee5-d7eb-a546-f35b66697686@HIDDEN> Date: Thu, 19 Apr 2018 21:45:51 +0200 In-Reply-To: <2040bd1a-7ee5-d7eb-a546-f35b66697686@HIDDEN> (gusbrs's message of "Wed, 11 Apr 2018 20:35:39 -0300") Message-ID: <867ep3q8sw.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 31132 Cc: 31132 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -6.0 (------) gusbrs.2016@HIDDEN writes: > From TeX.SX: https://tex.stackexchange.com/q/425883/105447 > > > RefTeX's relations biblatex's multicite commands (such as \parencites, > \footcites, \textcites and so on) leave some things to be desired > for. Namely, they do not seem to be recognized as citation > commands. This results in RefTeX's `reftex-view-crossref` (C-c &) > returning "Not on a crossref macro argument". Also, in adding an extra > bibkey to an already existing multicite command, it is not possible to > access RefTeX's facilities. > > Arash Esbati generously provided patches at TeX.SX that go a long way > in dealing with these problems. However, support for the presence of > global optional arguments (between parentheses) is still missing. At > their request, I write to report this issue. Hi Gusbrs, thanks for the report. I fiddled a little around and I think I have a working setup for this issue. I think with this patch, RefTeX will also recognize referencing commands provided by cleveref.sty. --8<---------------cut here---------------start------------->8--- diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index fd229a6..3f4965a 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -763,7 +763,9 @@ in order to only add another reference in the same cite command." (setq format "%l")) ((and (stringp macro) - (string-match "\\`\\\\cite\\|cite\\'" macro)) + (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" macro)) + ;; Match also commands from biblatex ending with `s' (\cites) or + ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). ;; We are already inside a cite macro (if (or (not arg) (not (listp arg))) (setq format diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el index 74a5e63..b93d05d 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el @@ -60,10 +60,13 @@ to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." (setq reftex-call-back-to-this-buffer (current-buffer)) (cond - ((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro) + ((string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) + ;; Match also commands from biblatex ending with `s' (\cites) or + ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). ;; 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) + ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) + ;; Match also commands from cleveref ending with `s' (\namecrefs). ;; 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) diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 492f546..31e108c 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -788,12 +788,13 @@ move backward to the closing parenthesis of the previous argument. This function understands the splitting of macros over several lines in TeX." (cond - ;; Just to be quick: - ((memq (preceding-char) '(?\] ?\}))) + ;; Just to be quick: biblatex uses () as delimiters for optional + ;; arguments in qualified citation lists. + ((memq (preceding-char) '(?\] ?\) ?\}))) ;; Do a search ((and reftex-allow-detached-macro-args (re-search-backward - "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) + "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) (goto-char (1+ (match-beginning 0))) t) (t nil))) @@ -842,12 +843,22 @@ considered an argument of macro \\macro." (while (and (reftex-move-to-previous-arg bound) (condition-case nil (let ((forward-sexp-function nil)) - (backward-sexp) t) + (if (= (preceding-char) ?\)) + (let ((temp-table (make-syntax-table))) + (modify-syntax-entry ?\( "()" temp-table) + (modify-syntax-entry ?\) ")(" temp-table) + (with-syntax-table temp-table + (backward-sexp))) + (backward-sexp)) + t) (error nil))) - (if (eq (following-char) ?\[) (cl-incf cnt-opt)) + (if (or (eq (following-char) ?\[) + (eq (following-char) ?\()) + (cl-incf cnt-opt)) (cl-incf cnt)) (setq pos (point)) (when (and (or (= (following-char) ?\[) + (= (following-char) ?\() (= (following-char) ?\{)) (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) (setq cmd (reftex-match-string 0)) --8<---------------cut here---------------end--------------->8--- One thing I don't understand is why (backward-sexp) doesn't work on (Global Pre) arguments. Maybe somebody can enlighten me. For now, I added a trickery with `with-syntax-table'. Further, I think the functions `reftex-move-over-touching-args' and `reftex-move-to-next-arg' must also be patched in order to support optional arguments in parentheses. My test file for this looks like this. In case somebody wants to try this out, the complete functions are inserted below. Any comments welcome. --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{filecontents}{biblatex-bib.bib} @book{lamp:94, author = {Leslie Lamport}, title = {LaTeX - {A} Document Preparation System: User's Guide and Reference Manual, Second Edition}, publisher = {Pearson / Prentice Hall}, year = {1994}, isbn = {978-0-201-52983-8}, timestamp = {Fri, 08 Apr 2011 18:21:00 +0200}, } @book{mitt:97, author = {Michel Goossens and Sebastian Rahtz and Frank Mittelbach}, title = {The LaTeX Graphics Companion - Illustrating documents with TeX and PostScript}, series = {Addison-Wesley series on tools and techniques for computer typesetting}, publisher = {Addison-Wesley}, year = {1997}, isbn = {978-0-201-85469-5}, } \end{filecontents} \usepackage[style=authoryear]{biblatex} \addbibresource{biblatex-bib.bib} \begin{document} %% =============== RefTeX standard \cite{mitt:97} ==> \verb|C-c &| Ok, \verb|C-c [| Ok \cites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} ==> \verb|C-c &| Ok, \verb|C-c [| Ok \footcitetext[Pre][Post]{mitt:97} ==> \verb|C-c &| NOk, \verb|C-c [| NOk \parencite*[Pre][Post]{mitt:97} ==> \verb|C-c &| Ok, \verb|C-c [| NOk \parencites{mitt:97} \parencites(GPre)()[Pre][]{mitt:97}[Pre][]{lamp:94} \parencites(pre)()[pre][]{mitt:97} \parencites(post)[post]{mitt:97} ==> \verb|C-c &| NOk, \verb|C-c [| NOk %% ============== RefTeX patched \parencites[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} ==> \verb|C-c &| Ok, \verb|C-c [| Ok \parencites(Global Pre)(Global Post)[Pre][Post]{mitt:97}[Pre][Post]{lamp:94} ==> \verb|C-c &| Ok, \verb|C-c [| Ok \begin{verbatim} (defun reftex-view-crossref (&optional arg auto-how fail-quietly) "View cross reference of macro at point. Point must be on the KEY argument. When at a `\\ref' macro, show corresponding `\\label' definition, also in external documents (`xr'). When on a label, show a locations where KEY is referenced. Subsequent calls find additional locations. When on a `\\cite', show the associated `\\bibitem' macro or the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro which uses this KEY. When on an `\\index', show other locations marked by the same index entry. To define additional cross referencing items, use the option `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. 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. (let* ((macro (car (reftex-what-macro-safe 1))) (key (reftex-this-word "^{}%\n\r, \t")) dw) (if (or (null macro) (reftex-in-comment)) (or fail-quietly (error "Not on a crossref macro argument")) (setq reftex-call-back-to-this-buffer (current-buffer)) (cond ((string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'\\|bibentry" macro) ;; Match also commands from biblatex ending with `s' (\cites) or ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). ;; A citation macro: search for bibitems or BibTeX entries (setq dw (reftex-view-cr-cite arg key auto-how))) ((string-match "\\`\\\\ref\\|ref\\(s\\|range\\)?\\*?\\'" macro) ;; Match also commands from cleveref ending with `s' (\namecrefs). ;; 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-figure-out-cite-format (arg &optional no-insert format-key) "Check if there is already a cite command at point and change cite format in order to only add another reference in the same cite command." (let ((macro (car (reftex-what-macro 1))) (cite-format-value (reftex-get-cite-format)) key format) (cond (no-insert ;; Format does not really matter because nothing will be inserted. (setq format "%l")) ((and (stringp macro) (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" macro)) ;; Match also commands from biblatex ending with `s' (\cites) or ;; `*' (\parencite*) and `texts?' (\footcitetext and \footcitetexts). ;; We are already inside a cite macro (if (or (not arg) (not (listp arg))) (setq format (concat (if (member (preceding-char) '(?\{ ?,)) "" reftex-cite-key-separator) "%l" (if (member (following-char) '(?\} ?,)) "" reftex-cite-key-separator))) (setq format "%l"))) (t ;; Figure out the correct format (setq format (if (and (symbolp cite-format-value) (assq cite-format-value reftex-cite-format-builtin)) (nth 2 (assq cite-format-value reftex-cite-format-builtin)) cite-format-value)) (when (listp format) (setq key (or format-key (reftex-select-with-char "" (concat "SELECT A CITATION FORMAT\n\n" (mapconcat (lambda (x) (format "[%c] %s %s" (car x) (if (> (car x) 31) " " "") (cdr x))) format "\n"))))) (if (assq key format) (setq format (cdr (assq key format))) (error "No citation format associated with key `%c'" key))))) format)) (defun reftex-move-to-previous-arg (&optional bound) "Assuming that we are in front of a macro argument, move backward to the closing parenthesis of the previous argument. This function understands the splitting of macros over several lines in TeX." (cond ;; Just to be quick: biblatex uses () as delimiters for optional ;; arguments in qualified citation lists. ((memq (preceding-char) '(?\] ?\) ?\}))) ;; Do a search ((and reftex-allow-detached-macro-args (re-search-backward "[])}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)) (goto-char (1+ (match-beginning 0))) t) (t nil))) (defun reftex-what-macro (which &optional bound) "Find out if point is within the arguments of any TeX-macro. The return value is either (\"\\macro\" . (point)) or a list of them. If WHICH is nil, immediately return nil. If WHICH is 1, return innermost enclosing macro. If WHICH is t, return list of all macros enclosing point. If WHICH is a list of macros, look only for those macros and return the name of the first macro in this list found to enclose point. If the optional BOUND is an integer, bound backwards directed searches to this point. If it is nil, limit to nearest \\section - like statement. This function is pretty stable, but can be fooled if the text contains things like \\macro{aa}{bb} where \\macro is defined to take only one argument. As RefTeX cannot know this, the string \"bb\" would still be considered an argument of macro \\macro." (unless reftex-section-regexp (reftex-compile-variables)) (catch 'exit (if (null which) (throw 'exit nil)) (let ((bound (or bound (save-excursion (re-search-backward reftex-section-regexp nil 1) (point)))) pos cmd-list cmd cnt cnt-opt entry) (save-restriction (save-excursion (narrow-to-region (max (point-min) bound) (point-max)) ;; move back out of the current parenthesis (while (condition-case nil (let ((forward-sexp-function nil)) (up-list -1) t) (error nil)) (setq cnt 1 cnt-opt 0) ;; move back over any touching sexps (while (and (reftex-move-to-previous-arg bound) (condition-case nil (let ((forward-sexp-function nil)) (if (= (preceding-char) ?\)) (let ((temp-table (make-syntax-table))) (modify-syntax-entry ?\( "()" temp-table) (modify-syntax-entry ?\) ")(" temp-table) (with-syntax-table temp-table (backward-sexp))) (backward-sexp)) t) (error nil))) (if (or (eq (following-char) ?\[) (eq (following-char) ?\()) (cl-incf cnt-opt)) (cl-incf cnt)) (setq pos (point)) (when (and (or (= (following-char) ?\[) (= (following-char) ?\() (= (following-char) ?\{)) (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) (setq cmd (reftex-match-string 0)) (when (looking-at "\\\\begin{[^}]*}") (setq cmd (reftex-match-string 0) cnt (1- cnt))) ;; This does ignore optional arguments. Very hard to fix. (when (setq entry (assoc cmd reftex-env-or-mac-alist)) (if (> cnt (or (nth 4 entry) 100)) (setq cmd nil))) (cond ((null cmd)) ((eq t which) (push (cons cmd (point)) cmd-list)) ((or (eq 1 which) (member cmd which)) (throw 'exit (cons cmd (point)))))) (goto-char pos))) (nreverse cmd-list))))) \end{verbatim} \end{document} --8<---------------cut here---------------end--------------->8--- Best, Arash
bug-auctex@HIDDEN
:bug#31132
; Package auctex
.
Full text available.Received: (at submit) by debbugs.gnu.org; 12 Apr 2018 06:05:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 12 02:05:31 2018 Received: from localhost ([127.0.0.1]:46962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1f6VMR-0003oG-2V for submit <at> debbugs.gnu.org; Thu, 12 Apr 2018 02:05:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHP-00019W-RT for submit <at> debbugs.gnu.org; Wed, 11 Apr 2018 19:35:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHJ-0006hv-Kc for submit <at> debbugs.gnu.org; Wed, 11 Apr 2018 19:35:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_40, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:35781) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHJ-0006hF-HU for submit <at> debbugs.gnu.org; Wed, 11 Apr 2018 19:35:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHI-0005FQ-6A for bug-auctex@HIDDEN; Wed, 11 Apr 2018 19:35:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHF-0006ef-3x for bug-auctex@HIDDEN; Wed, 11 Apr 2018 19:35:48 -0400 Received: from mail-it0-x232.google.com ([2607:f8b0:4001:c0b::232]:51508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <gusbrs.2016@HIDDEN>) id 1f6PHE-0006eJ-UR for bug-auctex@HIDDEN; Wed, 11 Apr 2018 19:35:45 -0400 Received: by mail-it0-x232.google.com with SMTP id b5-v6so5046188itj.1 for <bug-auctex@HIDDEN>; Wed, 11 Apr 2018 16:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:subject:to:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=bv/Jw+p9SOJQfg6z3GGA1EKlOqiCNYw/zdDx0RJq+TA=; b=AyynaxYPeJW1L1fzm90uS/UX0stzPA6BbYTbzAvU9pMglTFbSrSlsuvP58CxKxkQgF CQgH9Gv1uSbG3c2m/jOAJEClk/cB6KwGloWkkUt1WWf1+3EA2WfzwZ6310FyNQfUBf3r vJkKrkBCIoyBxGPJwRvG/flKkkkAO9dX+0+249E9R+UXpnrfXJqmuTTOfiItdjrlEOAm epOTRGHRlSbjD+bsgiEGqiyXiQVZauYimfDHu8K6Cod42XKP9ZDkAm6JYZijXOn3jzcY fZeryeemVIINNBELzhcr3bphtwfqE5QzP4CUEEqLq2VvMifMQ94CgcfTarWWrTHmbOD8 wh3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:subject:to:message-id:date :user-agent:mime-version:content-transfer-encoding:content-language; bh=bv/Jw+p9SOJQfg6z3GGA1EKlOqiCNYw/zdDx0RJq+TA=; b=iEwVe/I/kNZKyDDmoKvEAaTKvujv/YyCIODnLYh7CH45z3cqpYX5gOHmTAbmiUmpvz k2bYVhqDIjrH47hE4L+eIMDVhyLU/qQGaDwE74YHjizc7mKygq4FKCsB2FvsoeaSGEDc /kJ8a5EqrlzNu80od7PTKOfLk6qkAf9tm2mMjeVseErXreQA0TAA3KrzzyzKcIyHIi8D yrESipvt0d+dErCSfWlZN54AW9CNILrW5osElRsgc/qwoc/W3qPw/xBYViUAWLPJ/caD xNZTnj/yvb5Jscmy3/crH2OTIcWSOlZOYs9FAKaZuivOTwYIGIyqns/d9VOopZZKemKD t9Kw== X-Gm-Message-State: ALQs6tAtgodSLhr5sg2hujOyzmtON9rDa1zgCr6bPOWHd+ZBs2JaN6S1 EiIQr6MbkQoJ4DNPqabIsCd8AlhQ X-Google-Smtp-Source: AIpwx48urkx7lAHnbt2UYCpdiGYWyrO1WNsudmHgNn5JYOSTqEr3J0mFfx8xrT/aTaT05x4zTlDpWA== X-Received: by 2002:a24:2903:: with SMTP id p3-v6mr6159506itp.10.1523489743502; Wed, 11 Apr 2018 16:35:43 -0700 (PDT) Received: from [10.5.14.6] (ip-28-39-52-196.chicago.us.northamericancoax.com. [196.52.39.28]) by smtp.gmail.com with ESMTPSA id y86-v6sm1275168ita.41.2018.04.11.16.35.42 for <bug-auctex@HIDDEN> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Apr 2018 16:35:42 -0700 (PDT) From: gusbrs.2016@HIDDEN Subject: AUCTeX, RefTeX and biblatex's multicite commands To: bug-auctex@HIDDEN Message-ID: <2040bd1a-7ee5-d7eb-a546-f35b66697686@HIDDEN> Date: Wed, 11 Apr 2018 20:35:39 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 12 Apr 2018 02:05:30 -0400 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.8 (----) From TeX.SX: https://tex.stackexchange.com/q/425883/105447 RefTeX's relations biblatex's multicite commands (such as \parencites, \footcites, \textcites and so on) leave some things to be desired for. Namely, they do not seem to be recognized as citation commands. This results in RefTeX's `reftex-view-crossref` (C-c &) returning "Not on a crossref macro argument". Also, in adding an extra bibkey to an already existing multicite command, it is not possible to access RefTeX's facilities. Arash Esbati generously provided patches at TeX.SX that go a long way in dealing with these problems. However, support for the presence of global optional arguments (between parentheses) is still missing. At their request, I write to report this issue. So, I kindly request that this issue be addressed when opportune. With my warmest thanks for the great software, gusbrs
gusbrs.2016@HIDDEN
:bug-auctex@HIDDEN
.
Full text available.bug-auctex@HIDDEN
:bug#31132
; Package auctex
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.