Thanks for trying! I'm just trying to find a flexible solution for future requirements like this... /PA
On Mon, 30 Jun 2025 at 09:54, Vangelis Evangelou <evange...@gmail.com> wrote: > > Hi Perdo. > > No, that doesn't fix it. I can see that add-texparse-filter is added to the > org-export-filter-final-output-functions, but the text doesn't appear in the > exported *Org LATEX Export* buffer. > > On Mon, 30 Jun 2025 at 07:49, Pedro Andres Aranda Gutierrez > <paag...@gmail.com> wrote: >> >> PS: You can also add the code in your Emacs Lisp test code >> >> Sorry for the convoluted suggestion... >> /PA >> >> On Sun, 29 Jun 2025 at 19:16, Pedro Andres Aranda Gutierrez >> <paag...@gmail.com> wrote: >> > >> > Last try: >> > put the following after the header and before the text in your buffer, >> > evaluate the block (C-c C-c) and then export to a buffer C-c C-e l L >> > >> > --- cut here >> > #+BEGIN_SRC emacs-lisp :exports none :results none :eval export >> > (defun add-texparse-filter (output backend info) >> > "Disable TeX-parse-self." >> > (when (eq backend 'latex) >> > (concat output >> > "\n" >> > "%%% Local Variables:\n" >> > "%%% TeX-parse-self: nil\n" >> > "%%% End:\n" ))) >> > >> > (make-variable-buffer-local 'org-export-filter-final-output-functions) >> > (add-to-list 'org-export-filter-final-output-functions >> > 'add-texparse-filter) >> > #+END_SRC >> > --- cut here >> > >> > This is a try to see if we can make the configuration of this >> > workaround customisable. >> > >> > Best, /PA >> > >> > On Sun, 29 Jun 2025 at 14:12, Vangelis Evangelou <evange...@gmail.com> >> > wrote: >> > > >> > > Hi Pedro. >> > > >> > > > This looks more like a side effect of using the auctex package >> > > >> > > I see. That makes sense. However, the function org-latex-export-as-latex >> > > calls LaTeX-mode, which is an alias for ‘latex-mode’ in ‘tex-mode.el’ >> > > that comes with emacs. However, auctex defines its own LaTeX-mode. I >> > > think org-latex-export-as-latex *intentionally* calls LaTeX-mode instead >> > > of latex-mode to make use of auctex if that's available. >> > > >> > > > Just BTW, do you see the problem pop up when you C-c C-e l o? >> > > >> > > No, it doesn't happen in this case. >> > > >> > > > What about saving the exported LaTeX to a file and then opening the >> > > > file in a separate buffer? >> > > >> > > I'm not sure what you mean. Do you mean C-c C-e l l? In that case, the >> > > problem doesn't happen after you open the file because the buffer is >> > > associated with a file. >> > > >> > > > Wasn't it TeX-master that did this... >> > > >> > > Yes, TeX-master also specifies the master file. TeX-master is part of >> > > auctex. reftex-TeX-master-file is part of reftex that does the same job. >> > > reftex-TeX-master-file uses auctex, if installed, otherwise, it does its >> > > own thing. >> > > >> > > > Anyhow, after reading the auctex documentation, could you please add >> > > > the following at the beginning of your test document? >> > > >> > > There must be something wrong with your code because after I do export >> > > and check org-export-filter-final-output-functions, I see nil. I also >> > > get an error with that when I open the org file: "Local variables list >> > > is not properly terminated" >> > > >> > > At the moment my workaround is >> > > (use-package org >> > > :config >> > > (advice-add 'org-latex-export-as-latex :around >> > > (lambda (fun &rest args) >> > > (cl-letf (((symbol-function 'reftex-TeX-master-file) >> > > (and (fboundp 'TeX-master-file) >> > > (not (buffer-file-name)) >> > > #'(lambda (&rest _) "<none>")))) >> > > (apply fun args))))) >> > > >> > > I think this is harmless as it temporarily overwrites >> > > reftex-TeX-master-file if auctex is used and there is no file associated >> > > with the buffer. In that case the return value is "<none>", which is >> > > what TeX-master-file would return as well. >> > > >> > > As I said in my previous email, if TeX-parse-self is t, then emacs scans >> > > for usepackage commands. Because the exported org file uses the amstex >> > > package, there are some commands provided by that package that need >> > > reftex, and so it runs reftex-TeX-master-file. However, reftex requires >> > > a file, and so it results in an error. Temporarily changing the >> > > behaviour of reftex-TeX-master-file should be OK. >> > > >> > > On Sun, 29 Jun 2025 at 07:06, Pedro Andres Aranda Gutierrez >> > > <paag...@gmail.com> wrote: >> > >> >> > >> Hi >> > >> Thx a lot for the explanation... answers inline >> > >> >> > >> On Sat, 28 Jun 2025 at 18:04, Vangelis Evangelou <evange...@gmail.com> >> > >> wrote: >> > >> > >> > >> > Hi Pedro. >> > >> > >> > >> > > I don't think this is a bug. It's more of a side effect ... >> > >> > >> > >> > I'm not sure what you are referring to. I assume that since the >> > >> > program does not produce the intended output, then it's a bug. >> > >> Well, IMHO, a bug is when your code doesn't produce the intended >> > >> result standalone. This looks more like a side effect of using the >> > >> auctex package, so people not using it will not be affected by it. >> > >> >> > >> Just BTW, do you see the problem pop up when you C-c C-e l o? What >> > >> about saving the exported LaTeX to a file and then opening the file in >> > >> a separate buffer? >> > >> >> > >> > > I'd like to understand what this reftex-TeX-master-file variable >> > >> > > means and what the effect of TeX-parse-self is. >> > >> > >> > >> > TeX-parse-self instructs emacs to scan the tex file for the document >> > >> > class, loaded packages and user-defined commands and make the >> > >> > relevant commands available to the user. For example, the graphicx >> > >> > package provides the command \includegraphics. Consider a file called >> > >> > file.tex containing the following >> > >> > ===================== >> > >> > \documentclass{article} >> > >> > \usepackage{graphicx} >> > >> > \begin{document} >> > >> > >> > >> > \end{document} >> > >> > ==================== >> > >> > With TeX-parse-self set to t (see the code in my original email), >> > >> > emacs will provide the commands from the article class and the >> > >> > graphicx package. For example, if you type C-c RET and then type >> > >> > includegraphics it will ask you a few questions about the image you >> > >> > want to include in the document. With TeX-parse-self set to nil, it >> > >> > doesn't know about the includegraphics command. >> > >> > >> > >> > reftex-TeX-master-file tells emacs which is the master file (so it >> > >> > assumes that such a file exists). That is, the main file that >> > >> > includes other files and needs to be compiled to produce a document. >> > >> > So you might have, e.g., file1.tex and file2.tex with file1.tex being >> > >> > the master file that includes file2.tex. So the master of file2 is >> > >> > file1. >> > >> >> > >> I see... Wasn't it TeX-master >> > >> (https://www.gnu.org/software/emacs/manual/html_node/reftex/Multifile-Documents.html) >> > >> that did this... >> > >> >> > >> > > A workaround may be what you propose or to >> > >> > > (setq-local TeX-parse-self nil) >> > >> > > in your org-mode-hook. Could you try this, please? >> > >> > >> > >> > This does not solve the problem because it applies the setting to the >> > >> > org buffer and not the exported latex buffer. >> > >> > >> > >> > I should add that (setq TeX-parse-self t) is one of the recommended >> > >> > settings by auctex https://elpa.gnu.org/packages/doc/auctex.html so I >> > >> > believe others are affected by this issues, though I'm surprised it >> > >> > hasn't been mentioned before. >> > >> >> > >> This is the source of my surprise too... >> > >> >> > >> Anyhow, after reading the auctex documentation, could you please add >> > >> the following at the beginning of your test document? >> > >> >> > >> --- cut here >> > >> #+BEGIN_SRC emacs-lisp :exports none :results none :eval export >> > >> (defun add-texmaster-filter (output backend info) >> > >> "Add `%' to `\\end{minipage}' to allow side by side." >> > >> (when (eq backend 'latex) >> > >> (message "Adding TeX-master...") >> > >> (string-replace "\\end{document}" >> > >> "\\end{document}\n\n%%% Local Variables:\n%%% >> > >> TeX-master: t\n%%% End:\n" output))) >> > >> >> > >> (make-variable-buffer-local 'org-export-filter-final-output-functions) >> > >> (add-to-list 'org-export-filter-final-output-functions >> > >> 'add-texmaster-filter) >> > >> #+END_SRC >> > >> --- cut here >> > >> >> > >> Best, /PA >> > >> > >> > >> > On Sat, 28 Jun 2025 at 06:17, Pedro Andres Aranda Gutierrez >> > >> > <paag...@gmail.com> wrote: >> > >> >> >> > >> >> Hi Vangelis... >> > >> >> >> > >> >> Me and thinking?.. rather difficult... <LoL> >> > >> >> >> > >> >> Now seriously... >> > >> >> I don't think this is a bug. It's more of a side effect and I'd like >> > >> >> to understand what this reftex-TeX-master-file variable means and >> > >> >> what the effect of TeX-parse-self is. >> > >> >> >> > >> >> A workaround may be what you propose or to >> > >> >> (setq-local TeX-parse-self nil) >> > >> >> in your org-mode-hook. Could you try this, please? >> > >> >> >> > >> >> IMvvHO, it would be more desirable approach, because you control your >> > >> >> setup for the packages you use. >> > >> >> org would just document this "special case" (maybe in the FAQ), >> > >> >> instead of "bloating" the package itself. >> > >> >> >> > >> >> @Ihor WDYT? >> > >> >> Best, /PA >> > >> >> >> > >> >> On Fri, 27 Jun 2025 at 18:31, Vangelis Evangelou >> > >> >> <evange...@gmail.com> wrote: >> > >> >> > >> > >> >> > Hi Pedro. >> > >> >> > >> > >> >> > The export works as expected *without* loading auctex. It also >> > >> >> > works as expected *with* loading auctex, but with TeX-parse-self >> > >> >> > to nil. Perhaps the best solution is to amend >> > >> >> > org-latex-export-as-latex to set TeX-parse-self to nil before >> > >> >> > calling LaTeX-mode, e.g., with (let ((TeX-parse-self nil)) <rest >> > >> >> > of the org-latex-export-as-latex code here>). To be honest, I'm >> > >> >> > not sure if this is a bug of org or reftex-auc. What do you think? >> > >> >> > >> > >> >> > >> > >> >> > On Fri, 27 Jun 2025 at 16:41, Pedro Andres Aranda Gutierrez >> > >> >> > <paag...@gmail.com> wrote: >> > >> >> >> >> > >> >> >> Vangelis writes: >> > >> >> >> >> > >> >> >> > Hello. >> > >> >> >> > >> > >> >> >> > I started with emacs -q. Then in the scratch buffer, I >> > >> >> >> > evaluated the >> > >> >> >> > following code >> > >> >> >> > >> > >> >> >> > (use-package reftex-auc) >> > >> >> >> > (use-package tex >> > >> >> >> > :load-path "site-lisp/auctex-14.0.9" >> > >> >> >> > :custom >> > >> >> >> > (TeX-parse-self t)) >> > >> >> >> > >> > >> >> >> > Then, I created an org buffer which I exported to latex buffer >> > >> >> >> > (C-c C-e l >> > >> >> >> > L). I get the error message >> > >> >> >> > >> > >> >> >> > reftex-TeX-master-file: Wrong type argument: stringp, nil >> > >> >> >> >> > >> >> >> Hi, >> > >> >> >> >> > >> >> >> could you please try the export part again *without* loading >> > >> >> >> auctex? >> > >> >> >> It looks like the LaTeX exporter is not generating that thing, >> > >> >> >> which I >> > >> >> >> guess is a file local variable. >> > >> >> >> >> > >> >> >> I remember never having time enough to procrastinate to cope with >> > >> >> >> all >> > >> >> >> the quirks of auctex while writing my PhD - some time ago ;-) - >> > >> >> >> and >> > >> >> >> going the "pure" LaTeX way with some yasnippets and a bit of code >> > >> >> >> to >> > >> >> >> emulate the couple of features people loved from auctex as a >> > >> >> >> viable >> > >> >> >> alternative. >> > >> >> >> >> > >> >> >> Maybe that could be a project once the PDF exporter reaches >> > >> >> >> master... >> > >> >> >> >> > >> >> >> Thx, /PA >> > >> >> >> >> > >> >> >> -- >> > >> >> >> Fragen sind nicht da, um beantwortet zu werden, >> > >> >> >> Fragen sind da um gestellt zu werden >> > >> >> >> Georg Kreisler >> > >> >> >> >> > >> >> >> Sagen's Paradeiser, write BE! >> > >> >> >> Year 1 of the New Koprocracy >> > >> >> >> > >> >> >> > >> >> >> > >> >> -- >> > >> >> Fragen sind nicht da, um beantwortet zu werden, >> > >> >> Fragen sind da um gestellt zu werden >> > >> >> Georg Kreisler >> > >> >> >> > >> >> Sagen's Paradeiser, write BE! >> > >> >> Year 1 of the New Koprocracy >> > >> >> > >> >> > >> >> > >> -- >> > >> Fragen sind nicht da, um beantwortet zu werden, >> > >> Fragen sind da um gestellt zu werden >> > >> Georg Kreisler >> > >> >> > >> Sagen's Paradeiser, write BE! >> > >> Year 1 of the New Koprocracy >> > >> > >> > >> > -- >> > Fragen sind nicht da, um beantwortet zu werden, >> > Fragen sind da um gestellt zu werden >> > Georg Kreisler >> > >> > Sagen's Paradeiser, write BE! >> > Year 1 of the New Koprocracy >> >> >> >> -- >> Fragen sind nicht da, um beantwortet zu werden, >> Fragen sind da um gestellt zu werden >> Georg Kreisler >> >> Sagen's Paradeiser, write BE! >> Year 1 of the New Koprocracy -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Sagen's Paradeiser, write BE! Year 1 of the New Koprocracy