yatex

changeset 592:86ceef677ca2

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 diff
     1.1 --- a/yatexprc.el	Fri Sep 23 18:42:59 2022 +0900
     1.2 +++ b/yatexprc.el	Sat Sep 24 12:25:21 2022 +0900
     1.3 @@ -1,7 +1,7 @@
     1.4  ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*-
     1.5  ;;; 
     1.6 -;;; (c)1993-2019 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Thu Dec 26 12:48:12 2019 on firestorm
     1.8 +;;; (c)1993-2022 by HIROSE Yuuji.[yuuji@yatex.org]
     1.9 +;;; Last modified Sat Sep 24 12:17:14 2022 on firestorm
    1.10  ;;; $Id$
    1.11  
    1.12  ;;; Code:
    1.13 @@ -1149,6 +1149,34 @@
    1.14  	  t)				;for YaTeX-goto-corresponding-*
    1.15        nil)))
    1.16  
    1.17 +(and (or (featurep 'dbus) (load "dbus" t))
    1.18 +     ;; Cannot load dbus on emacs without dbus module
    1.19 +     (fboundp 'url-unhex-string)
    1.20 +     (fboundp 'dbus-register-signal)
    1.21 +     ;; From https://texwiki.texjp.org/?Emacs#vecb4fd9
    1.22 +     (progn
    1.23 +       (fset 'YaTeX-evince-inverse-search
    1.24 +	     (if (fboundp 'evince-inverse)
    1.25 +		 'evince-inverse	;Use previously defined one
    1.26 +	       (function
    1.27 +		(lambda (file linecol &rest args)
    1.28 +		  (let* ((fn (decode-coding-string
    1.29 +			      (url-unhex-string
    1.30 +			       (if (string-match "^file:///" file)
    1.31 +				   (substring file 7) file))
    1.32 +			      'utf-8))
    1.33 +			 (buf (YaTeX-switch-to-buffer fn))
    1.34 +			 (ln  (car linecol))
    1.35 +			 (col (car (cdr linecol))))
    1.36 +		    (if (null buf)
    1.37 +			(error "[Synctex]: Not found [%s]" file)
    1.38 +		      (goto-line ln)
    1.39 +		      (move-to-column (max 0 col))))))))
    1.40 +       (dbus-register-signal
    1.41 +	:session nil "/org/gnome/evince/Window/0"
    1.42 +	"org.gnome.evince.Window" "SyncSource"
    1.43 +        'YaTeX-evince-inverse-search)))
    1.44 +
    1.45  (defun YaTeX-set-virtual-error-position (file-sym line-sym)
    1.46    "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
    1.47    (cond