GNU bug report logs - #20340
11.88; Evince reverse search opens buffer in all frames

Previous Next

Package: auctex;

Reported by: Iñaki García Etxebarria <garetxe <at> gmail.com>

Date: Wed, 15 Apr 2015 21:30:03 UTC

Severity: normal

Found in version 11.88

Done: Tassilo Horn <tsdh <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20340 in the body.
You can then email your comments to 20340 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Wed, 15 Apr 2015 21:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Iñaki García Etxebarria <garetxe <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Wed, 15 Apr 2015 21:30:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Iñaki García Etxebarria <garetxe <at> gmail.com>
To: bug-auctex <at> gnu.org
Subject: 11.88; Evince reverse search opens buffer in all frames
Date: Wed, 15 Apr 2015 23:20:20 +0200
Hello,

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.

Observed behavior: All emacs windows editing TeX files jump to the
source position for the file associated to the pdf in evince.

Expected behavior: Only the window in which you are editing the relevant file
reacts.

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).

(defun TeX-source-correlate-sync-source (file linecol &rest ignored)
  "Show TeX FILE with point at LINECOL.
This function is called when emacs receives a SyncSource signal
emitted from the Evince document viewer.  IGNORED absorbs an
unused id field accompanying the DBUS signal sent by Evince-3.0.0
or newer."
  ;; FILE may be given as relative path to the TeX-master root document or as
  ;; absolute file:// URL.  In the former case, the tex file has to be already
  ;; opened.
  (let ((buf (let ((f (condition-case nil
			  (progn
			    (require 'url-parse)
			    (require 'url-util)
			    (url-unhex-string (aref (url-generic-parse-url file) 6)))
			;; For Emacs 21 compatibility, which doesn't have the
			;; url package.
			(file-error (replace-regexp-in-string "^file://" "" file)))))
	       (if (string= f (buffer-file-name))
		   (current-buffer)
		 nil)))
	(line (car linecol))
	(col (cadr linecol)))
    (when (not (null buf))
      (switch-to-buffer buf)
      (push-mark (point) 'nomsg)
      (goto-char (point-min))
      (forward-line (1- line))
      (unless (= col -1)
	(move-to-column col))
      (raise-frame))))

------------------------------------------------------------------------

Emacs  : GNU Emacs 24.4.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.14.5)
 of 2014-11-19 on buildvm-03.phx2.fedoraproject.org
Package: 11.88

current state:
==============
(setq
 AUCTeX-date "2014-10-29"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("/var/auctex" "/usr/share/emacs/site-lisp/auctex/style"
                  "/home/inaki/.emacs.d/auctex/auto"
                  "/home/inaki/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save nil
 TeX-parse-self nil
 TeX-master t
 TeX-command-list '(("TeX"
                     "%(PDF)%(tex) %(extraopts) %`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil
                     (plain-tex-mode ams-tex-mode texinfo-mode) :help
                     "Run plain TeX")
                    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
                     (latex-mode doctex-mode) :help "Run LaTeX")
                    ("Makeinfo" "makeinfo %(extraopts) %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with Info output")
                    ("Makeinfo HTML" "makeinfo %(extraopts) --html %t"
                     TeX-run-compile nil (texinfo-mode) :help
                     "Run Makeinfo with HTML output")
                    ("AmSTeX"
                     "%(PDF)amstex %(extraopts) %`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
                    ("ConTeXt"
                     "texexec --once --texutil %(extraopts) %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
                    ("ConTeXt Full" "texexec %(extraopts) %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help
                     "Run ConTeXt until completion")
                    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
                     "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
                    ("View" "%V" TeX-run-discard-or-function t t :help
                     "Run Viewer")
                    ("Print" "%p" TeX-run-command t t :help "Print the file")
                    ("Queue" "%q" TeX-run-background nil t :help
                     "View the printer queue" :visible TeX-queue-command)
                    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help
                     "Generate PostScript file")
                    ("Index" "makeindex %s" TeX-run-command nil t :help
                     "Create index file")
                    ("Xindy" "texindy %s" TeX-run-command nil t :help
                     "Run xindy to create index file")
                    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
                     :help "Check LaTeX file for correctness")
                    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode)
                     :help "Check LaTeX file for common mistakes")
                    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil
                     t :help "Spell-check the document")
                    ("Clean" "TeX-clean" TeX-run-function nil t :help
                     "Delete generated intermediate files")
                    ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
                     "Delete generated intermediate and output files")
                    ("Other" "" TeX-run-command t t :help
                     "Run an arbitrary command")
                    )
 )

Thanks,
Iñaki





Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Thu, 16 Apr 2015 09:05:03 GMT) Full text and rfc822 format available.

