auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] forward / backward with evince


From: Tassilo Horn
Subject: Re: [AUCTeX] forward / backward with evince
Date: Wed, 04 Apr 2012 21:24:34 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.95 (gnu/linux)

Mandar Mitra <address@hidden> writes:

Hi Mandar,

> But the default forward search provided by auctex only specifies a
> page number. Can the solution given above be incorporated into
> auctex's forward search mechanism?

I've implemented the forward search for evince using its DBUS interface
now.  It works fine for me, but before I commit, could you please check
if it also does the trick for you?

The attached patch is against the current CVS version of AUCTeX.

Bye,
Tassilo

Index: tex.el
===================================================================
RCS file: /sources/auctex/auctex/tex.el,v
retrieving revision 5.688
diff -u -r5.688 tex.el
--- tex.el      24 Aug 2011 16:24:17 -0000      5.688
+++ tex.el      4 Apr 2012 19:21:20 -0000
@@ -1003,6 +1003,35 @@
   :group 'TeX-view
   :type '(alist :key-type symbol :value-type (group sexp)))
 
+(defun TeX-evince-dbus-p ()
+  "Return non-nil, if evince is installed and accessible via its
+DBUS interface."
+  (and (fboundp 'dbus-register-signal)
+       (fboundp 'dbus-call-method)
+       (getenv "DBUS_SESSION_BUS_ADDRESS")
+       (executable-find "evince")))
+
+(defun TeX-evince-sync-view ()
+  (let* ((uri (concat "file://" (expand-file-name
+                                (concat file "." (TeX-output-extension)))))
+        (owner (dbus-call-method
+                :session "org.gnome.evince.Daemon"
+                "/org/gnome/evince/Daemon"
+                "org.gnome.evince.Daemon"
+                "FindDocument"
+                uri
+                t)))
+    (if owner
+       (dbus-call-method
+        :session owner
+        "/org/gnome/evince/Window/0"
+        "org.gnome.evince.Window"
+        "SyncView"
+        (buffer-file-name)
+        (list :struct :int32 (line-number-at-pos) :int32 1)
+        (round (float-time)))
+      (error "Couldn't find the Evince instance for %s" uri))))
+
 (defvar TeX-view-program-list-builtin
   (cond
    ((eq system-type 'windows-nt)
@@ -1031,13 +1060,15 @@
       ("dvips and gv" "%(o?)dvips %d -o && gv %f")
       ("gv" "gv %o")
       ("xpdf" ("xpdf -remote %s -raise %o" (mode-io-correlate " %(outpage)")))
-      ("Evince" ("evince" (mode-io-correlate
-                          ;; With evince 3, -p N opens the page *labeled* N,
-                          ;; and -i,--page-index the physical page N.
-                          ,(if (string-match "--page-index"
-                                             (shell-command-to-string "evince 
--help"))
-                               " -i %(outpage)"
-                             " -p %(outpage)")) " %o"))
+      ("Evince" ,(if (TeX-evince-dbus-p)
+                    'TeX-evince-sync-view
+                  `("evince" (mode-io-correlate
+                              ;; With evince 3, -p N opens the page *labeled* 
N,
+                              ;; and -i,--page-index the physical page N.
+                              ,(if (string-match "--page-index"
+                                                 (shell-command-to-string 
"evince --help"))
+                                   " -i %(outpage)"
+                                 " -p %(outpage)")) " %o")))
       ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%b")))
       ("xdg-open" "xdg-open %o"))))
   "Alist of built-in viewer specifications.
@@ -1473,10 +1504,7 @@
   (TeX-set-mode-name 'TeX-source-correlate-mode t t)
   (setq TeX-source-correlate-start-server-flag TeX-source-correlate-mode)
   ;; Register Emacs for the SyncSource DBUS signal emitted by Evince.
-  (when (and (fboundp 'dbus-register-signal)
-            (fboundp 'dbus-call-method)
-            (getenv "DBUS_SESSION_BUS_ADDRESS")
-            (executable-find "evince"))
+  (when (TeX-evince-dbus-p)
     (require 'dbus)
     (dbus-register-signal
      :session nil "/org/gnome/evince/Window/0"

reply via email to

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