ReverseFlux

a

Feb 10th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. (require 'dbus)
  2.  
  3. (defun un-urlify (fname-or-url)
  4. "A trivial function that replaces a prefix of file:/// with just /."
  5. (if (string= (substring fname-or-url 0 8) "file:///")
  6. (substring fname-or-url 7)
  7. fname-or-url))
  8.  
  9. (defun th-evince-sync (file linecol &rest ignored)
  10. (let* ((fname (un-urlify file))
  11. (buf (find-buffer-visiting fname))
  12. (line (car linecol))
  13. (col (cadr linecol)))
  14. (if (null buf)
  15. (message "[Synctex]: %s is not opened..." fname)
  16. (switch-to-buffer buf)
  17. (goto-line (car linecol))
  18. (unless (= col -1)
  19. (move-to-column col)))))
  20.  
  21. (defvar *dbus-evince-signal* nil)
  22.  
  23. (defun enable-evince-sync ()
  24. (require 'dbus)
  25. (when (and
  26. (eq window-system 'x)
  27. (fboundp 'dbus-register-signal))
  28. (unless *dbus-evince-signal*
  29. (setf *dbus-evince-signal*
  30. (dbus-register-signal
  31. :session nil "/org/gnome/evince/Window/0"
  32. "org.gnome.evince.Window" "SyncSource"
  33. 'th-evince-sync)))))
  34.  
  35. (add-hook 'LaTeX-mode-hook 'enable-evince-sync)
Advertisement
Add Comment
Please, Sign In to add comment