Message #8 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Iñaki García Etxebarria <garetxe <at> gmail.com>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Thu, 16 Apr 2015 11:03:59 +0200
Iñaki García Etxebarria <garetxe <at> gmail.com> writes:

Hi Iñaki,

> 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 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.

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

Bye,
Tassilo




Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Thu, 16 Apr 2015 14:52:01 GMT) Full text and rfc822 format available.

Message #11 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Inaki Garcia Etxebarria <garetxe <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
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






Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Thu, 16 Apr 2015 19:59:01 GMT) Full text and rfc822 format available.

Message #14 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Inaki Garcia Etxebarria <garetxe <at> gmail.com>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Thu, 16 Apr 2015 21:58:08 +0200
Inaki Garcia Etxebarria <garetxe <at> gmail.com> writes:

Hi Inaki,

> 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).

BTW, what confused me a bit is your wording.  Emacs calls the WM
windows, i.e., the things with the menu/tool-bar and window decorations
"frames".  Windows in emacs are the panes that display a buffer which
you can split with C-x 2 and C-x 3.

So your problem is that after clicking in Evince, all (single) windows
of your two emacs frames show the buffer of the tex file from which the
pdf was generated.

> 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.

Ah, what a luck that you included the terminal window in the screenshot!
Now I know what the problem is.

You fire up two emacs instances, i.e., two completely separate emacs
processes.  When Evince sends the SyncSource signal via DBUS, both emacs
processe will receive it and act accordingly, i.e., pop to the
corresponding tex buffer.

There is no (simple) way that these two separate emacs processes could
talk to each other in order to negotiate which one should open the file.

Since a few years, one single emacs process can have arbitrarily frames
no matter if graphical or tty frames.  You start emacs once, and when
you want to, you can open another frame using `C-x 5 2'.  Then use one
frame for document1, the other for document2, yet another one for
document3.

And then, because there is only one single emacs process, inverse search
with Evince will magically work. :-)

This one emacs, many frames thingy is documented in

  (info "(emacs)Emacs Server")

Bye,
Tassilo (Embeddings for the non-toric Pezzo singularities, what?!?) :-)




Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Fri, 17 Apr 2015 10:11:01 GMT) Full text and rfc822 format available.

Message #17 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Iñaki García Etxebarria <garetxe <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Fri, 17 Apr 2015 12:10:13 +0200
Hi Tassilo,

On Thu, 2015-04-16 at 21:58 +0200, Tassilo Horn wrote:
> BTW, what confused me a bit is your wording.  Emacs calls the WM
> windows, i.e., the things with the menu/tool-bar and window decorations
> "frames".  Windows in emacs are the panes that display a buffer which
> you can split with C-x 2 and C-x 3.
> 
> So your problem is that after clicking in Evince, all (single) windows
> of your two emacs frames show the buffer of the tex file from which the
> pdf was generated.
Right, exactly. Sorry for the wrong wording! I will try to be more
accurate below, let's see how it goes :)

> Ah, what a luck that you included the terminal window in the screenshot!
> Now I know what the problem is.
> 
> You fire up two emacs instances, i.e., two completely separate emacs
> processes.  When Evince sends the SyncSource signal via DBUS, both emacs
> processe will receive it and act accordingly, i.e., pop to the
> corresponding tex buffer.
> 
> There is no (simple) way that these two separate emacs processes could
> talk to each other in order to negotiate which one should open the file.
> 
> Since a few years, one single emacs process can have arbitrarily frames
> no matter if graphical or tty frames.  You start emacs once, and when
> you want to, you can open another frame using `C-x 5 2'.  Then use one
> frame for document1, the other for document2, yet another one for
> document3.
> 
> And then, because there is only one single emacs process, inverse search
> with Evince will magically work. :-)
Thanks for the hint! This works better, but still in a somewhat
surprising fashion at times. Again with a clean installation of AUCTeX
11.88.4 (setting "TeX-source-correlate-mode" to t in my .emacs), I
observe the following:
I run "emacs draft5.tex". Then, inside that emacs frame: "C-x 5 2". That
creates a new frame still showing draft5.tex. In that new frame, I open
"BC-tiling.tex" using the "Open File" toolbar button. I open draft5.pdf
in evince from a terminal. So far so good, this is what I see:
https://www.mpp.mpg.de/~inaki/auctex3.png

Now select (i.e. give focus in the WM) the frame showing draft5.tex. If
I Ctrl+Click in evince this frame changes to the right place, good:
https://www.mpp.mpg.de/~inaki/auctex4.png

If instead I have the frame showing BC-tiling.tex with focus, and
Ctrl+Click in evince, it is the frame showing BC-tiling.tex that reacts,
and I get the following:
https://www.mpp.mpg.de/~inaki/auctex5.png
The frame showing draft5.tex does not react at all in this case (I
scrolled a bit the position in that buffer before ctrl+clicking in
evince to make that manifest).

