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

Reply via email to