Mercurial > hgrepos > hgweb.cgi > yatex
comparison yatexprc.el @ 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 |
comparison
equal
deleted
inserted
replaced
350:91ba61bb536e | 351:0fc7ea5baa5f |
---|---|
1 ;;; yatexprc.el --- YaTeX process handler | 1 ;;; yatexprc.el --- YaTeX process handler |
2 ;;; | 2 ;;; |
3 ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org] | 3 ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org] |
4 ;;; Last modified Sat Dec 20 20:14:43 2014 on firestorm | 4 ;;; Last modified Sun Dec 21 11:36:21 2014 on firestorm |
5 ;;; $Id$ | 5 ;;; $Id$ |
6 | 6 |
7 ;;; Code: | 7 ;;; Code: |
8 ;(require 'yatex) | 8 ;(require 'yatex) |
9 (require 'yatexlib) | 9 (require 'yatexlib) |
535 (if (eq (process-status proc) 'run) | 535 (if (eq (process-status proc) 'run) |
536 (progn | 536 (progn |
537 (interrupt-process proc) | 537 (interrupt-process proc) |
538 (delete-process proc)))))) | 538 (delete-process proc)))))) |
539 | 539 |
540 (defun YaTeX-system (command buffer) | 540 (defun YaTeX-system (command name &optional noask basedir) |
541 "Execute some command on buffer. Not a official function." | 541 "Execute some COMMAND with process name `NAME'. Not a official function. |
542 Optional second argument NOASK skip query when privious process running. | |
543 Optional third argument BASEDIR changes default-directory there." | |
542 (save-excursion | 544 (save-excursion |
543 (YaTeX-showup-buffer | 545 (let ((df default-directory) |
544 buffer (function (lambda (x) (nth 3 (window-edges x))))) | 546 (buffer (get-buffer-create (format " *%s*" name))) |
545 (let ((df default-directory)) ;preserve current buf's pwd | 547 proc status) |
546 (set-buffer (get-buffer-create buffer)) ;1.61.3 | 548 (set-buffer buffer) |
547 (setq default-directory df) | 549 (setq default-directory (cd (or basedir df))) |
548 (cd df)) | 550 (erase-buffer) |
549 (erase-buffer) | 551 (insert (format "Calling `%s'..." command)) |
550 (if (not (fboundp 'start-process)) | 552 (YaTeX-showup-buffer |
551 (call-process | 553 buffer (function (lambda (x) (nth 3 (window-edges x))))) |
552 shell-file-name nil buffer nil YaTeX-shell-command-option command) | 554 (if (not (fboundp 'start-process)) |
553 (if (and (get-buffer-process buffer) | 555 (call-process |
554 (eq (process-status (get-buffer-process buffer)) 'run) | 556 shell-file-name nil buffer nil YaTeX-shell-command-option command) |
555 (not | 557 (if (and (setq proc (get-buffer-process buffer)) |
556 (y-or-n-p (format "Process %s is running. Continue?" buffer)))) | 558 (setq status (process-status proc)) |
557 nil | 559 (eq status 'run) |
558 (set-process-buffer | 560 (not noask) |
559 (start-process | 561 (not |
560 "system" buffer shell-file-name YaTeX-shell-command-option command) | 562 (y-or-n-p (format "Process %s is running. Continue?" buffer)))) |
561 (get-buffer buffer)))))) | 563 nil |
564 (if (eq status 'run) | |
565 (progn (interrupt-process proc) (delete-process proc))) | |
566 (set-process-buffer | |
567 (start-process | |
568 name buffer shell-file-name YaTeX-shell-command-option command) | |
569 (get-buffer buffer))))))) | |
562 | 570 |
563 (defvar YaTeX-default-paper-type "a4" | 571 (defvar YaTeX-default-paper-type "a4" |
564 "*Default paper type.") | 572 "*Default paper type.") |
565 (defconst YaTeX-paper-type-alist | 573 (defconst YaTeX-paper-type-alist |
566 '(("a4paper" . "a4") | 574 '(("a4paper" . "a4") |
699 (concat (YaTeX-get-preview-file-name) ".dvi"))) | 707 (concat (YaTeX-get-preview-file-name) ".dvi"))) |
700 (message "Searching `%s'...Done" str)))) | 708 (message "Searching `%s'...Done" str)))) |
701 | 709 |
702 (defun YaTeX-preview-jlfmt-xdvi () | 710 (defun YaTeX-preview-jlfmt-xdvi () |
703 "Call xdvi -sourceposition to DVI corresponding to current main file" | 711 "Call xdvi -sourceposition to DVI corresponding to current main file" |
704 (interactive) | 712 (interactive)) |
705 ) | |
706 | 713 |
707 (defvar YaTeX-cmd-displayline "/Applications/Skim.app/Contents/SharedSupport/displayline") | 714 (defvar YaTeX-cmd-displayline "/Applications/Skim.app/Contents/SharedSupport/displayline") |
708 (defun YaTeX-preview-jump-line () | 715 (defun YaTeX-preview-jump-line () |
709 "Call jump-line function of various previewer on current main file" | 716 "Call jump-line function of various previewer on current main file" |
710 (interactive) | 717 (interactive) |
711 (save-excursion | 718 (save-excursion |
712 (save-restriction | 719 (save-restriction |
713 (widen) | 720 (widen) |
714 (let*((pf (or YaTeX-parent-file | 721 (let*((pf (or YaTeX-parent-file |
715 (save-excursion (YaTeX-visit-main t) (buffer-file-name)))) | 722 (save-excursion (YaTeX-visit-main t) (buffer-file-name)))) |
716 (pd (file-name-directory pf)) | 723 (pdir (file-name-directory pf)) |
717 (bnr (substring pf 0 (string-match "\\....$" pf))) | 724 (bnr (substring pf 0 (string-match "\\....$" pf))) |
718 (cf (file-relative-name (buffer-file-name) pd)) | 725 (cf (file-relative-name (buffer-file-name) pdir)) |
719 (buffer (get-buffer-create " *preview-jump-line*")) | 726 (buffer (get-buffer-create " *preview-jump-line*")) |
720 (line (count-lines (point-min) (point-end-of-line))) | 727 (line (count-lines (point-min) (point-end-of-line))) |
721 (previewer (YaTeX-preview-default-previewer)) | 728 (previewer (YaTeX-preview-default-previewer)) |
722 (cmd (cond | 729 (cmd (cond |
723 ((string-match "xdvi" previewer) | 730 ((string-match "xdvi" previewer) |
731 (format "%s %s.pdf %d %s" | 738 (format "%s %s.pdf %d %s" |
732 previewer bnr line cf)) | 739 previewer bnr line cf)) |
733 ((string-match "evince" previewer) | 740 ((string-match "evince" previewer) |
734 (format "%s %s.pdf %d %s" | 741 (format "%s %s.pdf %d %s" |
735 "fwdevince" bnr line cf))))) | 742 "fwdevince" bnr line cf))))) |
736 (YaTeX-typeset cmd buffer))))) | 743 (YaTeX-system cmd "jump-line" 'noask pdir))))) |
737 | 744 |
738 (defun YaTeX-goto-corresponding-viewer () | 745 (defun YaTeX-goto-corresponding-viewer () |
739 (let ((cmd (or (YaTeX-get-builtin "!") tex-command))) | 746 (let ((cmd (or (YaTeX-get-builtin "!") tex-command))) |
740 (if (string-match "-src\\|synctex=" cmd) | 747 (if (string-match "-src\\|synctex=" cmd) |
741 (progn | 748 (progn |
1119 (defun YaTeX-save-buffers () | 1126 (defun YaTeX-save-buffers () |
1120 "Save buffers whose major-mode is equal to current major-mode." | 1127 "Save buffers whose major-mode is equal to current major-mode." |
1121 (basic-save-buffer) | 1128 (basic-save-buffer) |
1122 (let ((cmm major-mode)) | 1129 (let ((cmm major-mode)) |
1123 (save-excursion | 1130 (save-excursion |
1124 (mapcar '(lambda (buf) | 1131 (mapcar (function |
1132 (lambda (buf) | |
1125 (set-buffer buf) | 1133 (set-buffer buf) |
1126 (if (and (buffer-file-name buf) | 1134 (if (and (buffer-file-name buf) |
1127 (eq major-mode cmm) | 1135 (eq major-mode cmm) |
1128 (buffer-modified-p buf) | 1136 (buffer-modified-p buf) |
1129 (y-or-n-p (format "Save %s" (buffer-name buf)))) | 1137 (y-or-n-p (format "Save %s" (buffer-name buf)))) |
1130 (save-buffer buf))) | 1138 (save-buffer buf)))) |
1131 (buffer-list))))) | 1139 (buffer-list))))) |
1132 | 1140 |
1133 (provide 'yatexprc) | 1141 (provide 'yatexprc) |