Hi Vangelis,

I've come up with a solution, which is to customise the mode the
export buffer is opened with. You could set it to plain latex-mode
instead of LaTeX-mode. This will disable auctex functionality. Would
that be an issue for you? I don't see any specific advantage in having
the auctex functionality enabled on a *read-only* buffer, but that's
also, just maybe, because I have never used it...
If you are interested, I could share a patch for the all-tex-fonts
feature branch.

Speaking of which... I have been trying to reproduce the problem on a
clean emacs (master) with auctex/reftex from elpa and the feature
branch and was not able.
Could you share a bare minimum init.el file I could use to reproduce?

Best, /PA

On Thu, 17 Jul 2025 at 12:04, Pedro Andres Aranda Gutierrez
<paag...@gmail.com> wrote:
>
> Hi,
>
> I’m quite busy with the export as such.
>
>  It’s an interesting challenge and I currently would like to document it 
> along a variation of your workaround and then maybe discuss whether we want 
> LaTeX-mode or plain latex-mode regardless Of AucTeX in the list.
>
> There may be some benefit of using LaTeX mode in the only export buffer, but 
> I don’t see it…
>
> Best PA
>
> Enviado desde mi iPhone
>
> El 17 jul 2025, a las 9:16, Vangelis Evangelou <evange...@gmail.com> escribió:
>
> 
> Hi Perdo.
>
> Did you manage to get a solution to this?
>
> Best,
> Vangelis
>
> On Tue, 1 Jul 2025 at 18:05, Vangelis Evangelou <evange...@gmail.com> wrote:
>>
>> Hi Pedro.
>>
>> You haven't loaded reftex though. What if you add (use-package reftex) in 
>> your configuration?
>>
>> On Tue, 1 Jul 2025 at 16:36, Pedro Andres Aranda Gutierrez 
>> <paag...@gmail.com> wrote:
>>>
>>> Just to close this. I'm not able to completely reproduce the
>>> environment. Attach is a test report.
>>> /PA
>>>
>>> On Tue, 1 Jul 2025 at 16:34, Pedro Andres Aranda Gutierrez
>>> <paag...@gmail.com> wrote:
>>> >
>>> > OK, forget it, I'll try myself to see if I can reproduce...
>>> >
>>> > Thanks for your help and patience, /PA
>>> >
>>> > On Tue, 1 Jul 2025 at 11:09, Vangelis Evangelou <evange...@gmail.com> 
>>> > wrote:
>>> > >
>>> > > 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
>>> >
>>> >
>>> >
>>> > --
>>> > 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