changeset 350:91ba61bb536e dev

[prefix] g calls forward-search of previewers if -src is given to typesetting.
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 20 Dec 2014 20:30:33 +0900
parents b5bf68206bd1
children 0fc7ea5baa5f
files yatex.el yatex.new yatexprc.el
diffstat 3 files changed, 54 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/yatex.el	Sat Dec 20 14:57:53 2014 +0900
+++ b/yatex.el	Sat Dec 20 20:30:33 2014 +0900
@@ -1,6 +1,6 @@
 ;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*-
 ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Dec 19 07:46:21 2014 on firestorm
+;;; Last modified Sat Dec 20 19:43:33 2014 on firestorm
 ;;; $Id$
 ;;; The latest version of this software is always available at;
 ;;; http://www.yatex.org/
@@ -765,6 +765,7 @@
 (autoload 'YaTeX-get-builtin "yatexprc" "Get %# built-in." t)
 (autoload 'YaTeX-system "yatexprc" "Call system command" t)
 (autoload 'YaTeX-save-buffers "yatexprc" "Save buffers of same major mode" t)
+(autoload 'YaTeX-goto-corresponding-viewer "yatexprc" "Viewer jump line" t)
 
 ;;autoload from yatexmth.el
 (autoload 'YaTeX-math-insert-sequence "yatexmth" "Image input." t)
@@ -2190,6 +2191,7 @@
      ;;	  YaTeX-equation-env-regexp	;to delay loading
      ;;	  (or (YaTeX-inner-environment t) "document"))
      ;;	 (YaTeX-goto-corresponding-leftright)))
+     ((YaTeX-goto-corresponding-viewer))
      (t (message "I don't know where to go.")))))
 
 (defun YaTeX-goto-corresponding-*-other-window (arg)
--- a/yatex.new	Sat Dec 20 14:57:53 2014 +0900
+++ b/yatex.new	Sat Dec 20 20:30:33 2014 +0900
@@ -5,6 +5,7 @@
 	=== yatex ===
 	主な外部コマンド名を変数化。
 	[prefix] t d の直後のデフォルトヴューアはPDF用のものに。
+	「%#!コマンド -オプション」のときは親ファイル指定なしと判定。
 
 1.77	last-command-char 廃止対策を追加。
 	=== yatex ===
--- a/yatexprc.el	Sat Dec 20 14:57:53 2014 +0900
+++ b/yatexprc.el	Sat Dec 20 20:30:33 2014 +0900
@@ -1,7 +1,7 @@
 ;;; yatexprc.el --- YaTeX process handler
 ;;; 
 ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Nov 13 08:49:02 2014 on firestorm
+;;; Last modified Sat Dec 20 20:14:43 2014 on firestorm
 ;;; $Id$
 
 ;;; Code:
@@ -699,7 +699,51 @@
 	     (concat (YaTeX-get-preview-file-name) ".dvi")))
       (message "Searching `%s'...Done" str))))
 
-(defun YaTeX-set-virtual-error-position (file-sym line-sym)
+(defun YaTeX-preview-jlfmt-xdvi ()
+  "Call xdvi -sourceposition to DVI corresponding to current main file"
+  (interactive)
+)
+
+(defvar YaTeX-cmd-displayline "/Applications/Skim.app/Contents/SharedSupport/displayline")
+(defun YaTeX-preview-jump-line ()
+  "Call jump-line function of various previewer on current main file"
+  (interactive)
+  (save-excursion
+    (save-restriction
+      (widen)
+      (let*((pf (or YaTeX-parent-file
+		    (save-excursion (YaTeX-visit-main t) (buffer-file-name))))
+	    (pd (file-name-directory pf))
+	    (bnr (substring pf 0 (string-match "\\....$" pf)))
+	    (cf (file-relative-name (buffer-file-name) pd))
+	    (buffer (get-buffer-create " *preview-jump-line*"))
+	    (line (count-lines (point-min) (point-end-of-line)))
+	    (previewer (YaTeX-preview-default-previewer))
+	    (cmd (cond
+		  ((string-match "xdvi" previewer)
+		   (format "%s -nofork -sourceposition '%d %s' %s.dvi"
+			   YaTeX-xdvi-remote-program
+			   line cf bnr))
+		  ((string-match "Skim" previewer)
+		   (format "%s %d %s.pdf %s"
+			   YaTeX-cmd-displayline line bnr cf))
+		  ((string-match "sumatra" previewer)
+		   (format "%s %s.pdf %d %s"
+			   previewer bnr line cf))
+		  ((string-match "evince" previewer)
+		   (format "%s %s.pdf %d %s"
+			   "fwdevince" bnr line cf)))))
+	(YaTeX-typeset cmd buffer)))))
+
+(defun YaTeX-goto-corresponding-viewer ()
+  (let ((cmd (or (YaTeX-get-builtin "!") tex-command)))
+    (if (string-match "-src\\|synctex=" cmd)
+	(progn
+	  (YaTeX-preview-jump-line)
+	  t)				;for YaTeX-goto-corresponding-*
+      nil)))
+
+	 (defun YaTeX-set-virtual-error-position (file-sym line-sym)
   "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
   (cond
    ((and (get 'dvi2-command 'region)
@@ -915,9 +959,9 @@
      (cond
       (magic
        (cond
-	(switch (if (string-match "\\s " magic) magic
+	(switch (if (string-match "\\s [^-]\\S *$" magic) magic
 		  (concat magic " " parent)))
-	(t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
+	(t (concat (substring magic 0 (string-match "\\s [^-]\\S *$" magic)) " "))))
       (t (concat tex-command " " (if switch parent))))
      (list (cons "f" tparent)
 	   (cons "r" (substring tparent 0 (rindex tparent ?.)))))))
@@ -1056,8 +1100,8 @@
 
 (defun YaTeX-guess-parent (command-line)
   (setq command-line
-	(if (string-match ".*\\s " command-line)
-	    (substring command-line (match-end 0))
+	(if (string-match "\\s \\([^-]\\S *\\)$" command-line)
+	    (substring command-line (match-beginning 1))
 	  (file-name-nondirectory (buffer-file-name)))
 	command-line
 	(concat (if (string-match "\\(.*\\)\\." command-line)

yatex.org