changeset 592:86ceef677ca2 draft

Support synctex for evince (thanks to TeX Wiki)
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 24 Sep 2022 12:25:21 +0900
parents e3b7e199a87d
children 0a96c5fef8f1
files yatexprc.el
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/yatexprc.el	Fri Sep 23 18:42:59 2022 +0900
+++ b/yatexprc.el	Sat Sep 24 12:25:21 2022 +0900
@@ -1,7 +1,7 @@
 ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*-
 ;;; 
-;;; (c)1993-2019 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Dec 26 12:48:12 2019 on firestorm
+;;; (c)1993-2022 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sat Sep 24 12:17:14 2022 on firestorm
 ;;; $Id$
 
 ;;; Code:
@@ -1149,6 +1149,34 @@
 	  t)				;for YaTeX-goto-corresponding-*
       nil)))
 
+(and (or (featurep 'dbus) (load "dbus" t))
+     ;; Cannot load dbus on emacs without dbus module
+     (fboundp 'url-unhex-string)
+     (fboundp 'dbus-register-signal)
+     ;; From https://texwiki.texjp.org/?Emacs#vecb4fd9
+     (progn
+       (fset 'YaTeX-evince-inverse-search
+	     (if (fboundp 'evince-inverse)
+		 'evince-inverse	;Use previously defined one
+	       (function
+		(lambda (file linecol &rest args)
+		  (let* ((fn (decode-coding-string
+			      (url-unhex-string
+			       (if (string-match "^file:///" file)
+				   (substring file 7) file))
+			      'utf-8))
+			 (buf (YaTeX-switch-to-buffer fn))
+			 (ln  (car linecol))
+			 (col (car (cdr linecol))))
+		    (if (null buf)
+			(error "[Synctex]: Not found [%s]" file)
+		      (goto-line ln)
+		      (move-to-column (max 0 col))))))))
+       (dbus-register-signal
+	:session nil "/org/gnome/evince/Window/0"
+	"org.gnome.evince.Window" "SyncSource"
+        'YaTeX-evince-inverse-search)))
+
 (defun YaTeX-set-virtual-error-position (file-sym line-sym)
   "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
   (cond

yatex.org