Created
September 24, 2012 13:13
-
-
Save mbenke/3775888 to your computer and use it in GitHub Desktop.
Make synctex work with Emacs 23.3.1 and evince 3.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Based on http://tex.stackexchange.com/questions/29813/setup-synctex-with-emacs/49840#49840 | |
;; replacing setf with setq | |
;; Use Evince as default viewer C-c C-v | |
(setq TeX-view-program-list '(("Evince" "evince %o")) | |
TeX-view-program-selection '((output-pdf "Evince"))) | |
;;; Backward search Evince to AUCTeX adapted from http://www.emacswiki.org/emacs/AUCTeX#toc19 | |
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode) | |
(setq TeX-source-correlate-start-server t); Automatically start server without asking | |
(defun un-urlify (fname-or-url) | |
"A trivial function that replaces a prefix of file:/// with just /." | |
(if (string= (substring fname-or-url 0 8) "file:///") | |
(substring fname-or-url 7) | |
fname-or-url)) | |
(defun th-evince-sync (file linecol &rest ignored) | |
(let* ((fname (un-urlify file)) | |
(buf (find-buffer-visiting fname)) | |
(line (car linecol)) | |
(col (cadr linecol))) | |
(if (null buf) | |
(message "[Synctex]: %s is not opened..." fname) | |
(switch-to-buffer buf) | |
(goto-line (car linecol)) | |
(unless (= col -1) | |
(move-to-column col))))) | |
(defvar *dbus-evince-signal* nil) | |
(defun enable-evince-sync () | |
(require 'dbus) | |
(when (and | |
(eq window-system 'x) | |
(fboundp 'dbus-register-signal)) | |
(unless *dbus-evince-signal* | |
(setq *dbus-evince-signal* ;; note: original used setf instead of setq here | |
(dbus-register-signal | |
:session nil "/org/gnome/evince/Window/0" | |
"org.gnome.evince.Window" "SyncSource" | |
'th-evince-sync))))) | |
(add-hook 'LaTeX-mode-hook 'enable-evince-sync) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment