annotate yatexprc.el @ 212:c63a4ec6a492 dev

Rerun typesetter when cross-reference warning seen.
author yuuji@gentei.org
date Thu, 12 Jan 2012 20:26:32 +0900
parents cf7352dfa40c
children 6a2594372108
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
1 ;;; -*- Emacs-Lisp -*-
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
2 ;;; YaTeX process handler.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
3 ;;; yatexprc.el
195
cf7352dfa40c Update copyright line.
yuuji@gentei.org
parents: 172
diff changeset
4 ;;; (c)1993-2012 by HIROSE Yuuji.[yuuji@yatex.org]
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
5 ;;; Last modified Thu Jan 12 17:52:15 2012 on firestorm
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
6 ;;; $Id$
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
7
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
8 ;(require 'yatex)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
9 (require 'yatexlib)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
10
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
11 (defvar YaTeX-typeset-process nil
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
12 "Process identifier for jlatex")
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
13
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
14 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
15 "Process buffer for jlatex")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
16
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
17 (defvar YaTeX-typeset-buffer-syntax nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
18 "*Syntax table for typesetting buffer")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
19
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
20 (defvar YaTeX-current-TeX-buffer nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
21 "Keeps the buffer on which recently typeset run.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
22
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
23 (defvar YaTeX-shell-command-option
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
24 (or (and (boundp 'shell-command-option) shell-command-option)
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
25 (and (boundp 'shell-command-switch) shell-command-switch)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
26 (if YaTeX-dos "/c" "-c"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
27 "Shell option for command execution.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
28
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
29 (defvar YaTeX-latex-message-code
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
30 ;; (cond
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
31 ;; (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist)))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
32 ;; ((and YaTeX-emacs-20 (member 'undecided (coding-system-list))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
33 ;; 'undecided))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
34 ;; ((featurep 'mule)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
35 ;; (or (and (boundp '*autoconv*) *autoconv*)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
36 ;; (and (fboundp 'coding-system-list) 'automatic-conversion)))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
37 ;; ((boundp 'NEMACS)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
38 ;; (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
39 (cond
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
40 (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist)))
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
41 (YaTeX-emacs-20
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
42 (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist)))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
43 ((boundp 'MULE)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
44 (symbol-value
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
45 (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
46 ((boundp 'NEMACS)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
47 latex-message-kanji-code))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
48 "Process coding system for LaTeX.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
49
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
50 (if YaTeX-typeset-buffer-syntax nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
51 (setq YaTeX-typeset-buffer-syntax
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
52 (make-syntax-table (standard-syntax-table)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
53 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
54 (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
55 (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
56 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
57
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
58 (defvar YaTeX-typeset-marker nil)
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
59 (defun YaTeX-typeset (command buffer &optional prcname modename ppcmd rerun)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
60 "Execute jlatex (or other) to LaTeX typeset."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
61 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
62 (save-excursion
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
63 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
64 (map YaTeX-typesetting-mode-map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
65 (outcode
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
66 (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
67 ((eq major-mode 'yahtml-mode) yahtml-kanji-code))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
68 (if (and YaTeX-typeset-process
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
69 (eq (process-status YaTeX-typeset-process) 'run))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
70 ;; if tex command is halting.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
71 (YaTeX-kill-typeset-process YaTeX-typeset-process))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
72 (YaTeX-put-nonstopmode)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
73 (setq prcname (or prcname "LaTeX")
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
74 modename (or modename "typeset"))
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
75 (if (eq major-mode 'yatex-mode) (YaTeX-visit-main t)) ;;execution dir
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
76 (setq execdir default-directory)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
77 ;;Select lower-most window if there are more than 2 windows and
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
78 ;;typeset buffer not seen.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
79 (YaTeX-showup-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
80 buffer (function (lambda (x) (nth 3 (window-edges x)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
81 (set-buffer (get-buffer-create buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
82 (setq default-directory execdir)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
83 (cd execdir)
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
84 (or rerun (erase-buffer))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
85 (cond
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
86 ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
87 (call-process
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
88 shell-file-name nil buffer nil YaTeX-shell-command-option command))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
89 (t ;if UNIX
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
90 (set-process-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
91 (setq YaTeX-typeset-process
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
92 (start-process prcname buffer shell-file-name
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
93 YaTeX-shell-command-option command))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
94 (get-buffer buffer))
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
95 (set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
96 (put 'YaTeX-typeset-process 'thiscmd command)
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
97 (put 'YaTeX-typeset-process 'name prcname)
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
98 (let ((ppprop (get 'YaTeX-typeset-process 'ppcmd)))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
99 (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
100 (if ppcmd
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
101 (setq ppprop (cons (cons YaTeX-typeset-process ppcmd) ppprop)))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
102 (put 'YaTeX-typeset-process 'ppcmd ppprop))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
103 (message (format "Calling `%s'..." command))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
104 (setq YaTeX-current-TeX-buffer (buffer-name))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
105 (use-local-map map) ;map may be localized
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
106 (set-syntax-table YaTeX-typeset-buffer-syntax)
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
107 (setq mode-name modename)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
108 (if YaTeX-typeset-process ;if process is running (maybe on UNIX)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
109 (cond ((fboundp 'set-current-process-coding-system)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
110 (set-current-process-coding-system
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
111 YaTeX-latex-message-code outcode))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
112 ((fboundp 'set-process-coding-system)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
113 (set-process-coding-system
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
114 YaTeX-typeset-process YaTeX-latex-message-code outcode))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
115 (YaTeX-emacs-20
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
116 (set-buffer-process-coding-system
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
117 YaTeX-latex-message-code outcode))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
118 ((boundp 'NEMACS)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
119 (set-kanji-process-code YaTeX-latex-message-code))))
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
120 (set-marker (or YaTeX-typeset-marker
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
121 (setq YaTeX-typeset-marker (make-marker)))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
122 (point))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
123 (insert (format "Call `%s'\n" command))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
124 (if YaTeX-dos (message "Done.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
125 (insert " ")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
126 (set-marker (process-mark YaTeX-typeset-process) (1- (point))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
127 (if (bolp) (forward-line -1)) ;what for?
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
128 (if (and YaTeX-emacs-19 window-system)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
129 (let ((win (get-buffer-window buffer t)) owin)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
130 (select-frame (window-frame win))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
131 (setq owin (selected-window))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
132 (select-window win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
133 (goto-char (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
134 (recenter -1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
135 (select-window owin))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
136 (select-window (get-buffer-window buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
137 (goto-char (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
138 (recenter -1))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
139 (select-window window)
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
140 (switch-to-buffer cb)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
141 (YaTeX-remove-nonstopmode))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
142
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
143 (defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.")
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
144 (defun YaTeX-typeset-sentinel (proc mes)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
145 (cond ((null (buffer-name (process-buffer proc)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
146 ;; buffer killed
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
147 (set-process-buffer proc nil))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
148 ((memq (process-status proc) '(signal exit))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
149 (let* ((obuf (current-buffer)) (pbuf (process-buffer proc))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
150 (pwin (get-buffer-window pbuf))
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
151 (owin (selected-window)) win
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
152 (thiscmd (get 'YaTeX-typeset-process 'thiscmd))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
153 (ppprop (get 'YaTeX-typeset-process 'ppcmd))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
154 (ppcmd (cdr (assq proc ppprop))))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
155 (put 'YaTeX-typeset-process 'ppcmd ;erase ppcmd
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
156 (delq (assq proc ppprop) ppprop))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
157 ;; save-excursion isn't the right thing if
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
158 ;; process-buffer is current-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
159 (unwind-protect
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
160 (progn
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
161 ;; Write something in *typesetting* and hack its mode line
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
162 (if pwin
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
163 (select-window pwin)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
164 (set-buffer pbuf))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
165 ;;(YaTeX-showup-buffer pbuf nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
166 (goto-char (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
167 (if pwin (recenter -3))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
168 (insert ?\n mode-name " " mes)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
169 (forward-char -1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
170 (insert " at " (substring (current-time-string) 0 -5) "\n")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
171 (setq mode-line-process
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
172 (concat ": "
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
173 (symbol-name (process-status proc))))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
174 (message mode-name " %s."
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
175 (if (eq (process-status proc) 'exit)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
176 "done" "ceased"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
177 ;; If buffer and mode line shows that the process
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
178 ;; is dead, we can delete it now. Otherwise it
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
179 ;; will stay around until M-x list-processes.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
180 (delete-process proc)
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
181 (if (save-excursion
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
182 (search-backward
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
183 YaTeX-typeset-rerun-msg YaTeX-typeset-marker t))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
184 (progn
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
185 (insert
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
186 (format
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
187 "===!!! %s !!!===\n"
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
188 (message "Rerun `%s' to get cross-references right"
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
189 thiscmd)))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
190 (set-marker YaTeX-typeset-marker (point))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
191 (save-excursion (sit-for 2))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
192 (set-process-sentinel
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
193 (start-process
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
194 mode-name pbuf
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
195 shell-file-name YaTeX-shell-command-option thiscmd)
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
196 'YaTeX-typeset-sentinel)
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
197 (if ppcmd
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
198 (put 'YaTeX-typeset-process 'ppcmd
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
199 (cons (cons (get-buffer-process pbuf) ppcmd)
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
200 ppprop))))
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
201 ;; If ppcmd is active, call it.
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
202 (cond
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
203 ((and ppcmd (string-match "finish" mes))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
204 (insert (format "=======> Success! Calling %s\n" ppcmd))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
205 (setq mode-name ; set process name
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
206 (substring ppcmd 0 (string-match " " ppcmd)))
212
c63a4ec6a492 Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents: 195
diff changeset
207 ; to reach here, 'start-process exists on this emacsen
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
208 (set-process-sentinel
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
209 (start-process
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
210 mode-name
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
211 pbuf ; Use this buffer twice.
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
212 shell-file-name YaTeX-shell-command-option
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
213 ppcmd)
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
214 'YaTeX-typeset-sentinel))))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
215
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
216 (forward-char 1))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
217 (setq YaTeX-typeset-process nil)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
218 ;; Force mode line redisplay soon
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
219 (set-buffer-modified-p (buffer-modified-p))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
220 )
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
221 (select-window owin)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
222 (set-buffer obuf)))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
223
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
224 (defvar YaTeX-texput-file "texput.tex"
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
225 "*File name for temporary file of typeset-region.")
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
226
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
227 (defun YaTeX-typeset-region ()
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
228 "Paste the region to the file `texput.tex' and execute typesetter.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
229 The region is specified by the rule:
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
230 (1)If keyword `%#BEGIN' is found in the upper direction from (point).
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
231 (1-1)if the keyword `%#END' is found after `%#BEGIN',
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
232 ->Assume the text between `%#BEGIN' and `%#END' as region.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
233 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN',
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
234 ->Assume the text after `%#BEGIN' as region.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
235 (2)If no `%#BEGIN' usage is found before the (point),
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
236 ->Assume the text between current (point) and (mark) as region.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
237 DON'T forget to eliminate the `%#BEGIN/%#END' notation after editing
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
238 operation to the region."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
239 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
240 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
241 (let*
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
242 ((end "") typeout ;Type out message that tells the method of cutting.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
243 (texput YaTeX-texput-file)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
244 (cmd (concat (YaTeX-get-latex-command nil) " " texput))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
245 (buffer (current-buffer)) opoint preamble (subpreamble "") main
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
246 (hilit-auto-highlight nil) ;for Emacs19 with hilit19
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
247 reg-begin reg-end lineinfo)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
248
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
249 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
250 (if (search-backward "%#BEGIN" nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
251 (progn
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
252 (setq typeout "--- Region from BEGIN to "
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
253 end "the end of the buffer ---"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
254 reg-begin (match-end 0))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
255 (if (search-forward "%#END" nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
256 (setq reg-end (match-beginning 0)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
257 end "END ---")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
258 (setq reg-end (point-max))))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
259 (setq typeout "=== Region from (point) to (mark) ==="
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
260 reg-begin (point) reg-end (mark)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
261 (goto-char (min reg-begin reg-end))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
262 (setq lineinfo (count-lines (point-min) (point-end-of-line)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
263 (goto-char (point-min))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
264 (while (search-forward "%#REQUIRE" nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
265 (setq subpreamble
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
266 (concat subpreamble
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
267 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
268 ((eolp)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
269 (buffer-substring
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
270 (match-beginning 0)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
271 (point-beginning-of-line)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
272 (t (buffer-substring
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
273 (match-end 0)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
274 (point-end-of-line))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
275 "\n"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
276 (goto-char (match-end 0))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
277 (YaTeX-visit-main t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
278 (setq main (current-buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
279 (setq opoint (point))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
280 (goto-char (point-min))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
281 (setq
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
282 preamble
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
283 (if (re-search-forward "^[ ]*\\\\begin.*{document}" nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
284 (buffer-substring (point-min) (match-end 0))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
285 (concat
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
286 (if YaTeX-use-LaTeX2e "\\documentclass{" "\\documentstyle{")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
287 YaTeX-default-document-style "}\n"
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
288 "\\begin{document}")))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
289 (goto-char opoint)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
290 ;;(set-buffer buffer) ;for clarity
133
e117bfc8ce66 Do not activate any major-mode for texput.tex at typeset-region.
yuuji@gentei.org
parents: 130
diff changeset
291 (let ((hilit-auto-highlight nil) (auto-mode-alist nil)
e117bfc8ce66 Do not activate any major-mode for texput.tex at typeset-region.
yuuji@gentei.org
parents: 130
diff changeset
292 (magic-mode-alist nil)) ;Do not activate yatex-mode here
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
293 (set-buffer (find-file-noselect texput)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
294 ;;(find-file YaTeX-texput-file)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
295 (erase-buffer)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
296 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
297 (insert "\\nonstopmode{}\n"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
298 (insert preamble "\n" subpreamble "\n")
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
299 (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
300 (insert-buffer-substring buffer reg-begin reg-end)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
301 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
302 (insert "\n\\end{document}\n")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
303 (basic-save-buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
304 (kill-buffer (current-buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
305 (set-buffer main) ;return to parent file or itself.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
306 (YaTeX-typeset cmd YaTeX-typeset-buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
307 (switch-to-buffer buffer) ;for Emacs-19
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
308 (put 'dvi2-command 'region t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
309 (put 'dvi2-command 'file buffer)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
310 (put 'dvi2-command 'offset lineinfo))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
311
130
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
312 (defun YaTeX-typeset-environment ()
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
313 "Typeset current math environment"
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
314 (interactive)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
315 (save-excursion
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
316 (YaTeX-mark-environment)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
317 (YaTeX-typeset-region)))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 125
diff changeset
318
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
319 (defun YaTeX-typeset-buffer (&optional pp)
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
320 "Typeset whole buffer.
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
321 If %#! usage says other buffer is main text,
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
322 visit main buffer to confirm if its includeonly list contains current
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
323 buffer's file. And if it doesn't contain editing text, ask user which
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
324 action wants to be done, A:Add list, R:Replace list, %:comment-out list.
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
325 If optional argument PP given as string, PP is considered as post-process
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
326 command and call it with the same command argument as typesetter without
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
327 last extension.
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
328 eg. if PP is \"dvipdfmx\", called commands as follows.
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
329 platex foo.tex
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
330 dvipdfmx foo
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
331 PP command will be called iff typeset command exit successfully"
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
332 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
333 (YaTeX-save-buffers)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
334 (let*((me (substring (buffer-name) 0 (rindex (buffer-name) ?.)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
335 (mydir (file-name-directory (buffer-file-name)))
172
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
336 (cmd (YaTeX-get-latex-command t)) pparg ppcmd
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
337 (cb (current-buffer)))
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
338 (and pp
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
339 (stringp pp)
172
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
340 (setq pparg (substring cmd 0 (string-match "[;&]" cmd)) ;rm multistmt
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
341 pparg (substring pparg (rindex pparg ? )) ;get last arg
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
342 ppcmd (concat pp (substring pparg 0 (rindex pparg ?.)))));rm ext
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
343 (if (YaTeX-main-file-p) nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
344 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
345 (YaTeX-visit-main t) ;search into main buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
346 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
347 (push-mark (point) t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
348 (goto-char (point-min))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
349 (if (and (re-search-forward "^[ ]*\\\\begin{document}" nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
350 (re-search-backward "^[ ]*\\\\includeonly{" nil t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
351 (let*
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
352 ((b (progn (skip-chars-forward "^{") (point)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
353 (e (progn (skip-chars-forward "^}") (1+ (point))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
354 (s (buffer-substring b e)) c
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
355 (pardir (file-name-directory (buffer-file-name))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
356 (if (string-match (concat "[{,/]" me "[,}]") s)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
357 nil ; Nothing to do when it's already in includeonly.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
358 (ding)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
359 (switch-to-buffer (current-buffer));Display this buffer.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
360 (setq
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
361 me ;;Rewrite my name(me) to contain sub directory name.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
362 (concat
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
363 (if (string-match pardir mydir) ;if mydir is child of main
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
364 (substring mydir (length pardir)) ;cut absolute path
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
365 mydir) ;else concat absolute path name.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
366 me))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
367 (message
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
368 "`%s' is not in \\includeonly. A)dd R)eplace %%)comment? "
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
369 me)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
370 (setq c (read-char))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
371 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
372 ((= c ?a)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
373 (goto-char (1+ b))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
374 (insert me (if (string= s "{}") "" ",")))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
375 ((= c ?r)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
376 (delete-region (1+ b) (1- e)) (insert me))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
377 ((= c ?%)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
378 (beginning-of-line) (insert "%"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
379 (t nil))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
380 (basic-save-buffer))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
381 (exchange-point-and-mark)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
382 (switch-to-buffer cb)) ;for 19
123
590fc51462c7 New typeset menu `latex+p(D)f' added.
yuuji@gentei.org
parents: 122
diff changeset
383 (YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
384 (put 'dvi2-command 'region nil)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
385
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
386 (defvar YaTeX-call-command-history nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
387 "Holds history list of YaTeX-call-command-on-file.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
388 (put 'YaTeX-call-command-history 'no-default t)
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
389 (defun YaTeX-call-command-on-file (base-cmd buffer &optional file)
171
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
390 "Call external command BASE-CMD in the BUFFER.
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
391 By default, pass the basename of current file. Optional 3rd argument
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
392 FILE changes the default file name."
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
393 (YaTeX-save-buffers)
171
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
394 (let ((default (concat base-cmd " "
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
395 (let ((me (file-name-nondirectory
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
396 (or file buffer-file-name))))
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
397 (if (string-match "\\.tex" me)
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
398 (substring me 0 (match-beginning 0))
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
399 me)))))
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
400 (or YaTeX-call-command-history
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
401 (setq YaTeX-call-command-history (list default)))
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
402 (YaTeX-typeset
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
403 (read-string-with-history
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
404 "Call command: "
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
405 (car YaTeX-call-command-history)
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
406 'YaTeX-call-command-history)
670549efa5c2 YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents: 152
diff changeset
407 buffer)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
408
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
409 (defun YaTeX-bibtex-buffer (cmd)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
410 "Pass the bibliography data of editing file to bibtex."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
411 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
412 (YaTeX-save-buffers)
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
413 (let ((main (or YaTeX-parent-file
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
414 (progn (YaTeX-visit-main t) buffer-file-name))))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
415 (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" main)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
416
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
417 (defun YaTeX-kill-typeset-process (proc)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
418 "Kill process PROC after sending signal to PROC.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
419 PROC should be process identifier."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
420 (cond
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
421 ((not (fboundp 'start-process))
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
422 (error "This system can't have concurrent process."))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
423 ((or (null proc) (not (eq (process-status proc) 'run)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
424 (message "Typesetting process is not running."))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
425 (t
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
426 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
427 (set-buffer (process-buffer proc))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
428 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
429 (goto-char (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
430 (beginning-of-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
431 (if (looking-at "\\? +$")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
432 (let ((mp (point-max)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
433 (process-send-string proc "x\n")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
434 (while (= mp (point-max)) (sit-for 1))))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
435 (if (eq (process-status proc) 'run)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
436 (progn
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
437 (interrupt-process proc)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
438 (delete-process proc))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
439
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
440 (defun YaTeX-system (command buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
441 "Execute some command on buffer. Not a official function."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
442 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
443 (YaTeX-showup-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
444 buffer (function (lambda (x) (nth 3 (window-edges x)))))
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
445 (let ((df default-directory)) ;preserve current buf's pwd
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
446 (set-buffer (get-buffer-create buffer)) ;1.61.3
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
447 (setq default-directory df)
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
448 (cd df))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
449 (erase-buffer)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
450 (if (not (fboundp 'start-process))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
451 (call-process
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
452 shell-file-name nil buffer nil YaTeX-shell-command-option command)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
453 (if (and (get-buffer-process buffer)
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
454 (eq (process-status (get-buffer-process buffer)) 'run)
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
455 (not
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
456 (y-or-n-p (format "Process %s is running. Continue?" buffer))))
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
457 nil
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
458 (set-process-buffer
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
459 (start-process
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
460 "system" buffer shell-file-name YaTeX-shell-command-option command)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
461 (get-buffer buffer))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
462
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
463 (defvar YaTeX-default-paper-type "a4"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
464 "*Default paper type.")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
465 (defconst YaTeX-paper-type-alist
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
466 '(("a4paper" . "a4")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
467 ("a5paper" . "a5")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
468 ("b4paper" . "b4")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
469 ("b5paper" . "b5"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
470 "Holds map of options and paper types.")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
471 (defconst YaTeX-dvips-paper-option-alist
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
472 '(("a4" . "-t a4")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
473 ("a5" . "-t a5")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
474 ("b4" . "-t b4")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
475 ("b5" . "-t b5")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
476 ("a4r" . "-t landscape"); Can't specify options, `-t a4' and `-t landscape', at the same time.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
477 ("a5r" . "-t landscape")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
478 ("b4r" . "-t landscape")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
479 ("b5r" . "-t landscape"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
480 "Holds map of dvips options and paper types.")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
481 (defun YaTeX-get-paper-type ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
482 "Search options in header and return a paper type, such as \"a4\", \"a4r\", etc."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
483 (save-excursion
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
484 (YaTeX-visit-main t)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
485 (goto-char (point-min))
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
486 (let ((opts
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
487 (if (re-search-forward
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
488 "^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t)
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
489 (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*"))))
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
490 (concat
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
491 (catch 'found-paper
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
492 (mapcar (lambda (pair)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
493 (if (YaTeX-member (car pair) opts)
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
494 (throw 'found-paper (cdr pair))))
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
495 YaTeX-paper-type-alist)
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
496 YaTeX-default-paper-type)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
497 (if (YaTeX-member "landscape" opts) (if YaTeX-dos "L" "r") "")))))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
498
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
499 (defvar YaTeX-preview-command-history nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
500 "Holds minibuffer history of preview command.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
501 (put 'YaTeX-preview-command-history 'no-default t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
502 (defvar YaTeX-preview-file-history nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
503 "Holds minibuffer history of file to preview.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
504 (put 'YaTeX-preview-file-history 'no-default t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
505 (defun YaTeX-preview (preview-command preview-file)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
506 "Execute xdvi (or other) to tex-preview."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
507 (interactive
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
508 (let* ((command (read-string-with-history
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
509 "Preview command: "
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
510 (YaTeX-replace-format
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
511 (or (YaTeX-get-builtin "PREVIEW") dvi2-command)
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
512 "p" (format (cond
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
513 (YaTeX-dos "-y:%s")
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
514 (t "-paper %s"))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
515 (YaTeX-get-paper-type)))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
516 'YaTeX-preview-command-history))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
517 (file (read-string-with-history
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
518 "Preview file: "
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
519 (if (get 'dvi2-command 'region)
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
520 (substring YaTeX-texput-file
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
521 0 (rindex YaTeX-texput-file ?.))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
522 (YaTeX-get-preview-file-name command))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
523 'YaTeX-preview-file-history)))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
524 (list command file)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
525 (setq dvi2-command preview-command) ;`dvi2command' is buffer local
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
526 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
527 (YaTeX-visit-main t)
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
528 (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
529 (let ((pbuffer "*dvi-preview*") (dir default-directory))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
530 (YaTeX-showup-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
531 pbuffer (function (lambda (x) (nth 3 (window-edges x)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
532 (set-buffer (get-buffer-create pbuffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
533 (erase-buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
534 (setq default-directory dir) ;for 18
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
535 (cd dir) ;for 19
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
536 (cond
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
537 ((not (fboundp 'start-process)) ;if MS-DOS
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
538 (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
539 (call-process shell-file-name "con" "*dvi-preview*" nil
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
540 YaTeX-shell-command-option
61
b9f753846b6b Bug fix release
yuuji
parents: 60
diff changeset
541 (concat preview-command " " preview-file))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
542 (send-string-to-terminal "\e[>5l") ;show cursor
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
543 (redraw-display))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
544 ((and (string-match "dviout" preview-command) ;maybe on `kon'
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
545 (stringp (getenv "TERM"))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
546 (string-match "^kon" (getenv "TERM")))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
547 (call-process shell-file-name "con" "*dvi-preview*" nil
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
548 YaTeX-shell-command-option
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
549 (concat preview-command " " preview-file)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
550 (t ;if UNIX
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
551 (set-process-buffer
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
552 (let ((process-connection-type nil))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
553 (start-process "preview" "*dvi-preview*" shell-file-name
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
554 YaTeX-shell-command-option
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
555 (concat preview-command " " preview-file)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
556 (get-buffer pbuffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
557 (message
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
558 (concat "Starting " preview-command
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
559 " to preview " preview-file)))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
560
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
561 (defvar YaTeX-xdvi-remote-program "xdvi")
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
562 (defun YaTeX-xdvi-remote-search (&optional region-mode)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
563 "Search string at the point on xdvi -remote window.
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
564 Non-nil for optional argument REGION-MODE specifies the search string
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
565 by region."
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
566 (interactive "P")
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
567 (let ((pb " *xdvi*") str proc)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
568 (save-excursion
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
569 (if region-mode
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
570 (setq str (buffer-substring (region-beginning) (region-end)))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
571 (setq str (buffer-substring
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
572 (point)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
573 (progn (skip-chars-forward "^\n\\\\}") (point)))))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
574 (message "Searching `%s'..." str)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
575 (if (boundp 'MULE)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
576 (define-program-coding-system
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
577 (regexp-quote pb) (regexp-quote YaTeX-xdvi-remote-program)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
578 *euc-japan*))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
579 (setq proc
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
580 (start-process
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
581 "xdvi" pb YaTeX-xdvi-remote-program
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
582 "-remote" (format "SloppySearch(%s) " str)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
583 (concat (YaTeX-get-preview-file-name) ".dvi")))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
584 (message "Searching `%s'...Done" str))))
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 57
diff changeset
585
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
586 (defun YaTeX-set-virtual-error-position (file-sym line-sym)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
587 "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
588 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
589 ((and (get 'dvi2-command 'region)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
590 (> (symbol-value line-sym) (car (get 'dvi2-command 'offset))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
591 (set file-sym (get 'dvi2-command 'file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
592 (set line-sym
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
593 (+ (- (apply '- (get 'dvi2-command 'offset)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
594 (symbol-value line-sym)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
595 -1)))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
596
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
597 (defun YaTeX-prev-error ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
598 "Visit previous typeset error.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
599 To avoid making confliction of line numbers by editing, jump to
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
600 error or warning lines in reverse order."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
601 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
602 (let ((cur-buf (buffer-name)) (cur-win (selected-window))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
603 b0 errorp error-line typeset-win error-buffer error-win)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
604 (if (null (get-buffer YaTeX-typeset-buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
605 (error "There is no typesetting buffer."))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
606 (YaTeX-showup-buffer YaTeX-typeset-buffer nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
607 (setq typeset-win (selected-window))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
608 (if (re-search-backward
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
609 (concat "\\(" latex-error-regexp "\\)\\|\\("
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
610 latex-warning-regexp "\\)")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
611 nil t)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
612 (setq errorp (match-beginning 1))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
613 (select-window cur-win)
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
614 (error "No more errors on %s" cur-buf))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
615 (goto-char (setq b0 (match-beginning 0)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
616 (skip-chars-forward "^0-9" (match-end 0))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
617 (setq error-line
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
618 (string-to-int
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
619 (buffer-substring
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
620 (point)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
621 (progn (skip-chars-forward "0-9" (match-end 0)) (point))))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
622 error-buffer (expand-file-name (YaTeX-get-error-file cur-buf)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
623 (if (or (null error-line) (equal 0 error-line))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
624 (error "Can't detect error position."))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
625 (YaTeX-set-virtual-error-position 'error-buffer 'error-line)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
626 (setq error-win (get-buffer-window error-buffer))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
627 (select-window cur-win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
628 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
629 (error-win (select-window error-win))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
630 ((eq (get-lru-window) typeset-win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
631 (YaTeX-switch-to-buffer error-buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
632 (t (select-window (get-lru-window))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
633 (YaTeX-switch-to-buffer error-buffer)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
634 (setq error-win (selected-window))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
635 (goto-line error-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
636 (message "LaTeX %s in `%s' on line: %d."
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
637 (if errorp "error" "warning")
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
638 error-buffer error-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
639 (select-window typeset-win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
640 (skip-chars-backward "0-9")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
641 (recenter (/ (window-height) 2))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
642 (sit-for 1)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
643 (goto-char b0)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
644 (select-window error-win)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
645
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
646 (defun YaTeX-jump-error-line ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
647 "Jump to corresponding line on latex command's error message."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
648 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
649 (let (error-line error-file error-buf)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
650 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
651 (beginning-of-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
652 (setq error-line (re-search-forward "l[ ines]*\\.?\\([1-9][0-9]*\\)"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
653 (point-end-of-line) t)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
654 (if (null error-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
655 (if (eobp) (insert (this-command-keys))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
656 (error "No line number expression."))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
657 (goto-char (match-beginning 0))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
658 (setq error-line (string-to-int
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
659 (buffer-substring (match-beginning 1) (match-end 1)))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
660 error-file (expand-file-name
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
661 (YaTeX-get-error-file YaTeX-current-TeX-buffer)))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
662 (YaTeX-set-virtual-error-position 'error-file 'error-line)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
663 (setq error-buf (YaTeX-switch-to-buffer error-file t)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
664 (if (null error-buf)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
665 (error "`%s' is not found in this directory." error-file))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
666 (YaTeX-showup-buffer error-buf nil t)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
667 (goto-line error-line)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
668
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
669 (defun YaTeX-send-string ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
670 "Send string to current typeset process."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
671 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
672 (if (and (eq (process-status YaTeX-typeset-process) 'run)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
673 (>= (point) (process-mark YaTeX-typeset-process)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
674 (let ((b (process-mark YaTeX-typeset-process))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
675 (e (point-end-of-line)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
676 (goto-char b)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
677 (skip-chars-forward " \t" e)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
678 (setq b (point))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
679 (process-send-string
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
680 YaTeX-typeset-process (concat (buffer-substring b e) "\n"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
681 (goto-char e)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
682 (insert "\n")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
683 (set-marker (process-mark YaTeX-typeset-process) (point))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
684 (insert " "))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
685 (ding)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
686
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
687 (defun YaTeX-view-error ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
688 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
689 (if (null (get-buffer YaTeX-typeset-buffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
690 (message "No typeset buffer found.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
691 (let ((win (selected-window)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
692 (YaTeX-showup-buffer YaTeX-typeset-buffer nil t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
693 ;; Next 3 lines are obsolete because YaTeX-typesetting-buffer is
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
694 ;; automatically scrolled up at typesetting.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
695 ;;(goto-char (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
696 ;;(forward-line -1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
697 ;;(recenter -1)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
698 (select-window win))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
699
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
700 (defun YaTeX-get-error-file (default)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
701 "Get current processing file from typesetting log."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
702 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
703 (let(s)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
704 (condition-case () (up-list -1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
705 (error
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
706 (let ((list 0) found)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
707 (while
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
708 (and (<= list 0) (not found)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
709 (re-search-backward "\\((\\)\\|\\()\\)" nil t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
710 (if (equal (match-beginning 0) (match-beginning 2)) ;close paren.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
711 (setq list (1- list)) ;open paren
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
712 (setq list (1+ list))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
713 (if (= list 1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
714 (if (looking-at "\\([^,{}%]+\.\\)tex\\|sty")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
715 (setq found t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
716 (setq list (1- list)))))))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
717 (setq s
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
718 (buffer-substring
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
719 (progn (forward-char 1) (point))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
720 (progn (skip-chars-forward "^ \n" (point-end-of-line))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
721 (point))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
722 (if (string= "" s) default s))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
723
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
724 (defun YaTeX-put-nonstopmode ()
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
725 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
726 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
727 nil ;if already written in text then do nothing
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
728 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
729 (YaTeX-visit-main t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
730 (goto-char (point-min))
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
731 (insert "\\nonstopmode{}%_YaTeX_%\n")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
732 (if (buffer-file-name) (basic-save-buffer))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
733
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
734 (defun YaTeX-remove-nonstopmode ()
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
735 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
736 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
737 (YaTeX-visit-main t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
738 (goto-char (point-min))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
739 (forward-line 1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
740 (narrow-to-region (point-min) (point))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
741 (goto-char (point-min))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
742 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
743 (widen))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
744
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
745 (defvar YaTeX-dvi2-command-ext-alist
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
746 '(("[agx]dvi\\|dviout" . ".dvi")
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
747 ("ghostview\\|gv" . ".ps")
152
095a5c97ecac Add a pattern of "evince" for PDF viewer.
yuuji@gentei.org
parents: 148
diff changeset
748 ("acroread\\|pdf\\|Preview\\|TeXShop\\|Skim\\|evince" . ".pdf")))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
749
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
750 (defun YaTeX-get-preview-file-name (&optional preview-command)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
751 "Get file name to preview by inquiring YaTeX-get-latex-command"
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
752 (if (null preview-command) (setq preview-command dvi2-command))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
753 (let* ((latex-cmd (YaTeX-get-latex-command t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
754 (rin (rindex latex-cmd ? ))
172
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
755 (fname (if rin (substring latex-cmd (1+ rin)) ""))
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
756 (r (YaTeX-assoc-regexp preview-command YaTeX-dvi2-command-ext-alist))
172
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
757 (ext (if r (cdr r) "")))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
758 (concat
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
759 (if (string= fname "")
172
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
760 (setq fname (substring (file-name-nondirectory
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
761 (buffer-file-name))
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
762 0 -4))
429d10a0d5b2 YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents: 171
diff changeset
763 (setq fname (substring fname 0 (rindex fname ?.))))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
764 ext)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
765
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
766 (defun YaTeX-get-latex-command (&optional switch)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
767 "Specify the latex-command name and its argument.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
768 If there is a line which begins with string: \"%#!\", the following
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
769 strings are assumed to be the latex-command and arguments. The
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
770 default value of latex-command is:
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
771 tex-command FileName
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
772 and if you write \"%#!jlatex\" in the beginning of certain line.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
773 \"jlatex \" FileName
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
774 will be the latex-command,
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
775 and you write \"%#!jlatex main.tex\" on some line and argument SWITCH
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
776 is non-nil, then
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
777 \"jlatex main.tex\"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
778
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
779 will be given to the shell."
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
780 (let (parent tparent magic)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
781 (setq parent
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
782 (cond
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
783 (YaTeX-parent-file
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
784 (if YaTeX-dos (expand-file-name YaTeX-parent-file)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
785 YaTeX-parent-file))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
786 (t (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
787 (YaTeX-visit-main t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
788 (file-name-nondirectory (buffer-file-name)))))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
789 magic (YaTeX-get-builtin "!")
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
790 tparent (file-name-nondirectory parent))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
791 (YaTeX-replace-formats
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
792 (cond
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
793 (magic
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
794 (cond
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
795 (switch (if (string-match "\\s " magic) magic
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
796 (concat magic " " parent)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
797 (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
798 (t (concat tex-command " " (if switch parent))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
799 (list (cons "f" tparent)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
800 (cons "r" (substring tparent 0 (rindex tparent ?.)))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
801
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
802 (defvar YaTeX-lpr-command-history nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
803 "Holds command line history of YaTeX-lpr.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
804 (put 'YaTeX-lpr-command-history 'no-default t)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
805 (defvar YaTeX-lpr-ask-page-range-default t)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
806 (defun YaTeX-lpr (arg)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
807 "Print out.
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
808 If prefix arg ARG is non nil, call print driver without
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
809 page range description."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
810 (interactive "P")
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
811 (or YaTeX-lpr-ask-page-range-default (setq arg (not arg)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
812 (let*((cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
813 from to (lbuffer "*dvi-printing*") dir)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
814 (setq
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
815 cmd
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
816 (YaTeX-replace-format
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
817 cmd "f"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
818 (if (or arg (not (string-match "%f" cmd)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
819 ""
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
820 (YaTeX-replace-format
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
821 dviprint-from-format
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
822 "b"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
823 (if (string=
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
824 (setq from (read-string "From page(default 1): ")) "")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
825 "1" from))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
826 )
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
827 (setq
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
828 cmd
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
829 (YaTeX-replace-format
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
830 cmd "t"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
831 (if (or arg (not (string-match "%t" cmd))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
832 (string=
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
833 (setq to (read-string "To page(default none): ")) ""))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
834 ""
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
835 (YaTeX-replace-format dviprint-to-format "e" to)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
836 )
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
837 (setq
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
838 cmd
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
839 (YaTeX-replace-format
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
840 cmd "p"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
841 (cdr (assoc (YaTeX-get-paper-type) YaTeX-dvips-paper-option-alist))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
842 (setq cmd
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
843 (read-string-with-history
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
844 "Edit command line: "
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
845 (format cmd
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
846 (if (get 'dvi2-command 'region)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
847 (substring YaTeX-texput-file
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
848 0 (rindex YaTeX-texput-file ?.))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
849 (YaTeX-get-preview-file-name)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
850 'YaTeX-lpr-command-history))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
851 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
852 (YaTeX-visit-main t) ;;change execution directory
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
853 (setq dir default-directory)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
854 (YaTeX-showup-buffer
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
855 lbuffer (function (lambda (x) (nth 3 (window-edges x)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
856 (set-buffer (get-buffer-create lbuffer))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
857 (erase-buffer)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
858 (cd dir) ;for 19
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
859 (cond
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 61
diff changeset
860 ((not (fboundp 'start-process))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
861 (call-process shell-file-name "con" "*dvi-printing*" nil
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
862 YaTeX-shell-command-option cmd))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
863 (t
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
864 (set-process-buffer
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
865 (let ((process-connection-type nil))
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
866 (start-process "print" "*dvi-printing*" shell-file-name
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
867 YaTeX-shell-command-option cmd))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
868 (get-buffer lbuffer))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
869 (message "Starting printing command: %s..." cmd))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
870
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
871 (defun YaTeX-main-file-p ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
872 "Return if current buffer is main LaTeX source."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
873 (cond
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
874 (YaTeX-parent-file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
875 (eq (get-file-buffer YaTeX-parent-file) (current-buffer)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
876 ((YaTeX-get-builtin "!")
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
877 (string-match
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
878 (concat "^" (YaTeX-guess-parent (YaTeX-get-builtin "!")))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
879 (buffer-name)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
880 (t
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
881 (save-excursion
57
18f4939986e6 (j)LaTeX2e supported
yuuji
parents: 53
diff changeset
882 (let ((latex-main-id
18f4939986e6 (j)LaTeX2e supported
yuuji
parents: 53
diff changeset
883 (concat "^\\s *" YaTeX-ec-regexp "document\\(style\\|class\\)")))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
884 (or (re-search-backward latex-main-id nil t)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
885 (re-search-forward latex-main-id nil t)))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
886
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
887 (defun YaTeX-visit-main (&optional setbuf)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
888 "Switch buffer to main LaTeX source.
122
57d3d9abd661 Search %# built-in value for parent if not found in current buffer.
yuuji@gentei.org
parents: 88
diff changeset
889 Use set-buffer instead of switch-to-buffer if the optional argument
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
890 SETBUF is t(Use it only from Emacs-Lisp program)."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
891 (interactive "P")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
892 (if (and (interactive-p) setbuf) (setq YaTeX-parent-file nil))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
893 (let ((ff (function (lambda (f)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
894 (if setbuf (set-buffer (find-file-noselect f))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
895 (find-file f)))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
896 b-in main-file YaTeX-create-file-prefix-g
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
897 (hilit-auto-highlight (not setbuf)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
898 (if (setq b-in (YaTeX-get-builtin "!"))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
899 (setq main-file (YaTeX-guess-parent b-in)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
900 (if YaTeX-parent-file
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
901 (setq main-file ;;(get-file-buffer YaTeX-parent-file)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
902 YaTeX-parent-file))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
903 (if (YaTeX-main-file-p)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
904 (if (interactive-p) (message "I think this is main LaTeX source.") nil)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
905 (cond
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
906 ((and ;;(interactive-p)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
907 main-file
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
908 (cond ((get-file-buffer main-file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
909 (cond
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
910 (setbuf (set-buffer (get-file-buffer main-file)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
911 ((get-buffer-window (get-file-buffer main-file))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
912 (select-window
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
913 (get-buffer-window (get-file-buffer main-file))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
914 (t (switch-to-buffer (get-file-buffer main-file)))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
915 ((file-exists-p main-file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
916 (funcall ff main-file)))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
917 ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
918 ((and main-file
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
919 (file-exists-p (setq main-file (concat "../" main-file)))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
920 (or b-in
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
921 (y-or-n-p (concat (expand-file-name main-file)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
922 " is main file?:"))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
923 (setq YaTeX-parent-file main-file)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
924 ;(YaTeX-switch-to-buffer main-file setbuf)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
925 (funcall ff main-file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
926 )
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
927 (t (setq main-file (read-file-name "Enter your main text: " nil nil 1))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
928 (setq YaTeX-parent-file main-file)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
929 ; (YaTeX-switch-to-buffer main-file setbuf))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
930 (funcall ff main-file))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
931 )))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
932 nil)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
933
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
934 (defun YaTeX-guess-parent (command-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
935 (setq command-line
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
936 (if (string-match ".*\\s " command-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
937 (substring command-line (match-end 0))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
938 (file-name-nondirectory (buffer-file-name)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
939 command-line
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
940 (concat (if (string-match "\\(.*\\)\\." command-line)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
941 (substring command-line (match-beginning 1) (match-end 1))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
942 command-line)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
943 ".tex")))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
944
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
945 (defun YaTeX-visit-main-other-window ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
946 "Switch to buffer main LaTeX source in other window."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
947 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
948 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
949 (YaTeX-switch-to-buffer-other-window
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
950 (concat (YaTeX-get-preview-file-name) ".tex"))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
951
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
952 (defun YaTeX-save-buffers ()
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
953 "Save buffers whose major-mode is equal to current major-mode."
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
954 (basic-save-buffer)
60
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
955 (let ((cmm major-mode))
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
956 (save-excursion
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
957 (mapcar '(lambda (buf)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
958 (set-buffer buf)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
959 (if (and (buffer-file-name buf)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
960 (eq major-mode cmm)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
961 (buffer-modified-p buf)
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
962 (y-or-n-p (format "Save %s" (buffer-name buf))))
9e08ed569d80 yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents: 59
diff changeset
963 (save-buffer buf)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
964 (buffer-list)))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
965
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
966 (provide 'yatexprc)

yatex.org