Package: auctex;
Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>
Date: Sun, 17 Nov 2019 19:58:01 UTC
Severity: normal
Tags: wontfix
Found in version 12.2.0
Done: Arash Esbati <arash <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38249 in the body.
You can then email your comments to 38249 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sun, 17 Nov 2019 19:58:02 GMT) Full text and rfc822 format available.Gustavo Barros <gusbrs.2016 <at> gmail.com>
:bug-auctex <at> gnu.org
.
(Sun, 17 Nov 2019 19:58:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Gustavo Barros <gusbrs.2016 <at> gmail.com> To: bug-auctex <at> gnu.org Subject: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sun, 17 Nov 2019 16:57:37 -0300
Hi all, `reftex-create-bibtex-file' is a neat RefTeX utility, but it doesn’t seem to handle some peculiarities of `biblatex', namely: - `reftex-all-used-citation-keys', the auxiliary function used by `reftex-create-bibtex-file' to generate the list of entries cited in the document, does not include entries cited in qualified citation lists. - `reftex-create-bibtex-file' handles the traditional BibTeX `crossref' and `string' fields, but biblatex extends data inheritance and entry cross-reference with such fields as `xref', `xdata' and `set', which are not taken care of. A MWE which illustrates these cases is: #+begin_export latex \documentclass{article} \usepackage[minxrefs=1]{biblatex} \usepackage{filecontents} \begin{filecontents}{mwe_bib.bib} @article{sigfridsson, author = {Sigfridsson, Emma and Ryde, Ulf}, title = {Comparison of methods for deriving atomic charges from the electrostatic potential and moments}, journaltitle = {Journal of Computational Chemistry}, date = 1998, volume = 19, number = 4, pages = {377-395}, doi = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P}, } @article{reese, author = {Reese, Trevor R.}, title = {Georgia in {Anglo-Spanish} Diplomacy, 1736--1739}, journaltitle = {William and Mary Quarterly}, date = 1958, series = 3, volume = 15, pages = {168-190}, } @book{companion, author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander}, title = {The {LaTeX} Companion}, date = 1994, edition = 1, publisher = {Addison-Wesley}, location = {Reading, Mass.}, pagetotal = 528, } @incollection{westfahl:space, author = {Westfahl, Gary}, title = {The True Frontier}, subtitle = {Confronting and Avoiding the Realities of Space in {American} Science Fiction Films}, pages = {55-65}, xref = {westfahl:frontier}, } @collection{westfahl:frontier, editor = {Westfahl, Gary}, title = {Space and Beyond}, date = 2000, subtitle = {The Frontier Theme in Science Fiction}, publisher = {Greenwood}, location = {Westport, Conn. and London}, } @xdata{hup, publisher = {Harvard University Press}, location = {Cambridge, Mass.}, } @incollection{pines, author = {Pines, Shlomo}, editor = {Twersky, Isadore}, title = {The Limitations of Human Knowledge According to {Al-Farabi}, {ibn Bajja}, and {Maimonides}}, date = 1979, booktitle = {Studies in Medieval {Jewish} History and Literature}, xdata = {hup}, pages = {82-109}, shorttitle = {Limitations of Human Knowledge}, } @set{stdmodel, entryset = {glashow,weinberg,salam}, annotation = {A \texttt{set} with three members discussing the standard model of particle physics.}, } @article{glashow, author = {Glashow, Sheldon}, title = {Partial Symmetries of Weak Interactions}, journaltitle = {Nucl.~Phys.}, date = 1961, volume = 22, pages = {579-588}, } @article{weinberg, author = {Weinberg, Steven}, title = {A Model of Leptons}, journaltitle = {Phys.~Rev.~Lett.}, date = 1967, volume = 19, pages = {1264-1266}, } @inproceedings{salam, author = {Salam, Abdus}, editor = {Svartholm, Nils}, title = {Weak and Electromagnetic Interactions}, date = 1968, booktitle = {Elementary particle theory}, booksubtitle = {Relativistic groups and analyticity}, booktitleaddon= {Proceedings of the {Eighth Nobel Symposium}}, eventdate = {1968-05-19/1968-05-25}, venue = {Aspen{\"a}sgarden, Lerum}, publisher = {Almquist \& Wiksell}, location = {Stockholm}, pages = {367-377}, } \end{filecontents} \addbibresource{mwe_bib.bib} \begin{document} % Entries cited in qualified citation lists are missing in the file generated by `reftex-create-bibtex-file'. \cites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion}. \textcites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion}. \parencites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion}. % Entry `westfahl:space' xref's entry `westfahl:frontier'. The latter should be included in the bibliography, given option `minxrefs=1', but it is missing in the file generated by `reftex-create-bibtex-file'. \cite{westfahl:space}. % Entry `pines' uses xdata from entry `hup', but the latter is missing in the file generated by `reftex-create-bibtex-file'. \cite{pines}. % Set `stdmodel' is composed by entries `glashow', `weinberg' and `salam', wich are missing in the file generated by `reftex-create-bibtex-file'. \cite{stdmodel}. \printbibliography{} \end{document} #+end_export The content of the file generated by `reftex-create-bibtex-file' on the above MWE is: #+begin_example @incollection{westfahl:space, author = {Westfahl, Gary}, title = {The True Frontier}, subtitle = {Confronting and Avoiding the Realities of Space in {American} Science Fiction Films}, pages = {55-65}, xref = {westfahl:frontier}, } @incollection{pines, author = {Pines, Shlomo}, editor = {Twersky, Isadore}, title = {The Limitations of Human Knowledge According to {Al-Farabi}, {ibn Bajja}, and {Maimonides}}, date = 1979, booktitle = {Studies in Medieval {Jewish} History and Literature}, xdata = {hup}, pages = {82-109}, shorttitle = {Limitations of Human Knowledge}, } @set{stdmodel, entryset = {glashow,weinberg,salam}, annotation = {A \texttt{set} with three members discussing the standard model of particle physics.}, } #+end_example However, all the entries initially provided are required for the MWE to work correctly. Best regards, Gustavo Barros. Emacs : GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-11-11 Package: 12.2.0 current state: ============== (setq AUCTeX-date "2019-10-31" window-system 'x LaTeX-version "2e" TeX-style-path '("/home/gustavo/.emacs.d/auctex" "/home/gustavo/.emacs.d/elpa/auctex-12.2.0/style" "/home/gustavo/.emacs.d/AUCTeX/auto" "/home/gustavo/.emacs.d/AUCTeX/style" ".auctex-auto" "auctex-style") TeX-auto-save t TeX-parse-self t TeX-master t TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %(extraopts) %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo %(extraopts) --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode) :help "Run BibTeX") ("Biber" "biber %s" TeX-run-Biber nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run Biber") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Generate PostScript file") ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PostScript") ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PDF with dvipdfmx") ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert PostScript file to PDF") ("Glossaries" "makeglossaries %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeglossaries to create glossary\n file") ("Index" "makeindex %s" TeX-run-index nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeindex to create index file") ("upMendex" "upmendex %s" TeX-run-index t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run upmendex to create index file") ("Xindy" "texindy %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run xindy to create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for common mistakes") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command") ("make4odt" "make4ht -f odt %t" TeX-run-TeX nil (latex-mode)) ("make4html" "make4ht -uf html5+tidy %t" TeX-run-TeX nil (latex-mode)) ("Arara" "arara --verbose %s" TeX-run-TeX nil t :help "Run Arara.") ) )
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Thu, 11 Apr 2024 08:38:02 GMT) Full text and rfc822 format available.Message #8 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: Gustavo Barros <gusbrs.2016 <at> gmail.com> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Thu, 11 Apr 2024 10:36:44 +0200
Hi Gustavo, Gustavo Barros <gusbrs.2016 <at> gmail.com> writes: > `reftex-create-bibtex-file' is a neat RefTeX utility, but it doesn’t > seem to handle some peculiarities of `biblatex', namely: > > - `reftex-all-used-citation-keys', the auxiliary function used by > `reftex-create-bibtex-file' to generate the list of entries cited in > the document, does not include entries cited in qualified citation > lists. How do you write these citation lists, especially the long one? I mean, what is the syntax of the TeX parser for this? For example, do you write: \textcites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion} or \textcites(See, for example)()[45]{sigfridsson}% [67]{reese}[24]{companion} and some such? I'm asking because for the version with everything in a single line, the following change should work: --8<---------------cut here---------------start------------->8--- (defun reftex-all-used-citation-keys () "Return a list of all citation keys used in document." (reftex-access-scan-info) ;; FIXME: multicites macros provided by biblatex ;; are not covered in this function. (let ((files (reftex-all-document-files)) (re (concat "\\\\" "\\(?:" ;; biblatex volcite macros take these args: ;; \volcite[prenote]{volume}[pages]{key} ;; so cater for the first 3 args: (regexp-opt '("volcite" "Volcite" "pvolcite" "Pvolcite" "fvolcite" "ftvolcite" "svolcite" "Svolcite" "tvolcite" "Tvolcite" "avolcite" "Avolcite")) "\\(?:\\[[^]]*\\]\\)?" "{[^}]*}" "\\(?:\\[[^]]*\\]\\)?" "\\|" ;; Other cite macros usually go like: ;; \cite[prenote][postnote]{key} ;; so cater for the optional args: "\\(?:bibentry\\|[a-zA-Z]*[Cc]ite[a-zA-Z*]*\\)" "\\(?:\\[[^]]*\\]\\)\\{0,2\\}" "\\)" ;; Now match the key: "{\\([^}]+\\)}")) (re2 (concat "\\\\" (regexp-opt '("cites" "Cites" "parencites" "Parencites" "footcites" "footcitetexts" "smartcites" "Smartcites" "textcites" "Textcites" "supercites" "autocites" "Autocites" "volcites" "Volcites" "pvolcites" "Pvolcites" "fvolcites" "Fvolcites" "svolcites" "Svolcites" "tvolcites" "Tvolcites" "avolcites" "Avolcites")) "\\(?:([^)]*)\\)\\{0,2\\}")) (re3 (concat "\\(?:\\[[^]]*\\]\\)\\{0,2\\}" "{\\([^}]+\\)}")) file keys kk k) (save-current-buffer (while (setq file (pop files)) (set-buffer (reftex-get-file-buffer-force file 'mark)) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward re nil t) ;; Make sure we're not inside a comment: (unless (save-match-data (nth 4 (syntax-ppss))) (setq kk (match-string-no-properties 1)) (while (string-match "%.*\n?" kk) (setq kk (replace-match "" t t kk))) (setq kk (split-string kk "[, \t\r\n]+")) (while (setq k (pop kk)) (or (member k keys) (setq keys (cons k keys))))))))) ;; Re-set `files': (setq files (reftex-all-document-files)) ;; And now search for citation lists: (while (setq file (pop files)) (set-buffer (reftex-get-file-buffer-force file 'mark)) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward re2 nil t) ;; Make sure we're not inside a comment: (unless (save-match-data (nth 4 (syntax-ppss))) (while (and (looking-at re3) (goto-char (match-end 0))) (setq kk (match-string-no-properties 1)) (while (string-match "%.*\n?" kk) (setq kk (replace-match "" t t kk))) (setq kk (split-string kk "[, \t\r\n]+")) (while (setq k (pop kk)) (or (member k keys) (setq keys (cons k keys))))))))))) (reftex-kill-temporary-buffers) keys)) --8<---------------cut here---------------end--------------->8--- Do you want to give it a roll? > - `reftex-create-bibtex-file' handles the traditional BibTeX `crossref' > and `string' fields, but biblatex extends data inheritance and entry > cross-reference with such fields as `xref', `xdata' and `set', which > are not taken care of. I have to think about this one. Best, Arash
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Thu, 11 Apr 2024 13:09:02 GMT) Full text and rfc822 format available.Message #11 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: gusbrs <gusbrs.2016 <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Thu, 11 Apr 2024 10:08:16 -0300
Hi Arash, thank you for looking into this. On Thu, 11 Apr 2024 at 05:36, Arash Esbati <arash <at> gnu.org> wrote: > How do you write these citation lists, especially the long one? I mean, > what is the syntax of the TeX parser for this? For example, do you > write: > > \textcites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion} > > or > > \textcites(See, for example)()[45]{sigfridsson}% > [67]{reese}[24]{companion} > > and some such? I'm asking because for the version with everything in a > single line, the following change should work: I can see you cursing me when you read this one. :-) But, worse, much worse, I'm a sinner: I enable `reftex-allow-detached-macro-args' and use it widely ("wildly" one might say). An example from an actual document of mine: destes sobre os benefícios obtidos pelas diferentes partes envolvidas e os resultados gerais da valorização.\footcites(Sobre a primeira valorização, veja)() {Holloway1978} [40-88]{DelfimNo1959} [vol.~10, \pnfmt{55-218}, vol.~11, \pnfmt{35-436}]{Taunay1941} [213-225]{Fausto1989} [52-66]{Pelaez1971} [494-501]{Krasner1973} [410-463]{Calogeras1960} [13-22]{Fritsch1988} [44-50, 188-195]{Love1980} [62-73, 84-91]{Topik1987} [112-134]{Kugelmas1986} Or how about: militar, mas que contrastava com ele ao especificar detalhadamente as medidas a serem tomadas.\footnote{\cites[1917, vol.~II, sessão de 20/06/1917, \pnfmt{125-131}]{AS} % Assinado: % Pires Ferreira (PI), presidente % F. Mendes de Almeida (MA), relator % A. Indio do Brasil (PA) % Soares dos Santos (RS) % todos militares [1917, vol.~III, sessão de 04/07/1917, \pnfmt{30-34}]{AS}. A primeira referência é a publicação original da leitura do parecer em plenário, mas (I hope the email will preserve line breaks, but I think this should be enough to grasp how bad it can get). This is legit (La)TeX syntax, or at least valid (see https://tex.stackexchange.com/a/175359/105447). From AUCTeX/RefTeX's sides pretty much everything works, except that you cannot detach the very first argument after the macro. (If I recall correctly, this exception is due to an implementation detail in font-latex.el, but I don't recall if I had filled this as a mal-function or not, I'm just used to it by now. I also don't recall if this exception affects only citation lists or is general, probably general). (My ears feel hot by now, I don't know what might be going on. :-D ). > Do you want to give it a roll? I did some light testing and it does indeed handle the MWE of the original report, that is, the simplest cases. But it is easy to beat it, you know it. Simply detaching the arguments with white space is enough to fool it (that would be easy to fix, I guess). Any macro in the pre- or postnotes which itself has an optional argument would fool `re3' and break the loop (that would be hard to fix...). And, as you have noted yourself, a comment between two arguments would also beat it. I'm sure you know much better than me how hard it is to parse TeX arguments solely based on regexps (as opposed to sexp navigation). Despite that, I'd say this is still a good improvement relative to the current state of things, and you might want to go with it. That said, I really don't recall what the "barely out of noobness five year ago me" was up to when "he" opened this bug report. But gladly people learn and, nowadays, I'd not even consider for this task something which does not rely on generated files (.aux, .bcf, etc.) instead of the main file. biber tool mode, bibtool, bibexport, there are plenty of options (https://tex.stackexchange.com/q/41821/105447 seems to be a good list). So, while the "old me" opened this report, the "current me" would advise you not to invest much of your time in this. It is a losing battle. You can improve things on the margin but ultimately it will always remain a "good approximation". Unless, of course, you want to go all out and start parsing the relevant generated files. But I'm not sure RefTeX should invest in this, given there are specialized tools for that. True, `reftex-create-bibtex-file' already exists, so it does pose the question as to whether "let it wane", "marginally improve" or "replace it with something better" is the best option. Not a question for me to answer tough. ;-) WDYT? Best, gusbrs
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Thu, 11 Apr 2024 15:47:01 GMT) Full text and rfc822 format available.Message #14 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: gusbrs <gusbrs.2016 <at> gmail.com> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Thu, 11 Apr 2024 17:45:57 +0200
gusbrs <gusbrs.2016 <at> gmail.com> writes: > I can see you cursing me when you read this one. :-) > But, worse, much worse, I'm a sinner: I enable > `reftex-allow-detached-macro-args' and use it widely ("wildly" one > might say). I thought you were a nice guy, but that's about to change ;-) Persoally, I don't like detached args, but that's only me, and it's a matter of taste, so it doesn't really count. > An example from an actual document of mine: > > destes sobre os benefícios obtidos pelas diferentes partes envolvidas e os > resultados gerais da valorização.\footcites(Sobre a primeira valorização, > veja)() {Holloway1978} [40-88]{DelfimNo1959} [vol.~10, \pnfmt{55-218}, > vol.~11, \pnfmt{35-436}]{Taunay1941} [213-225]{Fausto1989} > [52-66]{Pelaez1971} [494-501]{Krasner1973} [410-463]{Calogeras1960} > [13-22]{Fritsch1988} [44-50, 188-195]{Love1980} [62-73, 84-91]{Topik1987} > [112-134]{Kugelmas1986} > > Or how about: > > militar, mas que contrastava com ele ao especificar detalhadamente as medidas > a serem tomadas.\footnote{\cites[1917, vol.~II, sessão de 20/06/1917, > \pnfmt{125-131}]{AS} > % Assinado: > % Pires Ferreira (PI), presidente > % F. Mendes de Almeida (MA), relator > % A. Indio do Brasil (PA) > % Soares dos Santos (RS) > % todos militares > [1917, vol.~III, sessão de 04/07/1917, \pnfmt{30-34}]{AS}. A primeira > referência é a publicação original da leitura do parecer em plenário, mas > > (I hope the email will preserve line breaks, but I think this should > be enough to grasp how bad it can get). Can you please try this on your files: --8<---------------cut here---------------start------------->8--- (defun reftex-all-used-citation-keys () "Return a list of all citation keys used in document." (reftex-access-scan-info) ;; FIXME: multicites macros provided by biblatex ;; are not covered in this function. (let ((files (reftex-all-document-files)) (re (concat "\\\\" "\\(?:" ;; biblatex volcite macros take these args: ;; \volcite[prenote]{volume}[pages]{key} ;; so cater for the first 3 args: (regexp-opt '("volcite" "Volcite" "pvolcite" "Pvolcite" "fvolcite" "ftvolcite" "svolcite" "Svolcite" "tvolcite" "Tvolcite" "avolcite" "Avolcite")) "\\(?:\\[[^]]*\\]\\)?" "{[^}]*}" "\\(?:\\[[^]]*\\]\\)?" "\\|" ;; Other cite macros usually go like: ;; \cite[prenote][postnote]{key} ;; so cater for the optional args: "\\(?:bibentry\\|[a-zA-Z]*[Cc]ite[a-zA-Z*]*\\)" "\\(?:\\[[^]]*\\]\\)\\{0,2\\}" "\\)" ;; Now match the key: "{\\([^}]+\\)}")) (re2 (concat "\\\\" (regexp-opt '("cites" "Cites" "parencites" "Parencites" "footcites" "footcitetexts" "smartcites" "Smartcites" "textcites" "Textcites" "supercites" "autocites" "Autocites" "volcites" "Volcites" "pvolcites" "Pvolcites" "fvolcites" "Fvolcites" "svolcites" "Svolcites" "tvolcites" "Tvolcites" "avolcites" "Avolcites")) "\\(?:([^)]*)\\)\\{0,2\\}")) (re3 (concat "\\(?:\\[[^]]*\\]\\)\\{0,2\\}" "{\\([^}]+\\)}")) file keys kk k) (save-current-buffer (while (setq file (pop files)) (set-buffer (reftex-get-file-buffer-force file 'mark)) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward re nil t) ;; Make sure we're not inside a comment: (unless (save-match-data (nth 4 (syntax-ppss))) (setq kk (match-string-no-properties 1)) (while (string-match "%.*\n?" kk) (setq kk (replace-match "" t t kk))) (setq kk (split-string kk "[, \t\r\n]+")) (while (setq k (pop kk)) (or (member k keys) (setq keys (cons k keys))))))))) ;; Re-set `files': (setq files (reftex-all-document-files)) ;; And now search for citation lists: (while (setq file (pop files)) (set-buffer (reftex-get-file-buffer-force file 'mark)) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward re2 nil t) ;; Make sure we're not inside a comment: (unless (save-match-data (nth 4 (syntax-ppss))) (while (progn ;; (and reftex-allow-detached-macro-args (while (looking-at "[ \t\r\n]+\\|%.*\n") (goto-char (match-end 0))) ;; ) (and (looking-at re3) (goto-char (match-end 0)))) (setq kk (match-string-no-properties 1)) (while (string-match "%.*\n?" kk) (setq kk (replace-match "" t t kk))) (setq kk (split-string kk "[, \t\r\n]+")) (while (setq k (pop kk)) (or (member k keys) (setq keys (cons k keys))))))))))) (reftex-kill-temporary-buffers) keys)) --8<---------------cut here---------------end--------------->8--- I think in this particular case, we should ignore the value of `reftex-allow-detached-macro-args'. > From AUCTeX/RefTeX's sides pretty much everything works, except that > you cannot detach the very first argument after the macro. (If I > recall correctly, this exception is due to an implementation detail in > font-latex.el, but I don't recall if I had filled this as a > mal-function or not, I'm just used to it by now. I also don't recall > if this exception affects only citation lists or is general, probably > general). Can you show a concrete example? > I did some light testing and it does indeed handle the MWE of the > original report, that is, the simplest cases. But it is easy to beat > it, you know it. Simply detaching the arguments with white space is > enough to fool it (that would be easy to fix, I guess). Any macro in > the pre- or postnotes which itself has an optional argument would fool > `re3' and break the loop (that would be hard to fix...). I will think about this one; we could allow one level of balanced braces inside the arg. > And, as you have noted yourself, a comment between two arguments would > also beat it. I'm sure you know much better than me how hard it is to > parse TeX arguments solely based on regexps (as opposed to sexp > navigation). Not always: Try "\foo[opti{]}onal]{}" in a .tex file, put point on [ and hit 'C-M-f'. > That said, I really don't recall what the "barely out of noobness five > year ago me" was up to when "he" opened this bug report. But gladly > people learn and, nowadays, I'd not even consider for this task > something which does not rely on generated files (.aux, .bcf, etc.) > instead of the main file. biber tool mode, bibtool, bibexport, there > are plenty of options (https://tex.stackexchange.com/q/41821/105447 > seems to be a good list). So, while the "old me" opened this report, > the "current me" would advise you not to invest much of your time in > this. It is a losing battle. You can improve things on the margin but > ultimately it will always remain a "good approximation". Unless, of > course, you want to go all out and start parsing the relevant > generated files. But I'm not sure RefTeX should invest in this, given > there are specialized tools for that. Agreed. > True, `reftex-create-bibtex-file' already exists, so it does pose the > question as to whether "let it wane", "marginally improve" or "replace > it with something better" is the best option. Not a question for me to > answer tough. ;-) I think AUCTeX/RefTeX are here, if we can improve them, we should do it. And if someone wants to replace it with something better, we can do it as well. It is always a matter of "I need that", and best case is one implements that as well. Best, Arash
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Thu, 11 Apr 2024 19:36:01 GMT) Full text and rfc822 format available.Message #17 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: gusbrs <gusbrs.2016 <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Thu, 11 Apr 2024 16:35:27 -0300
Hi Arash, On Thu, 11 Apr 2024 at 12:46, Arash Esbati <arash <at> gnu.org> wrote: > I thought you were a nice guy, but that's about to change ;-) > Persoally, I don't like detached args, but that's only me, and it's a > matter of taste, so it doesn't really count. Well, I don't use it everywhere, and not even in most places, but I do use it whenever I feel it is convenient. And biblatex citation lists are one case where it is practically a necessity. These macros easily become very long with no relevant break point, except perhaps an occasional space in a pre-/postnote, so they quickly become impossible tasks for paragraph filling functions. Adding some possible breaks between the arguments makes for much better results. > Can you please try this on your files: > > [...] My real life documents are not really a good testing ground for this. For starters, I don't have a list to benchmark the results. I could produce one with another tool, but on a real document each bibkey is called multiple times, and we would never really know when or where the parsing failed. But I tested this new version on the MWE for the original report, and it further handles detached arguments. Which is nice. Thank you. You only did so for the citation lists though. The macros matched in `re' do not allow detached arguments. It feels to me like it should. All in all, with perhaps the adjustment of the previous comment, this looks good to me. It is close to as good as is possible within this approach and certainly counts as good enough in my view. > I think in this particular case, we should ignore the value of > `reftex-allow-detached-macro-args'. Agreed. Btw, in plenty of places this just works implicitly. I'd only check/restrict behavior to `reftex-allow-detached-macro-args' if there is a cost or risk involved. > > From AUCTeX/RefTeX's sides pretty much everything works, except that > > you cannot detach the very first argument after the macro. (If I > > recall correctly, this exception is due to an implementation detail in > > font-latex.el, but I don't recall if I had filled this as a > > mal-function or not, I'm just used to it by now. I also don't recall > > if this exception affects only citation lists or is general, probably > > general). > > Can you show a concrete example? Mhm, my memory may have betrayed me there, perhaps not. This belongs to those long term muscle memory things, it is only natural that I lost track of the origin. I should have something noted somewhere, but I couldn't find it. But I won't leave you empty handed either: `reftex-what-macro' fails to handle a macro where the first argument is detached, regardless of the value of `reftex-allow-detached-macro-args'. Try `(reftex-what-macro 1)' on ("|" is point): \cite [45] {sig|fridsson} Result `nil'. On the other hand, on: \cite[45] {sig|fridsson} We now get `("\\cite" . 3654)' (Tested in my own setup, so assuming `reftex-allow-detached-macro-args' is `t', and possibly other noise, but the important point is that the first case fails regardless). This happens because in `reftex-what-macro', after moving backwards all the arguments of the macro, point is exactly at the first character of the first argument, and the function then grabs the macro name with: (when (and (memq (following-char) '(?\[ ?\( ?\{)) (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t)) (setq cmd (reftex-match-string 0)) There's no accounting for a possible space at this point. Good news, it is easy to fix, either by allowing for whitespace in the regexp or perhaps by some backwards version of `(while (and (not (eobp)) (font-latex-forward-comment)))'. I know, you telling me you want to keep your sanity and me suggesting you touch this regexp... Sorry, my bad. But, in fairness, I hadn't even made this a thing. You brought this upon yourself by asking me for an example. ;-) At this point, I'm not sure about similar restrictions stemming from font-latex.el, as I had initially mentioned. I fought a lot with this area of functionality, had many incarnations of setups, and am probably quite detached from the "vanilla" experience here. I'm also not sure if this issue arises somewhere else or not. But I think this thing in `reftex-what-macro' would, alone, be sufficient to generate the muscle memory that I have in this regard. > > And, as you have noted yourself, a comment between two arguments would > > also beat it. I'm sure you know much better than me how hard it is to > > parse TeX arguments solely based on regexps (as opposed to sexp > > navigation). > > Not always: Try "\foo[opti{]}onal]{}" in a .tex file, put point on [ and > hit 'C-M-f'. :-) > > True, `reftex-create-bibtex-file' already exists, so it does pose the > > question as to whether "let it wane", "marginally improve" or "replace > > it with something better" is the best option. Not a question for me to > > answer tough. ;-) > > I think AUCTeX/RefTeX are here, if we can improve them, we should do it. > And if someone wants to replace it with something better, we can do it > as well. It is always a matter of "I need that", and best case is one > implements that as well. Well, the current version you have is pretty good, and a welcome improvement. Thank you. Best, gusbrs
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 12:00:05 GMT) Full text and rfc822 format available.Message #20 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: gusbrs <gusbrs.2016 <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 08:59:00 -0300
Hi Arash, On Thu, 11 Apr 2024 at 12:46, Arash Esbati <arash <at> gnu.org> wrote: > I think AUCTeX/RefTeX are here, if we can improve them, we should do it. > And if someone wants to replace it with something better, we can do it > as well. It is always a matter of "I need that", and best case is one > implements that as well. Just "someone" playing a little with this: (defun reftex-all-used-citation-keys-alt () (let* (keys) (if (reftex-using-biblatex-p) (let* ((master (reftex-TeX-master-file)) (bbl-file (file-name-with-extension master ".bbl"))) (when (file-exists-p bbl-file) (with-temp-buffer (insert-file-contents bbl-file) (goto-char (point-min)) (while (re-search-forward "\\\\entry{\\([^}]*\\)}" nil t) (push (match-string-no-properties 1) keys))))) (reftex-access-scan-info) (let* ((files (reftex-all-document-files)) (aux-files (mapcar (lambda (x) (file-name-with-extension x ".aux")) files)) file) (while (setq file (pop aux-files)) (when (file-exists-p file) (with-temp-buffer (insert-file-contents file) (goto-char (point-min)) (while (re-search-forward "^\\\\citation{\\([^}]*\\)}" nil t) (let ((key (match-string-no-properties 1))) (unless (member key keys) (push key keys))))))))) (nreverse keys))) Quickly cooked, certainly needs polishing. But not a bad proof of concept, I think. Of course, this approach requires that the document has been compiled and the generated files are up to date with the main document. (This is still tricked by biblatex's xdata, but I see no way around it at this level). Best, gusbrs
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 16:10:02 GMT) Full text and rfc822 format available.Message #23 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: gusbrs <gusbrs.2016 <at> gmail.com> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 18:09:16 +0200
Hi Gustavo, gusbrs <gusbrs.2016 <at> gmail.com> writes: > On Thu, 11 Apr 2024 at 12:46, Arash Esbati <arash <at> gnu.org> wrote: > > Just "someone" playing a little with this: > > (defun reftex-all-used-citation-keys-alt () > (let* (keys) > (if (reftex-using-biblatex-p) > (let* ((master (reftex-TeX-master-file)) > (bbl-file (file-name-with-extension master ".bbl"))) > (when (file-exists-p bbl-file) > (with-temp-buffer > (insert-file-contents bbl-file) > (goto-char (point-min)) > (while (re-search-forward "\\\\entry{\\([^}]*\\)}" nil t) > (push (match-string-no-properties 1) keys))))) > (reftex-access-scan-info) > (let* ((files (reftex-all-document-files)) > (aux-files (mapcar (lambda (x) (file-name-with-extension x ".aux")) > files)) > file) > (while (setq file (pop aux-files)) > (when (file-exists-p file) > (with-temp-buffer > (insert-file-contents file) > (goto-char (point-min)) > (while (re-search-forward "^\\\\citation{\\([^}]*\\)}" nil t) > (let ((key (match-string-no-properties 1))) > (unless (member key keys) > (push key keys))))))))) > (nreverse keys))) > > Quickly cooked, certainly needs polishing. But not a bad proof of > concept, I think. Of course, this approach requires that the document > has been compiled and the generated files are up to date with the main > document. Thanks, nice. But I think the necessity you mention is also the weak point of this approach: You can't just load a .tex file, run the caller `reftex-create-bibtex-file' and close the file; you have to compile the file. So I don't think we should replace the current implementation with the above. > (unless (member key keys) > (push key keys)) Can be written as: (cl-pushnew key keys :test #'string=) Best, Arash
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 18:10:12 GMT) Full text and rfc822 format available.Message #26 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: gusbrs <gusbrs.2016 <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 15:09:11 -0300
Hi Arash, On Sat, 13 Apr 2024 at 13:09, Arash Esbati <arash <at> gnu.org> wrote: > Thanks, nice. But I think the necessity you mention is also the weak > point of this approach: You can't just load a .tex file, run the caller > `reftex-create-bibtex-file' and close the file; you have to compile the > file. So I don't think we should replace the current implementation > with the above. A drawback indeed it is. In my view, the reliability and simplicity outweigh that. But, a judgment call, of course. :-) One could, in theory, have both and just accumulate any non repeating keys which appear in either method. But it feels just wrong to do so... Best, gusbrs
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 21:05:02 GMT) Full text and rfc822 format available.Message #29 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: gusbrs <gusbrs.2016 <at> gmail.com> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 23:03:44 +0200
Hi Gustavo, gusbrs <gusbrs.2016 <at> gmail.com> writes: > All in all, with perhaps the adjustment of the previous comment, this > looks good to me. It is close to as good as is possible within this > approach and certainly counts as good enough in my view. Thanks for testing and your feedback. > But I won't leave you empty handed either: `reftex-what-macro' fails > to handle a macro where the first argument is detached, regardless of > the value of `reftex-allow-detached-macro-args'. > > Try `(reftex-what-macro 1)' on ("|" is point): > > \cite [45] {sig|fridsson} > > Result `nil'. On the other hand, on: > > \cite[45] {sig|fridsson} > > We now get `("\\cite" . 3654)' I think the editor has to make some assumption; this is one of them. > Well, the current version you have is pretty good, and a welcome > improvement. Thank you. I installed the change on Emacs master (845246093f). This was half of the bug report, right? Best, Arash
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 21:22:13 GMT) Full text and rfc822 format available.Message #32 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: gusbrs <gusbrs.2016 <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 18:20:48 -0300
Hi Arash, On Sat, 13 Apr 2024 at 18:03, Arash Esbati <arash <at> gnu.org> wrote: > I think the editor has to make some assumption; this is one of them. I personally classify that as misbehavior. But I can certainly understand you prefer not to change things at a critical place (and why). (Besides, sinners know they are sinners ;-). > I installed the change on Emacs master (845246093f). This was half of > the bug report, right? Thank you! Regarding the remaining part, again, my advice to you is not to invest too much time in this. So, feel free to "won't fix" and close. Best, gusbrs
bug-auctex <at> gnu.org
:bug#38249
; Package auctex
.
(Sat, 13 Apr 2024 21:40:04 GMT) Full text and rfc822 format available.Message #35 received at 38249 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: gusbrs <gusbrs.2016 <at> gmail.com> Cc: 38249 <at> debbugs.gnu.org Subject: Re: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex Date: Sat, 13 Apr 2024 23:39:10 +0200
gusbrs <gusbrs.2016 <at> gmail.com> writes: > (Besides, sinners know they are sinners ;-). ;-) > Thank you! Regarding the remaining part, again, my advice to you is > not to invest too much time in this. So, feel free to "won't fix" and > close. I will do so. We can re-open once there is a real for this, we can then see if that part can also be solved somehow. Again, sorry for being late. Best, Arash
Arash Esbati <arash <at> gnu.org>
to control <at> debbugs.gnu.org
.
(Sat, 13 Apr 2024 21:41:04 GMT) Full text and rfc822 format available.Arash Esbati <arash <at> gnu.org>
to control <at> debbugs.gnu.org
.
(Sat, 13 Apr 2024 21:41:04 GMT) Full text and rfc822 format available.Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Sun, 12 May 2024 11:24:07 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.