yatex
diff yatexprc.el @ 80:9b4354af748c
Too many changes from 1.72.
See yatex.new. (Japanese)
author | yuuji |
---|---|
date | Sun, 24 Dec 2006 06:16:52 +0000 |
parents | 0734be649cb8 |
children | f14ec50103d0 |
line diff
1.1 --- a/yatexprc.el Thu Dec 25 04:10:32 2003 +0000 1.2 +++ b/yatexprc.el Sun Dec 24 06:16:52 2006 +0000 1.3 @@ -1,8 +1,8 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; YaTeX process handler. 1.6 ;;; yatexprc.el 1.7 -;;; (c)1993-2003 by HIROSE Yuuji.[yuuji@yatex.org] 1.8 -;;; Last modified Sun Nov 2 08:09:44 2003 on firestorm 1.9 +;;; (c)1993-2006 by HIROSE Yuuji.[yuuji@yatex.org] 1.10 +;;; Last modified Sun Dec 24 15:12:50 2006 on firestorm 1.11 ;;; $Id$ 1.12 1.13 ;(require 'yatex) 1.14 @@ -37,6 +37,7 @@ 1.15 ;; ((boundp 'NEMACS) 1.16 ;; (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist)))) 1.17 (cond 1.18 + (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist))) 1.19 (YaTeX-emacs-20 1.20 (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist))) 1.21 ((boundp 'MULE) 1.22 @@ -317,7 +318,11 @@ 1.23 (YaTeX-typeset 1.24 (read-string-with-history 1.25 "Call command: " 1.26 - (concat base-cmd " " (YaTeX-get-preview-file-name)) 1.27 + (concat base-cmd " " 1.28 + (let ((me (file-name-nondirectory buffer-file-name))) 1.29 + (if (string-match "\\.tex" me) 1.30 + (substring me 0 (match-beginning 0)) 1.31 + me))) 1.32 'YaTeX-call-command-history) 1.33 buffer)) 1.34 1.35 @@ -429,12 +434,13 @@ 1.36 (YaTeX-get-paper-type))) 1.37 'YaTeX-preview-command-history) 1.38 (read-string-with-history 1.39 - "Preview file[.dvi]: " 1.40 + "Preview file: " 1.41 (if (get 'dvi2-command 'region) 1.42 (substring YaTeX-texput-file 1.43 0 (rindex YaTeX-texput-file ?.)) 1.44 (YaTeX-get-preview-file-name)) 1.45 'YaTeX-preview-file-history))) 1.46 + (if YaTeX-dos (setq preview-file (expand-file-name preview-file))) 1.47 (setq dvi2-command preview-command) ;`dvi2command' is buffer local 1.48 (save-excursion 1.49 (YaTeX-visit-main t) 1.50 @@ -511,7 +517,7 @@ 1.51 error or warning lines in reverse order." 1.52 (interactive) 1.53 (let ((cur-buf (buffer-name)) (cur-win (selected-window)) 1.54 - error-line typeset-win error-buffer error-win) 1.55 + b0 errorp error-line typeset-win error-buffer error-win) 1.56 (if (null (get-buffer YaTeX-typeset-buffer)) 1.57 (error "There is no typesetting buffer.")) 1.58 (YaTeX-showup-buffer YaTeX-typeset-buffer nil t) 1.59 @@ -520,10 +526,10 @@ 1.60 (concat "\\(" latex-error-regexp "\\)\\|\\(" 1.61 latex-warning-regexp "\\)") 1.62 nil t) 1.63 - nil 1.64 + (setq errorp (match-beginning 1)) 1.65 (select-window cur-win) 1.66 (error "No more errors on %s" cur-buf)) 1.67 - (goto-char (match-beginning 0)) 1.68 + (goto-char (setq b0 (match-beginning 0))) 1.69 (skip-chars-forward "^0-9" (match-end 0)) 1.70 (setq error-line 1.71 (string-to-int 1.72 @@ -545,13 +551,13 @@ 1.73 (setq error-win (selected-window)) 1.74 (goto-line error-line) 1.75 (message "LaTeX %s in `%s' on line: %d." 1.76 - (if (match-beginning 1) "error" "warning") 1.77 + (if errorp "error" "warning") 1.78 error-buffer error-line) 1.79 (select-window typeset-win) 1.80 (skip-chars-backward "0-9") 1.81 (recenter (/ (window-height) 2)) 1.82 (sit-for 1) 1.83 - (goto-char (match-beginning 0)) 1.84 + (goto-char b0) 1.85 (select-window error-win))) 1.86 1.87 (defun YaTeX-jump-error-line () 1.88 @@ -653,18 +659,27 @@ 1.89 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$") 1.90 (widen)))) 1.91 1.92 +(defvar YaTeX-dvi2-command-ext-alist 1.93 + '(("[agx]dvi\\|dviout" . ".dvi") 1.94 + ("ghostview\\|gv" . ".ps") 1.95 + ("acroread\\|pdf\\|Preview\\|TeXShop" . ".pdf"))) 1.96 + 1.97 (defun YaTeX-get-preview-file-name () 1.98 "Get file name to preview by inquiring YaTeX-get-latex-command" 1.99 (let* ((latex-cmd (YaTeX-get-latex-command t)) 1.100 (rin (rindex latex-cmd ? )) 1.101 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) "")) 1.102 + (r (YaTeX-assoc-regexp dvi2-command YaTeX-dvi2-command-ext-alist)) 1.103 + (ext (if r (cdr r) "")) 1.104 (period)) 1.105 - (if (string= fname "") 1.106 + (concat 1.107 + (if (string= fname "") 1.108 (setq fname (substring (file-name-nondirectory 1.109 (buffer-file-name)) 1.110 0 -4)) 1.111 (setq period (rindex fname ?.)) 1.112 - (setq fname (substring fname 0 (if (eq -1 period) nil period)))))) 1.113 + (setq fname (substring fname 0 (if (eq -1 period) nil period)))) 1.114 + ext))) 1.115 1.116 (defun YaTeX-get-latex-command (&optional switch) 1.117 "Specify the latex-command name and its argument. 1.118 @@ -680,21 +695,27 @@ 1.119 \"jlatex main.tex\" 1.120 1.121 will be given to the shell." 1.122 - (let (magic command target) 1.123 + (let (parent tparent magic) 1.124 (setq parent 1.125 (cond 1.126 - (YaTeX-parent-file YaTeX-parent-file) 1.127 + (YaTeX-parent-file 1.128 + (if YaTeX-dos (expand-file-name YaTeX-parent-file) 1.129 + YaTeX-parent-file)) 1.130 (t (save-excursion 1.131 (YaTeX-visit-main t) 1.132 (file-name-nondirectory (buffer-file-name))))) 1.133 - magic (YaTeX-get-builtin "!")) 1.134 - (cond 1.135 - (magic 1.136 - (cond 1.137 - (switch (if (string-match "\\s " magic) magic 1.138 - (concat magic " " parent))) 1.139 - (t (concat (substring magic 0 (string-match "\\s " magic)) " ")))) 1.140 - (t (concat tex-command " " (if switch parent)))))) 1.141 + magic (YaTeX-get-builtin "!") 1.142 + tparent (file-name-nondirectory parent)) 1.143 + (YaTeX-replace-formats 1.144 + (cond 1.145 + (magic 1.146 + (cond 1.147 + (switch (if (string-match "\\s " magic) magic 1.148 + (concat magic " " parent))) 1.149 + (t (concat (substring magic 0 (string-match "\\s " magic)) " ")))) 1.150 + (t (concat tex-command " " (if switch parent)))) 1.151 + (list (cons "f" tparent) 1.152 + (cons "r" (substring tparent 0 (rindex tparent ?.))))))) 1.153 1.154 (defvar YaTeX-lpr-command-history nil 1.155 "Holds command line history of YaTeX-lpr.") 1.156 @@ -813,8 +834,9 @@ 1.157 ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf))) 1.158 ((and main-file 1.159 (file-exists-p (setq main-file (concat "../" main-file))) 1.160 - (y-or-n-p (concat (expand-file-name main-file) 1.161 - " is main file?:"))) 1.162 + (or b-in 1.163 + (y-or-n-p (concat (expand-file-name main-file) 1.164 + " is main file?:")))) 1.165 (setq YaTeX-parent-file main-file) 1.166 ;(YaTeX-switch-to-buffer main-file setbuf) 1.167 (funcall ff main-file) 1.168 @@ -851,7 +873,7 @@ 1.169 (if (and (re-search-forward 1.170 (concat "^" (regexp-quote (concat "%#" key))) nil t) 1.171 (not (eolp))) 1.172 - (buffer-substring 1.173 + (YaTeX-buffer-substring 1.174 (progn (skip-chars-forward " " (point-end-of-line))(point)) 1.175 (point-end-of-line)) 1.176 nil)))