yatex
changeset 351:0fc7ea5baa5f dev
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 21 Dec 2014 11:40:06 +0900 |
parents | 91ba61bb536e |
children | ecf7b5543e65 |
files | yatex.el yatexprc.el |
diffstat | 2 files changed, 41 insertions(+), 34 deletions(-) [+] |
line diff
1.1 --- a/yatex.el Sat Dec 20 20:30:33 2014 +0900 1.2 +++ b/yatex.el Sun Dec 21 11:40:06 2014 +0900 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*- 1.5 ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org] 1.6 -;;; Last modified Sat Dec 20 19:43:33 2014 on firestorm 1.7 +;;; Last modified Sun Dec 21 11:05:59 2014 on firestorm 1.8 ;;; $Id$ 1.9 ;;; The latest version of this software is always available at; 1.10 ;;; http://www.yatex.org/ 1.11 @@ -1654,7 +1654,7 @@ 1.12 "MAKEINDEX" makeindex-command arg)) 1.13 ((= c ?k) (YaTeX-kill-typeset-process YaTeX-typeset-process)) 1.14 ((= c ?p) (call-interactively 'YaTeX-preview)) 1.15 - ((= c ?q) (YaTeX-system "lpq" "*Printer queue*")) 1.16 + ((= c ?q) (YaTeX-system "lpq" "Printer queue")) 1.17 ((= c ?d) (YaTeX-typeset-buffer 1.18 (or (YaTeX-get-builtin "DVIPDF") YaTeX-dvipdf-command)) 1.19 (put 'dvi2-command 'format 'pdf)) 1.20 @@ -2006,9 +2006,8 @@ 1.21 (let ((default-directory basedir)) 1.22 (cond 1.23 ((stringp cmd) 1.24 - (let ((buf (concat "* " cmd " " src " *"))) 1.25 - (YaTeX-system (concat cmd " " src) buf) 1.26 - t)) 1.27 + (YaTeX-system (concat cmd " " src) cmd) 1.28 + t) 1.29 ((eq t cmd) 1.30 (let ((parent buffer-file-name)) 1.31 (funcall
2.1 --- a/yatexprc.el Sat Dec 20 20:30:33 2014 +0900 2.2 +++ b/yatexprc.el Sun Dec 21 11:40:06 2014 +0900 2.3 @@ -1,7 +1,7 @@ 2.4 ;;; yatexprc.el --- YaTeX process handler 2.5 ;;; 2.6 ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org] 2.7 -;;; Last modified Sat Dec 20 20:14:43 2014 on firestorm 2.8 +;;; Last modified Sun Dec 21 11:36:21 2014 on firestorm 2.9 ;;; $Id$ 2.10 2.11 ;;; Code: 2.12 @@ -537,28 +537,36 @@ 2.13 (interrupt-process proc) 2.14 (delete-process proc)))))) 2.15 2.16 -(defun YaTeX-system (command buffer) 2.17 - "Execute some command on buffer. Not a official function." 2.18 +(defun YaTeX-system (command name &optional noask basedir) 2.19 + "Execute some COMMAND with process name `NAME'. Not a official function. 2.20 +Optional second argument NOASK skip query when privious process running. 2.21 +Optional third argument BASEDIR changes default-directory there." 2.22 (save-excursion 2.23 - (YaTeX-showup-buffer 2.24 - buffer (function (lambda (x) (nth 3 (window-edges x))))) 2.25 - (let ((df default-directory)) ;preserve current buf's pwd 2.26 - (set-buffer (get-buffer-create buffer)) ;1.61.3 2.27 - (setq default-directory df) 2.28 - (cd df)) 2.29 - (erase-buffer) 2.30 - (if (not (fboundp 'start-process)) 2.31 - (call-process 2.32 - shell-file-name nil buffer nil YaTeX-shell-command-option command) 2.33 - (if (and (get-buffer-process buffer) 2.34 - (eq (process-status (get-buffer-process buffer)) 'run) 2.35 - (not 2.36 - (y-or-n-p (format "Process %s is running. Continue?" buffer)))) 2.37 - nil 2.38 - (set-process-buffer 2.39 - (start-process 2.40 - "system" buffer shell-file-name YaTeX-shell-command-option command) 2.41 - (get-buffer buffer)))))) 2.42 + (let ((df default-directory) 2.43 + (buffer (get-buffer-create (format " *%s*" name))) 2.44 + proc status) 2.45 + (set-buffer buffer) 2.46 + (setq default-directory (cd (or basedir df))) 2.47 + (erase-buffer) 2.48 + (insert (format "Calling `%s'..." command)) 2.49 + (YaTeX-showup-buffer 2.50 + buffer (function (lambda (x) (nth 3 (window-edges x))))) 2.51 + (if (not (fboundp 'start-process)) 2.52 + (call-process 2.53 + shell-file-name nil buffer nil YaTeX-shell-command-option command) 2.54 + (if (and (setq proc (get-buffer-process buffer)) 2.55 + (setq status (process-status proc)) 2.56 + (eq status 'run) 2.57 + (not noask) 2.58 + (not 2.59 + (y-or-n-p (format "Process %s is running. Continue?" buffer)))) 2.60 + nil 2.61 + (if (eq status 'run) 2.62 + (progn (interrupt-process proc) (delete-process proc))) 2.63 + (set-process-buffer 2.64 + (start-process 2.65 + name buffer shell-file-name YaTeX-shell-command-option command) 2.66 + (get-buffer buffer))))))) 2.67 2.68 (defvar YaTeX-default-paper-type "a4" 2.69 "*Default paper type.") 2.70 @@ -701,8 +709,7 @@ 2.71 2.72 (defun YaTeX-preview-jlfmt-xdvi () 2.73 "Call xdvi -sourceposition to DVI corresponding to current main file" 2.74 - (interactive) 2.75 -) 2.76 + (interactive)) 2.77 2.78 (defvar YaTeX-cmd-displayline "/Applications/Skim.app/Contents/SharedSupport/displayline") 2.79 (defun YaTeX-preview-jump-line () 2.80 @@ -713,9 +720,9 @@ 2.81 (widen) 2.82 (let*((pf (or YaTeX-parent-file 2.83 (save-excursion (YaTeX-visit-main t) (buffer-file-name)))) 2.84 - (pd (file-name-directory pf)) 2.85 + (pdir (file-name-directory pf)) 2.86 (bnr (substring pf 0 (string-match "\\....$" pf))) 2.87 - (cf (file-relative-name (buffer-file-name) pd)) 2.88 + (cf (file-relative-name (buffer-file-name) pdir)) 2.89 (buffer (get-buffer-create " *preview-jump-line*")) 2.90 (line (count-lines (point-min) (point-end-of-line))) 2.91 (previewer (YaTeX-preview-default-previewer)) 2.92 @@ -733,7 +740,7 @@ 2.93 ((string-match "evince" previewer) 2.94 (format "%s %s.pdf %d %s" 2.95 "fwdevince" bnr line cf))))) 2.96 - (YaTeX-typeset cmd buffer))))) 2.97 + (YaTeX-system cmd "jump-line" 'noask pdir))))) 2.98 2.99 (defun YaTeX-goto-corresponding-viewer () 2.100 (let ((cmd (or (YaTeX-get-builtin "!") tex-command))) 2.101 @@ -1121,13 +1128,14 @@ 2.102 (basic-save-buffer) 2.103 (let ((cmm major-mode)) 2.104 (save-excursion 2.105 - (mapcar '(lambda (buf) 2.106 + (mapcar (function 2.107 + (lambda (buf) 2.108 (set-buffer buf) 2.109 (if (and (buffer-file-name buf) 2.110 (eq major-mode cmm) 2.111 (buffer-modified-p buf) 2.112 (y-or-n-p (format "Save %s" (buffer-name buf)))) 2.113 - (save-buffer buf))) 2.114 + (save-buffer buf)))) 2.115 (buffer-list))))) 2.116 2.117 (provide 'yatexprc)