yatex

diff yatexprc.el @ 86:f14ec50103d0

as of 2009/9/28
author yuuji@gentei.org
date Mon, 28 Sep 2009 07:56:08 +0900
parents 9b4354af748c
children ce2deaceb818
line diff
     1.1 --- a/yatexprc.el	Sun Dec 24 06:16:52 2006 +0000
     1.2 +++ b/yatexprc.el	Mon Sep 28 07:56:08 2009 +0900
     1.3 @@ -1,8 +1,8 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; YaTeX process handler.
     1.6  ;;; yatexprc.el
     1.7 -;;; (c)1993-2006 by HIROSE Yuuji.[yuuji@yatex.org]
     1.8 -;;; Last modified Sun Dec 24 15:12:50 2006 on firestorm
     1.9 +;;; (c)1993-2007 by HIROSE Yuuji.[yuuji@yatex.org]
    1.10 +;;; Last modified Thu May  7 13:47:28 2009 on firestorm
    1.11  ;;; $Id$
    1.12  
    1.13  ;(require 'yatex)
    1.14 @@ -313,13 +313,16 @@
    1.15  (defvar YaTeX-call-command-history nil
    1.16    "Holds history list of YaTeX-call-command-on-file.")
    1.17  (put 'YaTeX-call-command-history 'no-default t)
    1.18 -(defun YaTeX-call-command-on-file (base-cmd buffer)
    1.19 +(defun YaTeX-call-command-on-file (base-cmd buffer &optional file)
    1.20 +  "Call external command BASE-CMD int the BUFFER.
    1.21 +By default, pass the basename of current file.  Optional 3rd argument
    1.22 +FILE changes the default file name."
    1.23    (YaTeX-save-buffers)
    1.24    (YaTeX-typeset
    1.25     (read-string-with-history
    1.26      "Call command: "
    1.27      (concat base-cmd " "
    1.28 -	    (let ((me (file-name-nondirectory buffer-file-name)))
    1.29 +	    (let ((me (file-name-nondirectory (or file buffer-file-name))))
    1.30  	      (if (string-match "\\.tex" me)
    1.31  		  (substring me 0 (match-beginning 0))
    1.32  		me)))
    1.33 @@ -330,7 +333,9 @@
    1.34    "Pass the bibliography data of editing file to bibtex."
    1.35    (interactive)
    1.36    (YaTeX-save-buffers)
    1.37 -  (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" ))
    1.38 +  (let ((main (or YaTeX-parent-file
    1.39 +		  (progn (YaTeX-visit-main t) buffer-file-name))))
    1.40 +    (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" main)))
    1.41  
    1.42  (defun YaTeX-kill-typeset-process (proc)
    1.43    "Kill process PROC after sending signal to PROC.
    1.44 @@ -423,27 +428,27 @@
    1.45  (defun YaTeX-preview (preview-command preview-file)
    1.46    "Execute xdvi (or other) to tex-preview."
    1.47    (interactive
    1.48 -   (list
    1.49 -    (read-string-with-history
    1.50 -     "Preview command: "
    1.51 -     (YaTeX-replace-format
    1.52 -      (or (YaTeX-get-builtin "PREVIEW") dvi2-command)
    1.53 -      "p" (format (cond
    1.54 -		   (YaTeX-dos "-y:%s")
    1.55 -		   (t "-paper %s"))
    1.56 -		  (YaTeX-get-paper-type)))
    1.57 -     'YaTeX-preview-command-history)
    1.58 -    (read-string-with-history
    1.59 -     "Preview file: "
    1.60 -     (if (get 'dvi2-command 'region)
    1.61 -	 (substring YaTeX-texput-file
    1.62 -		    0 (rindex YaTeX-texput-file ?.))
    1.63 -       (YaTeX-get-preview-file-name))
    1.64 -     'YaTeX-preview-file-history)))
    1.65 -  (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))
    1.66 +   (let* ((command (read-string-with-history
    1.67 +		    "Preview command: "
    1.68 +		    (YaTeX-replace-format
    1.69 +		     (or (YaTeX-get-builtin "PREVIEW") dvi2-command)
    1.70 +		     "p" (format (cond
    1.71 +				  (YaTeX-dos "-y:%s")
    1.72 +				  (t "-paper %s"))
    1.73 +				 (YaTeX-get-paper-type)))
    1.74 +		    'YaTeX-preview-command-history))
    1.75 +	  (file (read-string-with-history
    1.76 +		 "Preview file: "
    1.77 +		 (if (get 'dvi2-command 'region)
    1.78 +		     (substring YaTeX-texput-file
    1.79 +				0 (rindex YaTeX-texput-file ?.))
    1.80 +		   (YaTeX-get-preview-file-name command))
    1.81 +		 'YaTeX-preview-file-history)))
    1.82 +     (list command file)))
    1.83    (setq dvi2-command preview-command)	;`dvi2command' is buffer local
    1.84    (save-excursion
    1.85      (YaTeX-visit-main t)
    1.86 +    (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))
    1.87      (let ((pbuffer "*dvi-preview*") (dir default-directory))
    1.88        (YaTeX-showup-buffer
    1.89         pbuffer (function (lambda (x) (nth 3 (window-edges x)))))
    1.90 @@ -467,9 +472,10 @@
    1.91  		      (concat preview-command " " preview-file)))
    1.92         (t				;if UNIX
    1.93  	(set-process-buffer
    1.94 -	 (start-process "preview" "*dvi-preview*" shell-file-name
    1.95 -			YaTeX-shell-command-option
    1.96 -			(concat preview-command " " preview-file))
    1.97 +	 (let ((process-connection-type nil))
    1.98 +	   (start-process "preview" "*dvi-preview*" shell-file-name
    1.99 +			  YaTeX-shell-command-option
   1.100 +			  (concat preview-command " " preview-file)))
   1.101  	 (get-buffer pbuffer))
   1.102  	(message
   1.103  	 (concat "Starting " preview-command
   1.104 @@ -662,14 +668,15 @@
   1.105  (defvar YaTeX-dvi2-command-ext-alist
   1.106   '(("[agx]dvi\\|dviout" . ".dvi")
   1.107     ("ghostview\\|gv" . ".ps")
   1.108 -   ("acroread\\|pdf\\|Preview\\|TeXShop" . ".pdf")))
   1.109 +   ("acroread\\|pdf\\|Preview\\|TeXShop\\|Skim" . ".pdf")))
   1.110  
   1.111 -(defun YaTeX-get-preview-file-name ()
   1.112 +(defun YaTeX-get-preview-file-name (&optional preview-command)
   1.113    "Get file name to preview by inquiring YaTeX-get-latex-command"
   1.114 +  (if (null preview-command) (setq preview-command dvi2-command))
   1.115    (let* ((latex-cmd (YaTeX-get-latex-command t))
   1.116  	 (rin (rindex latex-cmd ? ))
   1.117  	 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) ""))
   1.118 -	 (r (YaTeX-assoc-regexp dvi2-command YaTeX-dvi2-command-ext-alist))
   1.119 +	 (r (YaTeX-assoc-regexp preview-command YaTeX-dvi2-command-ext-alist))
   1.120  	 (ext (if r (cdr r) ""))
   1.121  	 (period))
   1.122      (concat
   1.123 @@ -780,8 +787,9 @@
   1.124  		      YaTeX-shell-command-option cmd))
   1.125         (t
   1.126  	(set-process-buffer
   1.127 -	 (start-process "print" "*dvi-printing*" shell-file-name
   1.128 -			YaTeX-shell-command-option cmd)
   1.129 +	 (let ((process-connection-type nil))
   1.130 +	   (start-process "print" "*dvi-printing*" shell-file-name
   1.131 +			  YaTeX-shell-command-option cmd))
   1.132  	 (get-buffer lbuffer))
   1.133  	(message "Starting printing command: %s..." cmd))))))
   1.134