Tassilo Horn | 29 Jan 15:40 2011
Picon

Inverse Search with Evince & DBUS

Hi all,

I've just gotten inverse search working with Evince (2.32).  That
doesn't have a setting for an editor command (well, it's GNOME, so it
has no settings at all, right?), but instead it fires a SyncSource
signal on the desktop bus.

Well, recent emacsen have dbus support, so it was pretty easy to get
inverse search working.  Here's the code:

--8<---------------cut here---------------start------------->8---
(require 'dbus)

(defun th-evince-sync (file linecol)
  (let ((buf (get-buffer file))
        (line (car linecol))
        (col (cadr linecol)))
    (if (null buf)
        (message "Sorry, %s is not opened..." file)
      (switch-to-buffer buf)
      (goto-line (car linecol))
      (unless (= col -1)
        (move-to-column col)))))

(dbus-register-signal
 :session nil "/org/gnome/evince/Window/0"
 "org.gnome.evince.Window" "SyncSource"
 'th-evince-sync)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo

Gmane