Subject: bug#20340: 11.88; Evince reverse search opens buffer in all frames

From: Inaki Garcia Etxebarria <[email-masked]>
Date: Thu, 16 Apr 2015 16:51:20 +0200

Hi Tassilo,

Thanks for the quick reply:

On Thu, 2015-04-16 at 11:03 +0200, Tassilo Horn wrote:
> > I am often editing various TeX files at the same time, and try to use
> > evince reverse search from evince, with "Ctrl+Click", in order to make
> > a change to a specific file. Currently
> > TeX-source-correlate-sync-source uses "find-file" in order to load the
> > file.  This is very frustrating, since it makes *all* emacs windows
> > switch to that buffer, including those in which you are editing
> > unrelated documents.
> 
> That should definitely not happen.  `find-file' should at most change
> the buffer of one window.  And if the file is already shown in some
> window, then it should just select that.
> 
> But anyway, there have been other problematic cases with the use of
> `find-file' so the current version of AUCTeX (e.g., the git version or
> version 11.88.4 which you can install from ELPA) doesn't use it with
> `TeX-source-correlate-sync-source' anymore.
> 
> I just tested with multiple tex documents, and that the current version
> seems to behave as you would expect.
I removed my .emacs and .emacs.d, upgraded to the latest version in ELPA
(11.88.4), and for me it still opens the file in all windows (although
it is now a bit better, in that the opened file only takes half the
emacs window). I made some screenshots to show better what happens:
In
https://www.mpp.mpg.de/~inaki/auctex1.png
I opened a couple of tex files (draft5.tex and BC-O5.tex), and the pdf
corresponding to one of them (draft5.pdf). Then I Ctrl+Clicked in
evince, getting the results in
https://www.mpp.mpg.de/~inaki/auctex2.png
As you can see, draft5.tex got opened in the window for BC-O5.tex too,
which is not what I intended.

Maybe detailing my usual workflow helps explain why the current behavior
will be undesirable for some users like me: I usually work on a file
(draft5.tex), and at the same time work on a number (3-4 typically) tikz
pictures on the side, which then get independently compiled to pdf (they
are their own standalone .tex documents). These pdf files are included,
via \includegraphics, into the final pdf. I typically also have some
other tex files open in other emacs instances for reference, but they
are not necessarily directly related to the main tex file (they contain
some equations to copy and paste, or things like that). I use workspaces
to manage the emacs windows, not emacs buffers in a single window.

As it is right now, when I click in evince, *every* window opens
draft5.tex, but I clearly only want the emacs window already showing
draft5.tex to react, not the ones containing tikz or reference tex
files.

> > I have replaced TeX-source-correlate-sync-source by the following code
> > in my local instalation, and it is working well.  It only reacts to
> > the DBus signal if the current buffer contains the file in the signal
> > (see the (if (string= ...)) part).
> 
> I don't think that's a good idea.  That would do nothing when you work
> on a multi-file document and the current buffer has another part of the
> document open.
Well, that would be preferable for my usecase, to be honest. Perhaps
some middle ground is possible: if the .tex file to be opened and the
one being shown have the same master document, then switch to that file,
but otherwise do nothing (perhaps with a message in case switching was
really intended and for some reason it did not work). I don't know
enough of the internals of auctex to know how hard this is to implement.
It may be easier, and still somewhat sensible, to switch to the file
evince tells us to open only if it is already open in some emacs buffer,
even if it is not the one being shown currently.

Well, just a couple of suggestions anyway. I was surprised by the new
behavior when I upgraded AUCTeX (I had some custom code for doing the
reverse lookup before), and it broke my workflow, so I wanted to report.

Thanks in any case for AUCTeX (which is wonderful in general :) ),
Iñaki

> 
> Anyway, please upgrade your AUCTeX version and report back if that works
> for you.
> 
> Bye,
> Tassilo