It seems like in this case emacs should have enough info to say
something like "if I am showing draft5.tex in some frame, just bring
that (WM) window forward, and don't touch any other frames", which is
ideal, I think. Would something like this be possible?

> Tassilo (Embeddings for the non-toric Pezzo singularities, what?!?) :-)
Sorry, using whatever I have at hand for examples :)

Thanks,
Iñaki





Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Fri, 17 Apr 2015 14:14:02 GMT) Full text and rfc822 format available.

Message #20 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Iñaki García Etxebarria <garetxe <at> gmail.com>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Fri, 17 Apr 2015 16:13:20 +0200
Iñaki García Etxebarria <garetxe <at> gmail.com> writes:

Hi Iñaki,

> It seems like in this case emacs should have enough info to say
> something like "if I am showing draft5.tex in some frame, just bring
> that (WM) window forward, and don't touch any other frames", which is
> ideal, I think. Would something like this be possible?

Yes, it is.

,----[ C-h v display-buffer-reuse-frames RET ]
| display-buffer-reuse-frames is a variable defined in `window.el'.
| Its value is nil
| 
|   This variable is obsolete since 24.3;
|   use a `reusable-frames' alist entry in `display-buffer-alist'.
| 
| Documentation:
| Non-nil means `display-buffer' should reuse frames.
| If the buffer in question is already displayed in a frame, raise
| that frame.
| 
| You can customize this variable.
| 
| This variable was introduced, or its default value was changed, in
| version 21.1 of Emacs.
`----

,----[ C-h v display-buffer-alist RET ]
| display-buffer-alist is a variable defined in `window.el'.
| Its value is nil
| 
|   This variable may be risky if used as a file-local variable.
| 
| Documentation:
| Alist of conditional actions for `display-buffer'.
| This is a list of elements (CONDITION . ACTION), where:
| 
|  CONDITION is either a regexp matching buffer names, or a
|   function that takes two arguments - a buffer name and the
|   ACTION argument of `display-buffer' - and returns a boolean.
| 
|  ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a
|   function or a list of functions.  Each such function should
|   accept two arguments: a buffer to display and an alist of the
|   same form as ALIST.  See `display-buffer' for details.
| 
| `display-buffer' scans this alist until it either finds a
| matching regular expression or the function specified by a
| condition returns non-nil.  In any of these cases, it adds the
| associated action to the list of actions it will try.
| 
| You can customize this variable.
| 
| This variable was introduced, or its default value was changed, in
| version 24.1 of Emacs.
`----

Wow, quite complex.  But I think this is the value you want:

  (setq display-buffer-alist
        '((".*" . (display-buffer-reuse-window . ((reusable-frames . visible))))))

Tested only briefly, though.

Bye,
Tassilo




Information forwarded to bug-auctex <at> gnu.org:
bug#20340; Package auctex. (Fri, 17 Apr 2015 14:37:01 GMT) Full text and rfc822 format available.

Message #23 received at 20340 <at> debbugs.gnu.org (full text, mbox):

From: Iñaki García Etxebarria <garetxe <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 20340 <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Fri, 17 Apr 2015 16:36:11 +0200
Hi Tassilo,

On Fri, 2015-04-17 at 16:13 +0200, Tassilo Horn wrote:
> Wow, quite complex.  But I think this is the value you want:
> 
>   (setq display-buffer-alist
>         '((".*" . (display-buffer-reuse-window . ((reusable-frames . visible))))))
> 
> Tested only briefly, though.
This seems to work perfectly, thank you very much!

Best,
Iñaki





Reply sent to Tassilo Horn <tsdh <at> gnu.org>:
You have taken responsibility. (Fri, 17 Apr 2015 18:55:02 GMT) Full text and rfc822 format available.

Notification sent to Iñaki García Etxebarria <garetxe <at> gmail.com>:
bug acknowledged by developer. (Fri, 17 Apr 2015 18:55:03 GMT) Full text and rfc822 format available.

Message #28 received at 20340-done <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Iñaki García Etxebarria <garetxe <at> gmail.com>
Cc: 20340-done <at> debbugs.gnu.org
Subject: Re: bug#20340: 11.88; Evince reverse search opens buffer in all frames
Date: Fri, 17 Apr 2015 20:54:45 +0200
Iñaki García Etxebarria <garetxe <at> gmail.com> writes:

Hi Iñaki,

>> Wow, quite complex.  But I think this is the value you want:
>> 
>>   (setq display-buffer-alist
>>         '((".*" . (display-buffer-reuse-window . ((reusable-frames . visible))))))
>> 
>> Tested only briefly, though.
> This seems to work perfectly, thank you very much!

Great to hear, and you're welcome!

Bye,
Tassilo




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 16 May 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.