Hi Pedro.

I tried what you said, but for some reason the local variables text doesn't
get printed. Could it be because the error occurs before the export filter?

In any case, I don't think this is a path towards a solution because local
variables are set when the file is visited (opened). Here, the text is
inserted in the buffer, so the local variables won't be set. I tried a
"manual" approach where in the org latex export buffer I did M-: (setq
TeX-master t) and then did M-: (reftex-TeX-master-file), but I still got
the same error.

TeX-master is a variable defined in ‘tex.el’.

Its value is t
Local in buffer *Org LATEX Export*; global value is the same.


On Tue, 1 Jul 2025 at 09:42, Pedro Andres Aranda Gutierrez <
paag...@gmail.com> wrote:

> Hmmm...
>
> This is a very trick case indeed. Apart from discerning if we want to
> blame it or not, what I would also like to take profit is from this
> for the future.
> If we encounter other cases and appending local variables to the
> export buffer solves out headache, we catch several flies with one
> stroke.
>
> What about trying:
>
> #+BEGIN_SRC emacs-lisp :exports none :results none :eval export
> (defun add-lvars-filter (output backend info)
>   "Ser TeX-master-file. in the lvars"
>   (when (eq backend 'latex)
>     (replace-string "\\end{document}"
>      (concat "\\end{document}\n"
>       "\n"
>       "%%% Local Variables:\n"
>       "%%% TeX-master-file: 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-lvars-filter)
> #+END_SRC
>
> Put that in your test document and evaluate it before C-c C-e l L.
>
> Thanks a ton... /PA
>
> On Tue, 1 Jul 2025 at 10:27, Vangelis Evangelou <evange...@gmail.com>
> wrote:
> >
> > Hi Ichor.
> >
> > I did you what you said. There are two scenarios
> > Scenario 1:
> >
> > Load auctex and set TeX-parse-self to t
> > Create a scratch buffer and type in "\documentclass{article}"
> > Load LaTeX-mode with M-x LaTeX-mode
> >
> > Scenario 2:
> >
> > Load auctex and set TeX-parse-self to t
> > Create a scratch buffer and type in "\documentclass{amsart}". Note that
> this is different from Scenario 1. The difference is that amsart uses the
> amstex package. Org export to latex also uses the amstex package.
> > Load LaTeX-mode with M-x LaTeX-mode
> >
> > With Scenario 1 I don't get an error but with Scenario 2 I do.
> reftex-TeX-master-file: Wrong type argument: stringp, nil
> >
> > As I said in a previous email, this may also be a bug with reftex.
> Looking at the code of reftex-TeX-master-file, I can see that
> >
> > (let ((master
> >         (cond
> >          ;; AUCTeX is loaded.  Use its mechanism.
> >          ((fboundp 'TeX-master-file)
> >           (condition-case nil
> >               (TeX-master-file t)
> >             (error (buffer-file-name)))))))
> >
> > and then later it says
> >     (cond
> >      ((null master)
> >       (error "Need a filename for this buffer, please save it first"))
> >
> > However, TeX-master-file returns "<none>" if the file is not saved
> instead of nil, so it seems that reftex-TeX-master-file uses
> TeX-master-file wrongly. However, even if reftex-TeX-master-file did use
> TeX-master-file correctly, org-mode would still have a problem because it
> would hit the (error "Need a filename for this buffer, please save it
> first"). Because of this I believe that both reftex and org have a bug.
> >
> > On Mon, 30 Jun 2025 at 18:40, Ihor Radchenko <yanta...@posteo.net>
> wrote:
> >>
> >> Vangelis E <evange...@gmail.com> writes:
> >>
> >> > Does this mean that you will implement my suggestion in my previous
> email?
> >> >
> >> >> On 30 Jun 2025, at 17:42, Pedro Andres Aranda Gutierrez <
> paag...@gmail.com> wrote:
> >> >>
> >> >> Thanks for trying! I'm just trying to find a flexible solution for
> >> >> future requirements like this...
> >> >> /PA
> >> >> ...
> >>
> >> Before this discussion stray too far away, and before I look into the
> >> report seriously, I have a suspicion that you are simply running into
> >> Auctex bug. Try creating a new buffer, not associated with any file,
> >> add some basic text code inside, and activate auctex there. Will it err?
> >> If yes, that's a bug in auctex.
> >>
> >> --
> >> Ihor Radchenko // yantar92,
> >> Org mode maintainer,
> >> Learn more about Org mode at <https://orgmode.org/>.
> >> Support Org development at <https://liberapay.com/org-mode>,
> >> or support my work at <https://liberapay.com/yantar92>
>
>
>
> --
> 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