Subject: Re: bug#61568: Problems using reftex from Org mode's latex blocks

From: Tassilo Horn <[email-masked]>
Date: Fri, 17 Feb 2023 11:23:29 +0100

[email-masked] writes:

Hi Alain,

> one is put into a special buffer which is latex aware.  If reftex is
> turned on in that buffer, 'Ref' is added to the modeline.  Now, upon
> [C-c (], one gets
>
>    RefTeX works only in buffers visiting a file
>
> This is disappointing, but I could accept it.  However upon [C-c =]
> one gets
>
>    Wrong type argument: stringp, nil
>
> which is much more problematic.

RefTeX uses (buffer-file-name) at 37 locations for various reasons.
Maybe we could get away with having a reftex-buffer-file-name defined as

  (or (buffer-file-name)
      (buffer-name))

For the time being, can't you just `C-x C-w /tmp/tmp.tex RET' to make
the buffer file-visiting?

> Further, a prominent Org contributor thinks it is a reftex bug and
> that "It is generally expected that major modes do work in non-file
> buffers in Emacs." (thread
> https://lists.gnu.org/archive/html/emacs-orgmode/2023-02/msg00388.html)

That's generally good, yes.  The thing is that RefTeX is a multi-file
mode which tries to parse all files belonging to the same document,
e.g., when your document looks like

  main.tex
  chapters/c1.tex
  chapters/c2.tex
  appendix.tex

Of course, you don't need that in your very use-case.

Bye,
Tassilo