auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Reftex (auctex?) and clone-indirect-buffer


From: Tassilo Horn
Subject: Re: [AUCTeX] Reftex (auctex?) and clone-indirect-buffer
Date: Tue, 09 Dec 2014 11:58:53 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Igor Sosa Mayor <address@hidden> writes:

Hi Igor,

> I use very often the function clone-indirect-buffer for editing a file
> in different points and above to have different narrows (this works
> with org files/buffer perfectly).
>
> With auctex (reftex?) I have the problem that I can not add
> bibliographical refs in a cloned buffer, because I get the error
> "Reftex can only work in buffers with a file" (or something like
> that). (The buffer is obviously related to a file...)
>
> Is there maybe something to do?

The problem is that in an indirect buffer, `buffer-file-name' is nil and
the function of the same name also returns nil but reftex requires that
it returns a file name.  (I have no idea why indirect buffers don't have
the file association of their base buffer...)

It's possible to check if we're in an indirect buffer and if so use the
base buffer's buffer-file-name, so reftex could be made functional in
indirect buffers.  But I'm currently not sure about possible
consequences.

For the time being, you can use this piece of advice which makes
`buffer-file-name' return the base buffer's buffer-file-name in buffers
where reftex is active.

--8<---------------cut here---------------start------------->8---
(defun my/buffer-file-name-for-reftex (old-fn &optional buffer)
  (let ((bfn (funcall old-fn buffer)))
    (if reftex-mode
        (or bfn
            (let ((base (buffer-base-buffer buffer)))
              (when base
                (funcall old-fn base))))
      bfn)))

(advice-add #'buffer-file-name :around #'my/buffer-file-name-for-reftex)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]