annotate yatexprc.el @ 230:7f4a5db88fbb dev

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

yatex.org