Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexprc.el @ 436:e78a87bc2c9e dev
current file treated as absolute path(YaTeX-preview-jump-line)
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 08 Jan 2016 08:18:54 +0859 |
parents | 5cce749f9bbb |
children | 7a9d30752353 |
rev | line source |
---|---|
395 | 1 ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*- |
287 | 2 ;;; |
384
e95ae850eefb
Update copyright lines and so on.
HIROSE Yuuji <yuuji@gentei.org>
parents:
381
diff
changeset
|
3 ;;; (c)1993-2015 by HIROSE Yuuji.[yuuji@yatex.org] |
436
e78a87bc2c9e
current file treated as absolute path(YaTeX-preview-jump-line)
HIROSE Yuuji <yuuji@gentei.org>
parents:
431
diff
changeset
|
4 ;;; Last modified Fri Jan 8 08:18:14 2016 on firestorm |
367 | 5 ;;; $Id$ |
51 | 6 |
287 | 7 ;;; Code: |
64 | 8 ;(require 'yatex) |
9 (require 'yatexlib) | |
51 | 10 |
11 (defvar YaTeX-typeset-process nil | |
388 | 12 "Process identifier for latex") |
69 | 13 |
51 | 14 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*" |
388 | 15 "Process buffer for latex") |
51 | 16 |
17 (defvar YaTeX-typeset-buffer-syntax nil | |
18 "*Syntax table for typesetting buffer") | |
19 | |
20 (defvar YaTeX-current-TeX-buffer nil | |
21 "Keeps the buffer on which recently typeset run.") | |
22 | |
23 (defvar YaTeX-shell-command-option | |
24 (or (and (boundp 'shell-command-option) shell-command-option) | |
68 | 25 (and (boundp 'shell-command-switch) shell-command-switch) |
51 | 26 (if YaTeX-dos "/c" "-c")) |
27 "Shell option for command execution.") | |
28 | |
64 | 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 | 39 (cond |
80 | 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 | 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 | 48 "Process coding system for LaTeX.") |
49 | |
51 | 50 (if YaTeX-typeset-buffer-syntax nil |
51 (setq YaTeX-typeset-buffer-syntax | |
52 (make-syntax-table (standard-syntax-table))) | |
53 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax) | |
54 (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax) | |
55 (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax) | |
69 | 56 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax)) |
51 | 57 |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
58 (defvar YaTeX-typeset-marker nil) |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
59 (defvar YaTeX-typeset-consumption nil) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
60 (make-variable-buffer-local 'YaTeX-typeset-consumption) |
213 | 61 (defun YaTeX-typeset (command buffer &optional prcname modename ppcmd) |
388 | 62 "Execute latex command (or other) to LaTeX typeset." |
51 | 63 (interactive) |
64 (save-excursion | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
65 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer)) |
64 | 66 (map YaTeX-typesetting-mode-map) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
67 (background (string-match "\\*bg:" buffer)) |
64 | 68 (outcode |
69 (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system) | |
69 | 70 ((eq major-mode 'yahtml-mode) yahtml-kanji-code)))) |
51 | 71 (if (and YaTeX-typeset-process |
72 (eq (process-status YaTeX-typeset-process) 'run)) | |
73 ;; if tex command is halting. | |
74 (YaTeX-kill-typeset-process YaTeX-typeset-process)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
75 (YaTeX-put-nonstopmode) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
76 (setq prcname (or prcname "LaTeX") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
77 modename (or modename "typeset")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
78 (if (eq major-mode 'yatex-mode) (YaTeX-visit-main t)) ;;execution dir |
51 | 79 (setq execdir default-directory) |
80 ;;Select lower-most window if there are more than 2 windows and | |
81 ;;typeset buffer not seen. | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
82 (if background |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
83 nil ;do not showup |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
84 (YaTeX-showup-buffer |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
85 buffer 'YaTeX-showup-buffer-bottom-most)) |
51 | 86 (set-buffer (get-buffer-create buffer)) |
87 (setq default-directory execdir) | |
88 (cd execdir) | |
213 | 89 (erase-buffer) |
51 | 90 (cond |
64 | 91 ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS |
51 | 92 (call-process |
64 | 93 shell-file-name nil buffer nil YaTeX-shell-command-option command)) |
51 | 94 (t ;if UNIX |
95 (set-process-buffer | |
96 (setq YaTeX-typeset-process | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
97 (start-process prcname buffer shell-file-name |
51 | 98 YaTeX-shell-command-option command)) |
99 (get-buffer buffer)) | |
123 | 100 (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
|
101 (put 'YaTeX-typeset-process 'thiscmd command) |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
102 (put 'YaTeX-typeset-process 'name prcname) |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
103 (if (fboundp 'current-time) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
104 (setq YaTeX-typeset-consumption |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
105 (cons (cons 'time (current-time)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
106 (delq 'time YaTeX-typeset-consumption)))) |
123 | 107 (let ((ppprop (get 'YaTeX-typeset-process 'ppcmd))) |
108 (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop)) | |
109 (if ppcmd | |
110 (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
|
111 (put 'YaTeX-typeset-process 'ppcmd ppprop)) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
112 (if (and (boundp 'bibcmd) bibcmd) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
113 (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
|
114 (setq bcprop (cons |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
115 (cons YaTeX-typeset-process bibcmd) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
116 (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
|
117 (put 'YaTeX-typeset-process 'bibcmd bcprop))))) |
51 | 118 (message (format "Calling `%s'..." command)) |
119 (setq YaTeX-current-TeX-buffer (buffer-name)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
120 (use-local-map map) ;map may be localized |
51 | 121 (set-syntax-table YaTeX-typeset-buffer-syntax) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
122 (setq mode-name modename) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
123 (if YaTeX-typeset-process ;if process is running (maybe on UNIX) |
64 | 124 (cond ((fboundp 'set-current-process-coding-system) |
51 | 125 (set-current-process-coding-system |
64 | 126 YaTeX-latex-message-code outcode)) |
127 ((fboundp 'set-process-coding-system) | |
128 (set-process-coding-system | |
129 YaTeX-typeset-process YaTeX-latex-message-code outcode)) | |
130 (YaTeX-emacs-20 | |
131 (set-buffer-process-coding-system | |
132 YaTeX-latex-message-code outcode)) | |
51 | 133 ((boundp 'NEMACS) |
134 (set-kanji-process-code YaTeX-latex-message-code)))) | |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
135 (set-marker (or YaTeX-typeset-marker |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
136 (setq YaTeX-typeset-marker (make-marker))) |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
137 (point)) |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
138 (insert (format "Call `%s'\n" command)) |
370
037f8d4c3c70
Use 'start-process existence instead of YaTeX-dos.
HIROSE Yuuji <yuuji@gentei.org>
parents:
369
diff
changeset
|
139 (cond |
037f8d4c3c70
Use 'start-process existence instead of YaTeX-dos.
HIROSE Yuuji <yuuji@gentei.org>
parents:
369
diff
changeset
|
140 ((fboundp 'start-process) |
51 | 141 (insert " ") |
142 (set-marker (process-mark YaTeX-typeset-process) (1- (point)))) | |
370
037f8d4c3c70
Use 'start-process existence instead of YaTeX-dos.
HIROSE Yuuji <yuuji@gentei.org>
parents:
369
diff
changeset
|
143 (t (message "Done."))) |
51 | 144 (if (bolp) (forward-line -1)) ;what for? |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
145 (cond |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
146 (background nil) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
147 ((and YaTeX-emacs-19 window-system) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
148 (let ((win (get-buffer-window buffer t)) owin) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
149 (select-frame (window-frame win)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
150 (setq owin (selected-window)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
151 (select-window win) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
152 (goto-char (point-max)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
153 (recenter -1) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
154 (select-window owin))) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
155 (t (select-window (get-buffer-window buffer)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
156 (goto-char (point-max)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
157 (recenter -1))) |
51 | 158 (select-window window) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
159 (switch-to-buffer cb) |
69 | 160 (YaTeX-remove-nonstopmode)))) |
51 | 161 |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
162 (defvar YaTeX-typeset-auto-rerun t |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
163 "*Non-nil automatically reruns typesetter when cross-refs update found. |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
164 This is a toy mechanism. DO NOT RELY ON THIS MECHANISM. |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
165 You SHOULD check the integrity of cross-references with your eyes!! |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
166 Supplying an integer to this variable inhibit compulsory call of bibtex, |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
167 thus, it call bibtex only if warning messages about citation are seen.") |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
168 (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
|
169 (defvar YaTeX-typeset-citation-msg |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
170 "Warning: Citation \`") |
51 | 171 (defun YaTeX-typeset-sentinel (proc mes) |
172 (cond ((null (buffer-name (process-buffer proc))) | |
173 ;; buffer killed | |
174 (set-process-buffer proc nil)) | |
175 ((memq (process-status proc) '(signal exit)) | |
176 (let* ((obuf (current-buffer)) (pbuf (process-buffer proc)) | |
177 (pwin (get-buffer-window pbuf)) | |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
178 (owin (selected-window)) win |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
179 tobecalled shortname |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
180 (thiscmd (get 'YaTeX-typeset-process 'thiscmd)) |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
181 (ppprop (get 'YaTeX-typeset-process 'ppcmd)) |
399
33bde8c52fcc
Fix message and remove trash
HIROSE Yuuji <yuuji@gentei.org>
parents:
395
diff
changeset
|
182 (ppcmd (cdr (assq proc ppprop))) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
183 (bcprop (get 'YaTeX-typeset-process 'bibcmd)) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
184 (bibcmd (cdr (assq proc bcprop)))) |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
185 (put 'YaTeX-typeset-process 'ppcmd ;erase ppcmd |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
186 (delq (assq proc ppprop) ppprop)) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
187 (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
|
188 (delq (assq proc bcprop) bcprop)) |
51 | 189 ;; save-excursion isn't the right thing if |
190 ;; process-buffer is current-buffer | |
191 (unwind-protect | |
192 (progn | |
193 ;; Write something in *typesetting* and hack its mode line | |
194 (if pwin | |
195 (select-window pwin) | |
196 (set-buffer pbuf)) | |
197 ;;(YaTeX-showup-buffer pbuf nil t) | |
198 (goto-char (point-max)) | |
199 (if pwin (recenter -3)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
200 (insert ?\n mode-name " " mes) |
51 | 201 (forward-char -1) |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
202 (insert |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
203 (format " at %s%s\n" |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
204 (substring (current-time-string) 0 -5) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
205 (if (and (fboundp 'current-time) (fboundp 'float) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
206 (assq 'time YaTeX-typeset-consumption)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
207 (format |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
208 " (%.2f secs)" |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
209 (YaTeX-elapsed-time |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
210 (cdr (assq 'time YaTeX-typeset-consumption)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
211 (current-time)))))) |
51 | 212 (setq mode-line-process |
213 (concat ": " | |
214 (symbol-name (process-status proc)))) | |
256
b1e70dc23208
Clarify messages for typesetting process.
HIROSE Yuuji <yuuji@gentei.org>
parents:
230
diff
changeset
|
215 (message "%s %s" mode-name |
51 | 216 (if (eq (process-status proc) 'exit) |
217 "done" "ceased")) | |
218 ;; If buffer and mode line shows that the process | |
219 ;; is dead, we can delete it now. Otherwise it | |
220 ;; will stay around until M-x list-processes. | |
221 (delete-process proc) | |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
222 (if (cond |
263
808f532d68d3
Inhibit auto-rerun of bibtex when using latexmk.
HIROSE Yuuji <yuuji@gentei.org>
parents:
262
diff
changeset
|
223 ((or (not YaTeX-typeset-auto-rerun) |
808f532d68d3
Inhibit auto-rerun of bibtex when using latexmk.
HIROSE Yuuji <yuuji@gentei.org>
parents:
262
diff
changeset
|
224 (string-match "latexmk" thiscmd)) |
808f532d68d3
Inhibit auto-rerun of bibtex when using latexmk.
HIROSE Yuuji <yuuji@gentei.org>
parents:
262
diff
changeset
|
225 nil) |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
226 ((and bibcmd ;Call bibtex if bibcmd defined && |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
227 (or ; (1st call || warning found) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
228 (and (not (numberp YaTeX-typeset-auto-rerun)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
229 ; cancel call at 1st, if value is a number. |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
230 (not (string-match "bibtex" mode-name))) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
231 (re-search-backward |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
232 YaTeX-typeset-citation-msg |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
233 YaTeX-typeset-marker t)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
234 (save-excursion ; && using .bbl files. |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
235 (search-backward |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
236 ".bbl" YaTeX-typeset-marker t))) |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
237 ;; Always call bibtex after the first typesetting, |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
238 ;; because bibtex doesn't warn disappeared \cite. |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
239 ;; (Suggested by ryseto. 2012) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
240 ;; It is more efficient to call bibtex directly than |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
241 ;; to call it after deep inspection on the balance |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
242 ;; of \cite vs. \bib*'s referring all *.aux files. |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
243 (insert "\n" YaTeX-typeset-rerun-msg "\n") |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
244 (setq tobecalled bibcmd shortname "+bibtex")) |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
245 ((or |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
246 (save-excursion |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
247 (search-backward |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
248 YaTeX-typeset-rerun-msg YaTeX-typeset-marker t)) |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
249 (save-excursion |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
250 (re-search-backward |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
251 "natbib.*Rerun to get citations correct" |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
252 YaTeX-typeset-marker t))) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
253 (if bibcmd |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
254 (put 'YaTeX-typeset-process 'bibcmd |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
255 (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
|
256 bcprop))) |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
257 (setq tobecalled thiscmd shortname "+typeset")) |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
258 (t |
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
259 nil)) ;no need to call any process |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
260 (progn ;;Something occurs to call next command |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
261 (insert |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
262 (format |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
263 "===!!! %s !!!===\n" |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
264 (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
|
265 tobecalled))) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
266 (if (equal tobecalled thiscmd) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
267 (set-marker YaTeX-typeset-marker (point))) |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
268 (set-process-sentinel |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
269 (start-process |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
270 (setq mode-name (concat mode-name shortname)) |
256
b1e70dc23208
Clarify messages for typesetting process.
HIROSE Yuuji <yuuji@gentei.org>
parents:
230
diff
changeset
|
271 pbuf |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
272 shell-file-name YaTeX-shell-command-option tobecalled) |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
273 'YaTeX-typeset-sentinel) |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
274 (if ppcmd |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
275 (put 'YaTeX-typeset-process 'ppcmd |
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
276 (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
|
277 ppprop))) |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
278 (if thiscmd |
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
279 (put 'YaTeX-typeset-process 'thiscmd thiscmd))) |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
280 ;; If ppcmd is active, call it. |
123 | 281 (cond |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
282 ((and ppcmd (symbolp ppcmd) (fboundp ppcmd)) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
283 ;; If ppcmd is set and it is a function symbol, |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
284 ;; call it whenever command succeeded or not |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
285 (funcall ppcmd)) |
123 | 286 ((and ppcmd (string-match "finish" mes)) |
287 (insert (format "=======> Success! Calling %s\n" ppcmd)) | |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
288 (setq mode-name ; set process name |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
289 (concat |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
290 mode-name "+" |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
291 (substring ppcmd 0 (string-match " " ppcmd)))) |
212
c63a4ec6a492
Rerun typesetter when cross-reference warning seen.
yuuji@gentei.org
parents:
195
diff
changeset
|
292 ; to reach here, 'start-process exists on this emacsen |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
293 (set-process-sentinel |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
294 (start-process |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
295 mode-name |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
296 pbuf ; Use this buffer twice. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
297 shell-file-name YaTeX-shell-command-option |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
298 ppcmd) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
299 'YaTeX-typeset-sentinel)) |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
300 (t |
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
301 (if (equal 0 (process-exit-status proc)) |
408
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
302 ;; Successful typesetting done |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
303 (if (save-excursion |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
304 (re-search-backward |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
305 (concat |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
306 "^Output written on .*\\.pdf (.*page," |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
307 "\\|\\.dvi -> .*\\.pdf$") |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
308 nil t)) |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
309 ;; If PDF output log found in buffer, |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
310 ;; set next default previewer to 'pdf viewer |
2857cac50a67
When PDF output seems to occur in typesetter, use pdf-viewer in [prefix] t p.
HIROSE Yuuji <yuuji@gentei.org>
parents:
406
diff
changeset
|
311 (put 'dvi2-command 'format 'pdf)) |
378
9452537530ac
Process exit status handler fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
377
diff
changeset
|
312 ;;Confirm process buffer to be shown when error |
9452537530ac
Process exit status handler fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
377
diff
changeset
|
313 (YaTeX-showup-buffer |
9452537530ac
Process exit status handler fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
377
diff
changeset
|
314 pbuf 'YaTeX-showup-buffer-bottom-most) |
9452537530ac
Process exit status handler fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
377
diff
changeset
|
315 (message "Command FAILED!")) |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
316 ;;pull back original mode-name |
261
8c555014f933
Auto-rerun supports natbib.
HIROSE Yuuji <yuuji@gentei.org>
parents:
260
diff
changeset
|
317 (setq mode-name "typeset")))) |
123 | 318 (forward-char 1)) |
319 (setq YaTeX-typeset-process nil) | |
51 | 320 ;; Force mode line redisplay soon |
321 (set-buffer-modified-p (buffer-modified-p)) | |
322 ) | |
323 (select-window owin) | |
69 | 324 (set-buffer obuf))))) |
51 | 325 |
326 (defvar YaTeX-texput-file "texput.tex" | |
69 | 327 "*File name for temporary file of typeset-region.") |
51 | 328 |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
329 (defun YaTeX-typeset-region (&optional pp) |
52 | 330 "Paste the region to the file `texput.tex' and execute typesetter. |
331 The region is specified by the rule: | |
51 | 332 (1)If keyword `%#BEGIN' is found in the upper direction from (point). |
333 (1-1)if the keyword `%#END' is found after `%#BEGIN', | |
334 ->Assume the text between `%#BEGIN' and `%#END' as region. | |
335 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN', | |
336 ->Assume the text after `%#BEGIN' as region. | |
337 (2)If no `%#BEGIN' usage is found before the (point), | |
338 ->Assume the text between current (point) and (mark) as region. | |
339 DON'T forget to eliminate the `%#BEGIN/%#END' notation after editing | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
340 operation to the region. |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
341 Optional second argument PP specifies post-processor command which will be |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
342 called with one argument of current file name whitout extension." |
51 | 343 (interactive) |
344 (save-excursion | |
345 (let* | |
346 ((end "") typeout ;Type out message that tells the method of cutting. | |
347 (texput YaTeX-texput-file) | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
348 (texputroot (substring texput 0 (string-match "\\.tex$" texput))) |
51 | 349 (cmd (concat (YaTeX-get-latex-command nil) " " texput)) |
350 (buffer (current-buffer)) opoint preamble (subpreamble "") main | |
351 (hilit-auto-highlight nil) ;for Emacs19 with hilit19 | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
352 ppcmd |
52 | 353 reg-begin reg-end lineinfo) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
354 (setq ppcmd (if (stringp pp) (concat pp " " texputroot) pp)) |
51 | 355 (save-excursion |
356 (if (search-backward "%#BEGIN" nil t) | |
357 (progn | |
358 (setq typeout "--- Region from BEGIN to " | |
359 end "the end of the buffer ---" | |
360 reg-begin (match-end 0)) | |
361 (if (search-forward "%#END" nil t) | |
362 (setq reg-end (match-beginning 0) | |
363 end "END ---") | |
364 (setq reg-end (point-max)))) | |
52 | 365 (setq typeout "=== Region from (point) to (mark) ===" |
366 reg-begin (point) reg-end (mark))) | |
367 (goto-char (min reg-begin reg-end)) | |
368 (setq lineinfo (count-lines (point-min) (point-end-of-line))) | |
51 | 369 (goto-char (point-min)) |
370 (while (search-forward "%#REQUIRE" nil t) | |
371 (setq subpreamble | |
372 (concat subpreamble | |
373 (cond | |
374 ((eolp) | |
375 (buffer-substring | |
376 (match-beginning 0) | |
377 (point-beginning-of-line))) | |
378 (t (buffer-substring | |
379 (match-end 0) | |
380 (point-end-of-line)))) | |
381 "\n")) | |
382 (goto-char (match-end 0)))) | |
383 (YaTeX-visit-main t) | |
384 (setq main (current-buffer)) | |
385 (setq opoint (point)) | |
386 (goto-char (point-min)) | |
387 (setq | |
388 preamble | |
389 (if (re-search-forward "^[ ]*\\\\begin.*{document}" nil t) | |
390 (buffer-substring (point-min) (match-end 0)) | |
73 | 391 (concat |
392 (if YaTeX-use-LaTeX2e "\\documentclass{" "\\documentstyle{") | |
393 YaTeX-default-document-style "}\n" | |
394 "\\begin{document}"))) | |
51 | 395 (goto-char opoint) |
396 ;;(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
|
397 (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
|
398 (magic-mode-alist nil)) ;Do not activate yatex-mode here |
52 | 399 (set-buffer (find-file-noselect texput))) |
51 | 400 ;;(find-file YaTeX-texput-file) |
401 (erase-buffer) | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
402 (YaTeX-set-file-coding-system YaTeX-kanji-code YaTeX-coding-system) |
64 | 403 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) |
51 | 404 (insert "\\nonstopmode{}\n")) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
405 (insert preamble "\n" subpreamble "\n" |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
406 "\\pagestyle{empty}\n\\thispagestyle{empty}\n") |
52 | 407 (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo)) |
51 | 408 (insert-buffer-substring buffer reg-begin reg-end) |
409 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method. | |
410 (insert "\n\\end{document}\n") | |
411 (basic-save-buffer) | |
412 (kill-buffer (current-buffer)) | |
413 (set-buffer main) ;return to parent file or itself. | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
414 (YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd) |
51 | 415 (switch-to-buffer buffer) ;for Emacs-19 |
52 | 416 (put 'dvi2-command 'region t) |
417 (put 'dvi2-command 'file buffer) | |
69 | 418 (put 'dvi2-command 'offset lineinfo)))) |
51 | 419 |
381
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
420 (defvar YaTeX-use-image-preview "png" |
376
1bbd0c2b340f
When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents:
375
diff
changeset
|
421 "*Nil means not using image preview by [prefix] t e. |
1bbd0c2b340f
When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents:
375
diff
changeset
|
422 Acceptable value is one of \"jpg\" or \"png\", which specifies |
381
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
423 format of preview image. NOTE that if your system has /usr/bin/sips |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
424 while not having convert(ImageMagick), jpeg format is automatically taken |
381
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
425 for conversion.") |
355
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
426 (defvar YaTeX-preview-image-mode-map nil |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
427 "Keymap used in YaTeX-preview-image-mode") |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
428 (defun YaTeX-preview-image-mode () |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
429 (interactive) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
430 (if YaTeX-preview-image-mode-map |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
431 nil |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
432 (let ((map (setq YaTeX-preview-image-mode-map (make-sparse-keymap)))) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
433 (define-key map "q" (lambda()(interactive) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
434 (kill-buffer) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
435 (select-window |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
436 (or (get 'YaTeX-typeset-process 'win) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
437 (selected-window))))) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
438 (define-key map "j" (lambda()(interactive) (scroll-up 1))) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
439 (define-key map "k" (lambda()(interactive) (scroll-up -1))))) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
440 (use-local-map YaTeX-preview-image-mode-map)) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
441 |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
442 (defvar YaTeX-typeset-pdf2image-chain |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
443 (cond |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
444 ((YaTeX-executable-find "pdfcrop") ;Mac OS X |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
445 (list |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
446 "pdfcrop --clip %b.pdf tmp.pdf" |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
447 (if (YaTeX-executable-find "convert") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
448 "convert -density %d tmp.pdf %b.%f" |
381
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
449 ;; If we use sips, specify jpeg as format |
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
450 "sips -s format jpeg -s dpiWidth %d -s dpiHeight %d %b.pdf --out %b.jpg") |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
451 "rm -f tmp.pdf"))) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
452 "*Pipe line of command as a list to create image file from PDF. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
453 See also doc-string of YaTeX-typeset-dvi2image-chain.") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
454 |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
455 (defvar YaTeX-typeset-dvi2image-chain |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
456 (cond |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
457 ((YaTeX-executable-find YaTeX-cmd-dvips) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
458 (list |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
459 (format "%s -E -o %%b.eps %%b.dvi" YaTeX-cmd-dvips) |
381
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
460 "convert -alpha off -density %d %b.eps %b.%f")) |
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
461 ((and (equal YaTeX-use-image-preview "png") |
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
462 (YaTeX-executable-find "dvipng")) |
fc1ad3b337a9
Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents:
380
diff
changeset
|
463 (list "dvipng %b.dvi"))) |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
464 "*Pipe line of command as a list to create png file from DVI or PDF. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
465 %-notation rewritten list: |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
466 %b basename of target file(\"texput\") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
467 %f Output format(\"png\") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
468 %d DPI |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
469 ") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
470 |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
471 (defvar YaTeX-typeset-conv2image-chain-alist |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
472 (list (cons 'pdf YaTeX-typeset-pdf2image-chain) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
473 (cons 'dvi YaTeX-typeset-dvi2image-chain)) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
474 "Default alist for creating image files from DVI/PDF. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
475 The value is generated from YaTeX-typeset-pdf2image-chain and |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
476 YaTeX-typeset-dvi2image-chain.") |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
477 |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
478 (defvar YaTeX-typeset-conv2image-process nil "Process of conv2image chain") |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
479 (defun YaTeX-typeset-conv2image-chain () |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
480 (let*((proc (or YaTeX-typeset-process YaTeX-typeset-conv2image-process)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
481 (prevname (process-name proc)) |
376
1bbd0c2b340f
When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents:
375
diff
changeset
|
482 (texput "texput") |
1bbd0c2b340f
When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents:
375
diff
changeset
|
483 (format YaTeX-use-image-preview) |
374
9b3093c0c181
conv2image format set to jpg for testing
HIROSE Yuuji <yuuji@gentei.org>
parents:
373
diff
changeset
|
484 (target (concat texput "." format)) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
485 (math (get 'YaTeX-typeset-conv2image-chain 'math)) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
486 (dpi (get 'YaTeX-typeset-conv2image-chain 'dpi)) |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
487 (srctype (or (get 'YaTeX-typeset-conv2image-chain 'srctype) |
374
9b3093c0c181
conv2image format set to jpg for testing
HIROSE Yuuji <yuuji@gentei.org>
parents:
373
diff
changeset
|
488 (if (file-newer-than-file-p |
9b3093c0c181
conv2image format set to jpg for testing
HIROSE Yuuji <yuuji@gentei.org>
parents:
373
diff
changeset
|
489 (concat texput ".pdf") |
9b3093c0c181
conv2image format set to jpg for testing
HIROSE Yuuji <yuuji@gentei.org>
parents:
373
diff
changeset
|
490 (concat texput ".dvi")) |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
491 'pdf 'dvi))) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
492 (chain (cdr (assq srctype YaTeX-typeset-conv2image-chain-alist))) |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
493 ;; This function is the first evaluation code. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
494 ;; If you find these command line does not work |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
495 ;; on your system, please tell the author |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
496 ;; which commands should be taken to achieve |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
497 ;; one-shot png previewing on your system |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
498 ;; before publishing patch on the Web. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
499 ;; Please please please please please. |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
500 (curproc (member prevname chain)) |
355
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
501 (w (get 'YaTeX-typeset-conv2image-chain 'win)) |
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
502 (pwd default-directory) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
503 img) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
504 (if (not (= (process-exit-status proc) 0)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
505 (progn |
362 | 506 (YaTeX-showup-buffer ;never comes here(?) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
507 (current-buffer) 'YaTeX-showup-buffer-bottom-most) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
508 (message "Region typesetting FAILED")) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
509 (setq command |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
510 (if curproc (car (cdr-safe curproc)) (car chain))) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
511 (if command |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
512 (let ((cmdline (YaTeX-replace-formats |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
513 command |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
514 (list (cons "b" "texput") |
374
9b3093c0c181
conv2image format set to jpg for testing
HIROSE Yuuji <yuuji@gentei.org>
parents:
373
diff
changeset
|
515 (cons "f" format) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
516 (cons "d" dpi))))) |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
517 (insert (format "Calling `%s'...\n" cmdline)) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
518 (set-process-sentinel |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
519 (setq YaTeX-typeset-conv2image-process |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
520 (start-process |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
521 command |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
522 (current-buffer) |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
523 shell-file-name YaTeX-shell-command-option |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
524 cmdline)) |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
525 'YaTeX-typeset-sentinel) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
526 (put 'YaTeX-typeset-process 'ppcmd |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
527 (cons (cons (get-buffer-process (current-buffer)) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
528 'YaTeX-typeset-conv2image-chain) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
529 (get 'YaTeX-typeset-process 'ppcmd)))) |
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
530 ;; After all chain executed, display image in current window |
362 | 531 (cond |
364 | 532 ((and (featurep 'image) window-system) |
362 | 533 ;; If direct image displaying available in running Emacs, |
534 ;; display target image into the next window in Emacs. | |
535 (select-window w) | |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
536 ;(setq foo (selected-window)) |
362 | 537 (YaTeX-showup-buffer |
538 (get-buffer-create " *YaTeX-region-image*") | |
539 'YaTeX-showup-buffer-bottom-most t) | |
540 (remove-images (point-min) (point-max)) | |
541 (erase-buffer) | |
542 (cd pwd) ;when reuse from other source | |
355
6c67a826f266
Hide temporary typesetting buffer
HIROSE Yuuji <yuuji@gentei.org>
parents:
354
diff
changeset
|
543 ;(put-image (create-image (expand-file-name target)) (point)) |
362 | 544 (insert-image-file target) |
545 (setq img (plist-get (text-properties-at (point)) 'intangible)) | |
546 (YaTeX-preview-image-mode) | |
547 (if img | |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
548 (let ((height (1+ (cdr (image-size img))))) |
362 | 549 (enlarge-window |
550 (- (ceiling (min height (/ (frame-height) 2))) | |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
551 (window-height))))) |
399
33bde8c52fcc
Fix message and remove trash
HIROSE Yuuji <yuuji@gentei.org>
parents:
395
diff
changeset
|
552 ;; Remember elapsed time, which will be threshold in onthefly-preview |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
553 (put 'YaTeX-typeset-conv2image-chain 'elapse |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
554 (YaTeX-elapsed-time |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
555 (get 'YaTeX-typeset-conv2image-chain 'start) (current-time)))) |
362 | 556 (t |
557 ;; Without direct image, display image with image viewer | |
558 (YaTeX-system | |
559 (format "%s %s" YaTeX-cmd-view-images target) | |
560 "YaTeX-region-image" | |
561 'noask) | |
562 ) | |
563 ))))) | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
564 |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
565 |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
566 (defvar YaTeX-typeset-environment-timer nil) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
567 (defun YaTeX-typeset-environment-timer () |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
568 "Update preview image in the |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
569 Plist: '(buf begPoint endPoint precedingChar 2precedingChar Substring time)" |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
570 (let*((plist (get 'YaTeX-typeset-environment-timer 'laststate)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
571 (b (nth 0 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
572 (s (nth 1 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
573 (e (nth 2 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
574 (p (nth 3 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
575 (q (nth 4 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
576 (st (nth 5 plist)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
577 (tm (nth 6 plist)) |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
578 (overlay YaTeX-on-the-fly-overlay) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
579 (thresh (* 2 (or (get 'YaTeX-typeset-conv2image-chain 'elapse) 1)))) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
580 (cond |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
581 ;; In minibuffer, do nothing |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
582 ((minibuffer-window-active-p (selected-window)) nil) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
583 ;; If point went out from last environment, cancel timer |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
584 ;;;((and (message "s=%d, e=%d, p=%d" s e (point)) nil)) |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
585 ((null (buffer-file-name)) nil) ;;At momentary-string-display, it's nil. |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
586 ((or (not (eq b (window-buffer (selected-window)))) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
587 (< (point) s) |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
588 (not (overlayp overlay)) |
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
589 (not (eq (overlay-buffer overlay) (current-buffer))) |
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
590 (> (point) (overlay-end overlay))) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
591 (YaTeX-typeset-environment-cancel-auto)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
592 ;;;((and (message "e=%d, p=%d t=%s" e (point) (current-time)) nil)) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
593 ;; If recently called, hold |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
594 ;;; ((< (YaTeX-elapsed-time tm (current-time)) thresh) nil) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
595 ;; If condition changed from last call, do it |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
596 ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay)))) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
597 (YaTeX-typeset-environment))))) |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
598 |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
599 |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
600 (defun YaTeX-typeset-environment-by-lmp () |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
601 (save-excursion |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
602 (let ((sw (selected-window))) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
603 (goto-char opoint) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
604 (latex-math-preview-expression) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
605 (select-window sw)))) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
606 |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
607 (defun YaTeX-typeset-environment-by-builtin () |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
608 (save-excursion |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
609 (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain))) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
610 |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
611 (defvar YaTeX-on-the-fly-math-preview-engine |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
612 (if (fboundp 'latex-math-preview-expression) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
613 'YaTeX-typeset-environment-by-lmp |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
614 'YaTeX-typeset-environment-by-builtin) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
615 "Function symbol to use math-preview. |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
616 'YaTeX-typeset-environment-by-lmp for using latex-math-preview, |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
617 'YaTeX-typeset-environment-by-builtin for using yatex-builtin.") |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
618 |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
619 (defun YaTeX-typeset-environment-1 () |
431 | 620 (require 'yatex23) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
621 (let*((math (YaTeX-in-math-mode-p)) |
406
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
622 (dpi (or (YaTeX-get-builtin "IMAGEDPI") (if math "300" "200"))) |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
623 (opoint (point)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
624 usetimer) |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
625 (cond |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
626 ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
627 (member YaTeX-on-the-fly-overlay (overlays-at (point)))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
628 ;; If current position is in on-the-fly overlay, |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
629 ;; use that region again |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
630 (setq math (get 'YaTeX-typeset-conv2image-chain 'math)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
631 (push-mark (overlay-start YaTeX-on-the-fly-overlay)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
632 (goto-char (overlay-end YaTeX-on-the-fly-overlay))) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
633 ((YaTeX-region-active-p) |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
634 nil) ;if region is active, use it |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
635 (math (setq usetimer t) (YaTeX-mark-environment)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
636 ((equal (or (YaTeX-inner-environment t) "document") "document") |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
637 (mark-paragraph)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
638 (t (setq usetimer t) (YaTeX-mark-environment))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
639 (if YaTeX-use-image-preview |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
640 (let ((YaTeX-typeset-buffer (concat "*bg:" YaTeX-typeset-buffer)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
641 (b (region-beginning)) (e (region-end))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
642 (put 'YaTeX-typeset-conv2image-chain 'math math) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
643 (put 'YaTeX-typeset-conv2image-chain 'dpi dpi) |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
644 (put 'YaTeX-typeset-conv2image-chain 'srctype nil) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
645 (put 'YaTeX-typeset-conv2image-chain 'win (selected-window)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
646 (put 'YaTeX-typeset-conv2image-chain 'start (current-time)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
647 (put 'YaTeX-typeset-environment-timer 'laststate |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
648 (list (current-buffer) b e (preceding-char) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
649 (char-after (- (point) 2)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
650 (YaTeX-buffer-substring b e) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
651 (current-time))) |
391
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
652 (if math (funcall YaTeX-on-the-fly-math-preview-engine) |
e834bbfce2ab
Use latex-math-preview if available. %#PREVIEWDPI
HIROSE Yuuji <yuuji@gentei.org>
parents:
388
diff
changeset
|
653 (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain)) |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
654 (if usetimer (YaTeX-typeset-environment-auto b e))) |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
655 (YaTeX-typeset-region)))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
656 |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
125
diff
changeset
|
657 (defun YaTeX-typeset-environment () |
371
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
658 "Typeset current environment or paragraph. |
f5b8e7415a25
Experimental code to split conv2img into dvi2png and pdf2png
HIROSE Yuuji <yuuji@gentei.org>
parents:
370
diff
changeset
|
659 If region activated, use it." |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
125
diff
changeset
|
660 (interactive) |
380
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
661 (let ((md (match-data))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
662 (unwind-protect |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
663 (save-excursion |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
664 (YaTeX-typeset-environment-1)) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
665 (store-match-data md)))) |
f061b37c7542
Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents:
378
diff
changeset
|
666 |
130
8703f090c628
`[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents:
125
diff
changeset
|
667 |
377
81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents:
376
diff
changeset
|
668 (defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9") |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
669 "*Control the on-the-fly update of preview environment by an image. |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
670 Nil disables on-the-fly update. Otherwise on-the-fly update is enabled |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
671 with update interval specified by this value.") |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
672 |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
673 (defun YaTeX-typeset-environment-auto (beg end) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
674 "Turn on on-the-fly preview-image" |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
675 (if YaTeX-typeset-environment-timer |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
676 (cancel-timer YaTeX-typeset-environment-timer)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
677 (if YaTeX-on-the-fly-overlay |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
678 (move-overlay YaTeX-on-the-fly-overlay beg end) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
679 (overlay-put |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
680 (setq YaTeX-on-the-fly-overlay (make-overlay beg end)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
681 'face 'YaTeX-on-the-fly-activated-face)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
682 (setq YaTeX-typeset-environment-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
683 (run-with-idle-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
684 (max (string-to-number "0.1") |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
685 (cond |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
686 ((numberp YaTeX-on-the-fly-preview-interval) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
687 YaTeX-on-the-fly-preview-interval) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
688 ((stringp YaTeX-on-the-fly-preview-interval) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
689 (string-to-number YaTeX-on-the-fly-preview-interval)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
690 (t 1))) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
691 t 'YaTeX-typeset-environment-timer))) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
692 |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
693 (defun YaTeX-typeset-environment-activate-onthefly () |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
694 (if (get-text-property (point) 'onthefly) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
695 (save-excursion |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
696 (if YaTeX-typeset-environment-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
697 (progn |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
698 (cancel-timer YaTeX-typeset-environment-timer) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
699 (setq YaTeX-typeset-environment-timer nil))) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
700 (if (YaTeX-on-begin-end-p) |
405
6b0d090840c1
YaTeX-on-begin-end-p: regex group 1,3 have `begin' patterns, 2,4 for `end'
HIROSE Yuuji <yuuji@gentei.org>
parents:
403
diff
changeset
|
701 (if (or (match-beginning 1) (match-beginning 3)) ;on beginning |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
702 (goto-char (match-end 0)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
703 (goto-char (match-beginning 0)))) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
704 (YaTeX-typeset-environment)))) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
705 |
406
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
706 (defun YaTeX-on-the-fly-cancel () |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
707 "Reset on-the-fly stickiness" |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
708 (interactive) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
709 (YaTeX-typeset-environment-cancel-auto 'stripoff) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
710 t) ;t for kill-* |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
711 |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
712 (defun YaTeX-typeset-environment-cancel-auto (&optional stripoff) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
713 "Cancel typeset-environment timer." |
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
714 (interactive) |
403
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
715 (if YaTeX-typeset-environment-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
716 (cancel-timer YaTeX-typeset-environment-timer)) |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
717 (setq YaTeX-typeset-environment-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
718 (run-with-idle-timer |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
719 (string-to-number "0.1") |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
720 t |
d8d66ed51034
Now on-the-fly preview is sticky to the environment where once called.
HIROSE Yuuji <yuuji@gentei.org>
parents:
399
diff
changeset
|
721 'YaTeX-typeset-environment-activate-onthefly)) |
406
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
722 (let ((ov YaTeX-on-the-fly-overlay)) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
723 (if stripoff |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
724 (remove-text-properties (overlay-start ov) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
725 (1- (overlay-end ov)) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
726 '(onthefly)) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
727 (put-text-property (overlay-start YaTeX-on-the-fly-overlay) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
728 (1- (overlay-end YaTeX-on-the-fly-overlay)) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
729 'onthefly |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
730 t)) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
731 (delete-overlay ov) |
acfa7d11b5c3
Sticky on-the-fly preview can be canceled by [prefix] k on vacant position.
HIROSE Yuuji <yuuji@gentei.org>
parents:
405
diff
changeset
|
732 (message "On-the-fly preview deactivated"))) |
375
afb8cb06b1d4
First trial of on-the-fly image-preview
HIROSE Yuuji <yuuji@gentei.org>
parents:
374
diff
changeset
|
733 |
123 | 734 (defun YaTeX-typeset-buffer (&optional pp) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
735 "Typeset whole buffer. |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
736 If %#! usage says other buffer is main text, |
51 | 737 visit main buffer to confirm if its includeonly list contains current |
738 buffer's file. And if it doesn't contain editing text, ask user which | |
123 | 739 action wants to be done, A:Add list, R:Replace list, %:comment-out list. |
740 If optional argument PP given as string, PP is considered as post-process | |
741 command and call it with the same command argument as typesetter without | |
742 last extension. | |
743 eg. if PP is \"dvipdfmx\", called commands as follows. | |
744 platex foo.tex | |
745 dvipdfmx foo | |
746 PP command will be called iff typeset command exit successfully" | |
51 | 747 (interactive) |
748 (YaTeX-save-buffers) | |
749 (let*((me (substring (buffer-name) 0 (rindex (buffer-name) ?.))) | |
750 (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
|
751 (cmd (YaTeX-get-latex-command t)) pparg ppcmd bibcmd |
123 | 752 (cb (current-buffer))) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
753 (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
|
754 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
|
755 pparg (substring pparg 0 (rindex pparg ?.)) ;rm ext |
262
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
756 bibcmd (or (YaTeX-get-builtin "BIBTEX") bibtex-command)) |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
757 (or (string-match "\\s " bibcmd) ;if bibcmd has no spaces, |
15ec86ff549c
Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents:
261
diff
changeset
|
758 (setq bibcmd (concat bibcmd pparg))) ;append argument(== %#!) |
123 | 759 (and pp |
760 (stringp pp) | |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
761 (setq ppcmd (concat pp pparg))) |
51 | 762 (if (YaTeX-main-file-p) nil |
763 (save-excursion | |
764 (YaTeX-visit-main t) ;search into main buffer | |
765 (save-excursion | |
766 (push-mark (point) t) | |
767 (goto-char (point-min)) | |
768 (if (and (re-search-forward "^[ ]*\\\\begin{document}" nil t) | |
769 (re-search-backward "^[ ]*\\\\includeonly{" nil t)) | |
770 (let* | |
771 ((b (progn (skip-chars-forward "^{") (point))) | |
772 (e (progn (skip-chars-forward "^}") (1+ (point)))) | |
773 (s (buffer-substring b e)) c | |
774 (pardir (file-name-directory (buffer-file-name)))) | |
775 (if (string-match (concat "[{,/]" me "[,}]") s) | |
776 nil ; Nothing to do when it's already in includeonly. | |
777 (ding) | |
778 (switch-to-buffer (current-buffer));Display this buffer. | |
779 (setq | |
780 me ;;Rewrite my name(me) to contain sub directory name. | |
781 (concat | |
782 (if (string-match pardir mydir) ;if mydir is child of main | |
783 (substring mydir (length pardir)) ;cut absolute path | |
784 mydir) ;else concat absolute path name. | |
785 me)) | |
786 (message | |
787 "`%s' is not in \\includeonly. A)dd R)eplace %%)comment? " | |
788 me) | |
789 (setq c (read-char)) | |
790 (cond | |
791 ((= c ?a) | |
792 (goto-char (1+ b)) | |
793 (insert me (if (string= s "{}") "" ","))) | |
794 ((= c ?r) | |
795 (delete-region (1+ b) (1- e)) (insert me)) | |
796 ((= c ?%) | |
797 (beginning-of-line) (insert "%")) | |
798 (t nil)) | |
799 (basic-save-buffer)))) | |
800 (exchange-point-and-mark))) | |
801 (switch-to-buffer cb)) ;for 19 | |
123 | 802 (YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd) |
69 | 803 (put 'dvi2-command 'region nil))) |
51 | 804 |
805 (defvar YaTeX-call-command-history nil | |
806 "Holds history list of YaTeX-call-command-on-file.") | |
807 (put 'YaTeX-call-command-history 'no-default t) | |
86 | 808 (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
|
809 "Call external command BASE-CMD in the BUFFER. |
86 | 810 By default, pass the basename of current file. Optional 3rd argument |
811 FILE changes the default file name." | |
51 | 812 (YaTeX-save-buffers) |
171
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
813 (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
|
814 (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
|
815 (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
|
816 (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
|
817 (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
|
818 me))))) |
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
819 (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
|
820 (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
|
821 (YaTeX-typeset |
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
822 (read-string-with-history |
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
823 "Call command: " |
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
824 (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
|
825 'YaTeX-call-command-history) |
670549efa5c2
YaTeX-call-command-on-file: Use last input command line as default.
yuuji@gentei.org
parents:
152
diff
changeset
|
826 buffer))) |
51 | 827 |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
828 (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
|
829 (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
|
830 (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
|
831 "Call command on file specified by BUILTIN-TYPE." |
51 | 832 (YaTeX-save-buffers) |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
833 (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
|
834 (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
|
835 (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
|
836 (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
|
837 (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
|
838 (cdr (assoc builtin-type alist)))) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
839 (command b-in)) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
840 (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
|
841 (progn |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
842 (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
|
843 (format "%s command: " builtin-type) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
844 (or b-in |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
845 (format "%s %s" default mainroot)) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
846 'YaTeX-call-command-history)) |
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
847 (if (or update (null b-in)) |
362 | 848 (if (y-or-n-p "Memorize this command line in this file? ") |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
849 (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
|
850 (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
|
851 (cons (cons builtin-type command) |
362 | 852 (delete (assoc builtin-type alist) alist))) |
853 (message "`%s' kept in memory. Type `%s %s' to override." | |
854 command | |
855 (key-description | |
856 (car (where-is-internal 'universal-argument))) | |
857 (key-description (this-command-keys))) | |
858 (sit-for 2))))) | |
224
9705855793ca
YaTeX-typeset-auto-rerun for labels and bibitems reference resolution.
yuuji@gentei.org
parents:
213
diff
changeset
|
859 (YaTeX-typeset |
227
3b2ac4652810
Handling of built-in is changed to use YaTeX-getset-builtin.
yuuji@gentei.org
parents:
224
diff
changeset
|
860 command |
362 | 861 (format " *YaTeX-%s*" (downcase builtin-type)) |
862 builtin-type builtin-type))) | |
51 | 863 |
864 (defun YaTeX-kill-typeset-process (proc) | |
865 "Kill process PROC after sending signal to PROC. | |
866 PROC should be process identifier." | |
867 (cond | |
68 | 868 ((not (fboundp 'start-process)) |
869 (error "This system can't have concurrent process.")) | |
51 | 870 ((or (null proc) (not (eq (process-status proc) 'run))) |
871 (message "Typesetting process is not running.")) | |
872 (t | |
873 (save-excursion | |
874 (set-buffer (process-buffer proc)) | |
875 (save-excursion | |
876 (goto-char (point-max)) | |
877 (beginning-of-line) | |
878 (if (looking-at "\\? +$") | |
879 (let ((mp (point-max))) | |
880 (process-send-string proc "x\n") | |
881 (while (= mp (point-max)) (sit-for 1)))))) | |
882 (if (eq (process-status proc) 'run) | |
883 (progn | |
884 (interrupt-process proc) | |
69 | 885 (delete-process proc)))))) |
51 | 886 |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
887 (defun YaTeX-system (command name &optional noask basedir) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
888 "Execute some COMMAND with process name `NAME'. Not a official function. |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
889 Optional second argument NOASK skip query when privious process running. |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
890 Optional third argument BASEDIR changes default-directory there." |
51 | 891 (save-excursion |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
892 (let ((df default-directory) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
893 (buffer (get-buffer-create (format " *%s*" name))) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
894 proc status) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
895 (set-buffer buffer) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
896 (setq default-directory (cd (or basedir df))) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
897 (erase-buffer) |
362 | 898 (insert (format "Calling `%s'...\n" command) |
899 "==Kill this buffer to STOP process==") | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
900 (YaTeX-showup-buffer buffer 'YaTeX-showup-buffer-bottom-most) |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
901 (if (not (fboundp 'start-process)) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
902 (call-process |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
903 shell-file-name nil buffer nil YaTeX-shell-command-option command) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
904 (if (and (setq proc (get-buffer-process buffer)) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
905 (setq status (process-status proc)) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
906 (eq status 'run) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
907 (not noask) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
908 (not |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
909 (y-or-n-p (format "Process %s is running. Continue?" buffer)))) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
910 nil |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
911 (if (eq status 'run) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
912 (progn (interrupt-process proc) (delete-process proc))) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
913 (set-process-buffer |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
914 (start-process |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
915 name buffer shell-file-name YaTeX-shell-command-option command) |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
916 (get-buffer buffer))))))) |
51 | 917 |
72 | 918 (defvar YaTeX-default-paper-type "a4" |
919 "*Default paper type.") | |
920 (defconst YaTeX-paper-type-alist | |
921 '(("a4paper" . "a4") | |
922 ("a5paper" . "a5") | |
923 ("b4paper" . "b4") | |
924 ("b5paper" . "b5")) | |
925 "Holds map of options and paper types.") | |
926 (defconst YaTeX-dvips-paper-option-alist | |
927 '(("a4" . "-t a4") | |
928 ("a5" . "-t a5") | |
929 ("b4" . "-t b4") | |
930 ("b5" . "-t b5") | |
931 ("a4r" . "-t landscape"); Can't specify options, `-t a4' and `-t landscape', at the same time. | |
932 ("a5r" . "-t landscape") | |
933 ("b4r" . "-t landscape") | |
934 ("b5r" . "-t landscape")) | |
935 "Holds map of dvips options and paper types.") | |
936 (defun YaTeX-get-paper-type () | |
937 "Search options in header and return a paper type, such as \"a4\", \"a4r\", etc." | |
938 (save-excursion | |
77 | 939 (YaTeX-visit-main t) |
72 | 940 (goto-char (point-min)) |
77 | 941 (let ((opts |
942 (if (re-search-forward | |
943 "^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t) | |
944 (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*")))) | |
945 (concat | |
946 (catch 'found-paper | |
947 (mapcar (lambda (pair) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
948 (if (YaTeX-member (car pair) opts) |
77 | 949 (throw 'found-paper (cdr pair)))) |
950 YaTeX-paper-type-alist) | |
951 YaTeX-default-paper-type) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
952 (if (YaTeX-member "landscape" opts) (if YaTeX-dos "L" "r") ""))))) |
72 | 953 |
51 | 954 (defvar YaTeX-preview-command-history nil |
955 "Holds minibuffer history of preview command.") | |
956 (put 'YaTeX-preview-command-history 'no-default t) | |
957 (defvar YaTeX-preview-file-history nil | |
958 "Holds minibuffer history of file to preview.") | |
959 (put 'YaTeX-preview-file-history 'no-default t) | |
328
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
960 (defun YaTeX-preview-default-previewer () |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
961 "Return default previewer for this document" |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
962 (YaTeX-replace-format |
410
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
963 (if (eq (get 'dvi2-command 'format) 'pdf) |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
964 (or (YaTeX-get-builtin "PDFVIEW") |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
965 tex-pdfview-command) |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
966 (or (YaTeX-get-builtin "PREVIEW") |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
967 dvi2-command)) |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
968 "p" (format (cond |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
969 (YaTeX-dos "-y:%s") |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
970 (t "-paper %s")) |
9ab38ecfd3d1
Default previewer for PDF is taken from %#PDFVIEW instead of %#PREVIEW.
HIROSE Yuuji <yuuji@gentei.org>
parents:
408
diff
changeset
|
971 (YaTeX-get-paper-type)))) |
328
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
972 (defun YaTeX-preview-default-main (command) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
973 "Return default preview target file" |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
974 (if (get 'dvi2-command 'region) |
86 | 975 (substring YaTeX-texput-file |
976 0 (rindex YaTeX-texput-file ?.)) | |
328
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
977 (YaTeX-get-preview-file-name command))) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
978 (defun YaTeX-preview (preview-command preview-file &optional as-default) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
979 "Execute xdvi (or other) to tex-preview." |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
980 (interactive |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
981 (let* ((previewer (YaTeX-preview-default-previewer)) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
982 (as-default current-prefix-arg) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
983 (command (if as-default |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
984 previewer |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
985 (read-string-with-history |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
986 "Preview command: " |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
987 previewer |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
988 'YaTeX-preview-command-history))) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
989 (target (YaTeX-preview-default-main command)) |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
990 (file (if as-default |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
991 target |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
992 (read-string-with-history |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
993 "Preview file: " |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
994 target |
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
995 'YaTeX-preview-file-history)))) |
86 | 996 (list command file))) |
328
d972598d233b
Prefix-arg for YaTeX-preview runs default previewer without inquiry
HIROSE Yuuji <yuuji@gentei.org>
parents:
326
diff
changeset
|
997 (setq dvi2-command preview-command) ;`dvi2-command' is buffer local |
51 | 998 (save-excursion |
999 (YaTeX-visit-main t) | |
86 | 1000 (if YaTeX-dos (setq preview-file (expand-file-name preview-file))) |
51 | 1001 (let ((pbuffer "*dvi-preview*") (dir default-directory)) |
1002 (YaTeX-showup-buffer | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
1003 pbuffer 'YaTeX-showup-buffer-bottom-most) |
51 | 1004 (set-buffer (get-buffer-create pbuffer)) |
1005 (erase-buffer) | |
1006 (setq default-directory dir) ;for 18 | |
1007 (cd dir) ;for 19 | |
1008 (cond | |
64 | 1009 ((not (fboundp 'start-process)) ;if MS-DOS |
51 | 1010 (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor |
1011 (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
|
1012 YaTeX-shell-command-option |
61 | 1013 (concat preview-command " " preview-file)) |
51 | 1014 (send-string-to-terminal "\e[>5l") ;show cursor |
1015 (redraw-display)) | |
69 | 1016 ((and (string-match "dviout" preview-command) ;maybe on `kon' |
1017 (stringp (getenv "TERM")) | |
1018 (string-match "^kon" (getenv "TERM"))) | |
1019 (call-process shell-file-name "con" "*dvi-preview*" nil | |
1020 YaTeX-shell-command-option | |
1021 (concat preview-command " " preview-file))) | |
51 | 1022 (t ;if UNIX |
1023 (set-process-buffer | |
86 | 1024 (let ((process-connection-type nil)) |
1025 (start-process "preview" "*dvi-preview*" shell-file-name | |
1026 YaTeX-shell-command-option | |
1027 (concat preview-command " " preview-file))) | |
51 | 1028 (get-buffer pbuffer)) |
1029 (message | |
1030 (concat "Starting " preview-command | |
69 | 1031 " to preview " preview-file))))))) |
51 | 1032 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1033 (defvar YaTeX-xdvi-remote-program "xdvi") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1034 (defun YaTeX-xdvi-remote-search (&optional region-mode) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1035 "Search string at the point on xdvi -remote window. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1036 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
|
1037 by region." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1038 (interactive "P") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1039 (let ((pb " *xdvi*") str proc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1040 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1041 (if region-mode |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1042 (setq str (buffer-substring (region-beginning) (region-end))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1043 (setq str (buffer-substring |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1044 (point) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1045 (progn (skip-chars-forward "^\n\\\\}") (point))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1046 (message "Searching `%s'..." str) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1047 (if (boundp 'MULE) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1048 (define-program-coding-system |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1049 (regexp-quote pb) (regexp-quote YaTeX-xdvi-remote-program) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1050 *euc-japan*)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1051 (setq proc |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1052 (start-process |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1053 "xdvi" pb YaTeX-xdvi-remote-program |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1054 "-remote" (format "SloppySearch(%s) " str) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1055 (concat (YaTeX-get-preview-file-name) ".dvi"))) |
69 | 1056 (message "Searching `%s'...Done" str)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1057 |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1058 (defun YaTeX-preview-jlfmt-xdvi () |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1059 "Call xdvi -sourceposition to DVI corresponding to current main file" |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1060 (interactive)) |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1061 |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1062 (defun YaTeX-preview-jump-line () |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1063 "Call jump-line function of various previewer on current main file" |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1064 (interactive) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1065 (save-excursion |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1066 (save-restriction |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1067 (widen) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1068 (let*((pf (or YaTeX-parent-file |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1069 (save-excursion (YaTeX-visit-main t) (buffer-file-name)))) |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1070 (pdir (file-name-directory pf)) |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1071 (bnr (substring pf 0 (string-match "\\....$" pf))) |
436
e78a87bc2c9e
current file treated as absolute path(YaTeX-preview-jump-line)
HIROSE Yuuji <yuuji@gentei.org>
parents:
431
diff
changeset
|
1072 ;(cf (file-relative-name (buffer-file-name) pdir)) |
e78a87bc2c9e
current file treated as absolute path(YaTeX-preview-jump-line)
HIROSE Yuuji <yuuji@gentei.org>
parents:
431
diff
changeset
|
1073 (cf (buffer-file-name)) ;2016-01-08 |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1074 (buffer (get-buffer-create " *preview-jump-line*")) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1075 (line (count-lines (point-min) (point-end-of-line))) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1076 (previewer (YaTeX-preview-default-previewer)) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1077 (cmd (cond |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1078 ((string-match "xdvi" previewer) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1079 (format "%s -nofork -sourceposition '%d %s' %s.dvi" |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1080 YaTeX-xdvi-remote-program |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1081 line cf bnr)) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1082 ((string-match "Skim" previewer) |
352
ecf7b5543e65
Arguments corrected for previewers
HIROSE Yuuji <yuuji@gentei.org>
parents:
351
diff
changeset
|
1083 (format "%s %d '%s.pdf' '%s'" |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1084 YaTeX-cmd-displayline line bnr cf)) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1085 ((string-match "evince" previewer) |
352
ecf7b5543e65
Arguments corrected for previewers
HIROSE Yuuji <yuuji@gentei.org>
parents:
351
diff
changeset
|
1086 (format "%s '%s.pdf' %d '%s'" |
ecf7b5543e65
Arguments corrected for previewers
HIROSE Yuuji <yuuji@gentei.org>
parents:
351
diff
changeset
|
1087 "fwdevince" bnr line cf)) |
362 | 1088 ;; |
1089 ;; These lines below for other PDF viewer is not confirmed | |
1090 ;; yet. If you find correct command line, PLEASE TELL | |
1091 ;; IT TO THE AUTHOR before publishing patch on the web. | |
1092 ;; ..PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE.. | |
369
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1093 ((string-match "sumatra" previewer) ;;?? |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1094 (format "%s \"%s.pdf\" -forward-search \"%s\" %d" |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1095 ;;Send patch to the author, please |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1096 previewer bnr cf line)) |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1097 ((string-match "qpdfview" previewer) ;;?? |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1098 (format "%s '%s.pdf#src:%s:%d:0'" |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1099 ;;Send patch to the author, please |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1100 previewer bnr cf line)) |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1101 ((string-match "okular" previewer) ;;?? |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1102 (format "%s '%s.pdf#src:%d' '%s'" |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1103 ;;Send patch to the author, please |
a536acc07a75
Re-activate forward-search code.
HIROSE Yuuji <yuuji@gentei.org>
parents:
367
diff
changeset
|
1104 previewer bnr line cf)) |
362 | 1105 ))) |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1106 (YaTeX-system cmd "jump-line" 'noask pdir))))) |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1107 |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1108 (defun YaTeX-goto-corresponding-viewer () |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1109 (let ((cmd (or (YaTeX-get-builtin "!") tex-command))) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1110 (if (string-match "-src\\|synctex=" cmd) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1111 (progn |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1112 (YaTeX-preview-jump-line) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1113 t) ;for YaTeX-goto-corresponding-* |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1114 nil))) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1115 |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1116 (defun YaTeX-set-virtual-error-position (file-sym line-sym) |
52 | 1117 "Replace the value of FILE-SYM, LINE-SYM by virtual error position." |
1118 (cond | |
1119 ((and (get 'dvi2-command 'region) | |
1120 (> (symbol-value line-sym) (car (get 'dvi2-command 'offset)))) | |
1121 (set file-sym (get 'dvi2-command 'file)) | |
1122 (set line-sym | |
1123 (+ (- (apply '- (get 'dvi2-command 'offset))) | |
1124 (symbol-value line-sym) | |
1125 -1))))) | |
1126 | |
51 | 1127 (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
|
1128 "Visit position of previous typeset error or warning. |
51 | 1129 To avoid making confliction of line numbers by editing, jump to |
1130 error or warning lines in reverse order." | |
1131 (interactive) | |
230
7f4a5db88fbb
Don't pause at re-run. YaTeX-prev-error supports re-run.
yuuji@gentei.org
parents:
227
diff
changeset
|
1132 (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
|
1133 (cur-win (selected-window)) |
7f4a5db88fbb
Don't pause at re-run. YaTeX-prev-error supports re-run.
yuuji@gentei.org
parents:
227
diff
changeset
|
1134 b0 bound errorp error-line typeset-win error-buffer error-win) |
51 | 1135 (if (null (get-buffer YaTeX-typeset-buffer)) |
1136 (error "There is no typesetting buffer.")) | |
1137 (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
|
1138 (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
|
1139 (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
|
1140 (setq bound YaTeX-typeset-marker)) |
51 | 1141 (setq typeset-win (selected-window)) |
1142 (if (re-search-backward | |
1143 (concat "\\(" latex-error-regexp "\\)\\|\\(" | |
1144 latex-warning-regexp "\\)") | |
230
7f4a5db88fbb
Don't pause at re-run. YaTeX-prev-error supports re-run.
yuuji@gentei.org
parents:
227
diff
changeset
|
1145 bound t) |
80 | 1146 (setq errorp (match-beginning 1)) |
51 | 1147 (select-window cur-win) |
68 | 1148 (error "No more errors on %s" cur-buf)) |
80 | 1149 (goto-char (setq b0 (match-beginning 0))) |
51 | 1150 (skip-chars-forward "^0-9" (match-end 0)) |
1151 (setq error-line | |
1152 (string-to-int | |
1153 (buffer-substring | |
1154 (point) | |
1155 (progn (skip-chars-forward "0-9" (match-end 0)) (point)))) | |
70 | 1156 error-buffer (expand-file-name (YaTeX-get-error-file cur-buf))) |
51 | 1157 (if (or (null error-line) (equal 0 error-line)) |
1158 (error "Can't detect error position.")) | |
52 | 1159 (YaTeX-set-virtual-error-position 'error-buffer 'error-line) |
1160 (setq error-win (get-buffer-window error-buffer)) | |
51 | 1161 (select-window cur-win) |
1162 (cond | |
1163 (error-win (select-window error-win)) | |
1164 ((eq (get-lru-window) typeset-win) | |
1165 (YaTeX-switch-to-buffer error-buffer)) | |
1166 (t (select-window (get-lru-window)) | |
1167 (YaTeX-switch-to-buffer error-buffer))) | |
1168 (setq error-win (selected-window)) | |
1169 (goto-line error-line) | |
1170 (message "LaTeX %s in `%s' on line: %d." | |
80 | 1171 (if errorp "error" "warning") |
51 | 1172 error-buffer error-line) |
1173 (select-window typeset-win) | |
1174 (skip-chars-backward "0-9") | |
1175 (recenter (/ (window-height) 2)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1176 (sit-for 1) |
80 | 1177 (goto-char b0) |
69 | 1178 (select-window error-win))) |
51 | 1179 |
1180 (defun YaTeX-jump-error-line () | |
1181 "Jump to corresponding line on latex command's error message." | |
1182 (interactive) | |
1183 (let (error-line error-file error-buf) | |
1184 (save-excursion | |
1185 (beginning-of-line) | |
1186 (setq error-line (re-search-forward "l[ ines]*\\.?\\([1-9][0-9]*\\)" | |
1187 (point-end-of-line) t))) | |
1188 (if (null error-line) | |
1189 (if (eobp) (insert (this-command-keys)) | |
1190 (error "No line number expression.")) | |
1191 (goto-char (match-beginning 0)) | |
1192 (setq error-line (string-to-int | |
1193 (buffer-substring (match-beginning 1) (match-end 1))) | |
70 | 1194 error-file (expand-file-name |
1195 (YaTeX-get-error-file YaTeX-current-TeX-buffer))) | |
52 | 1196 (YaTeX-set-virtual-error-position 'error-file 'error-line) |
1197 (setq error-buf (YaTeX-switch-to-buffer error-file t))) | |
51 | 1198 (if (null error-buf) |
1199 (error "`%s' is not found in this directory." error-file)) | |
1200 (YaTeX-showup-buffer error-buf nil t) | |
69 | 1201 (goto-line error-line))) |
51 | 1202 |
1203 (defun YaTeX-send-string () | |
1204 "Send string to current typeset process." | |
1205 (interactive) | |
1206 (if (and (eq (process-status YaTeX-typeset-process) 'run) | |
1207 (>= (point) (process-mark YaTeX-typeset-process))) | |
1208 (let ((b (process-mark YaTeX-typeset-process)) | |
1209 (e (point-end-of-line))) | |
1210 (goto-char b) | |
1211 (skip-chars-forward " \t" e) | |
1212 (setq b (point)) | |
1213 (process-send-string | |
1214 YaTeX-typeset-process (concat (buffer-substring b e) "\n")) | |
1215 (goto-char e) | |
1216 (insert "\n") | |
1217 (set-marker (process-mark YaTeX-typeset-process) (point)) | |
1218 (insert " ")) | |
69 | 1219 (ding))) |
51 | 1220 |
1221 (defun YaTeX-view-error () | |
1222 (interactive) | |
1223 (if (null (get-buffer YaTeX-typeset-buffer)) | |
1224 (message "No typeset buffer found.") | |
1225 (let ((win (selected-window))) | |
1226 (YaTeX-showup-buffer YaTeX-typeset-buffer nil t) | |
1227 ;; Next 3 lines are obsolete because YaTeX-typesetting-buffer is | |
1228 ;; automatically scrolled up at typesetting. | |
1229 ;;(goto-char (point-max)) | |
1230 ;;(forward-line -1) | |
1231 ;;(recenter -1) | |
69 | 1232 (select-window win)))) |
51 | 1233 |
1234 (defun YaTeX-get-error-file (default) | |
1235 "Get current processing file from typesetting log." | |
1236 (save-excursion | |
1237 (let(s) | |
1238 (condition-case () (up-list -1) | |
1239 (error | |
1240 (let ((list 0) found) | |
1241 (while | |
1242 (and (<= list 0) (not found) | |
1243 (re-search-backward "\\((\\)\\|\\()\\)" nil t)) | |
1244 (if (equal (match-beginning 0) (match-beginning 2)) ;close paren. | |
1245 (setq list (1- list)) ;open paren | |
1246 (setq list (1+ list)) | |
1247 (if (= list 1) | |
1248 (if (looking-at "\\([^,{}%]+\.\\)tex\\|sty") | |
1249 (setq found t) | |
1250 (setq list (1- list))))))))) | |
1251 (setq s | |
1252 (buffer-substring | |
1253 (progn (forward-char 1) (point)) | |
1254 (progn (skip-chars-forward "^ \n" (point-end-of-line)) | |
1255 (point)))) | |
69 | 1256 (if (string= "" s) default s)))) |
51 | 1257 |
1258 (defun YaTeX-put-nonstopmode () | |
64 | 1259 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) |
51 | 1260 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t) |
1261 nil ;if already written in text then do nothing | |
1262 (save-excursion | |
1263 (YaTeX-visit-main t) | |
1264 (goto-char (point-min)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1265 (insert "\\nonstopmode{}%_YaTeX_%\n") |
69 | 1266 (if (buffer-file-name) (basic-save-buffer)))))) |
51 | 1267 |
1268 (defun YaTeX-remove-nonstopmode () | |
64 | 1269 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed |
51 | 1270 (save-excursion |
1271 (YaTeX-visit-main t) | |
1272 (goto-char (point-min)) | |
1273 (forward-line 1) | |
1274 (narrow-to-region (point-min) (point)) | |
1275 (goto-char (point-min)) | |
1276 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$") | |
69 | 1277 (widen)))) |
51 | 1278 |
80 | 1279 (defvar YaTeX-dvi2-command-ext-alist |
388 | 1280 '(("[agxk]dvi\\|dviout" . ".dvi") |
80 | 1281 ("ghostview\\|gv" . ".ps") |
388 | 1282 ("acroread\\|[xk]pdf\\|pdfopen\\|Preview\\|TeXShop\\|Skim\\|evince\\|mupdf\\|zathura\\|okular" . ".pdf"))) |
80 | 1283 |
86 | 1284 (defun YaTeX-get-preview-file-name (&optional preview-command) |
51 | 1285 "Get file name to preview by inquiring YaTeX-get-latex-command" |
86 | 1286 (if (null preview-command) (setq preview-command dvi2-command)) |
51 | 1287 (let* ((latex-cmd (YaTeX-get-latex-command t)) |
1288 (rin (rindex latex-cmd ? )) | |
172
429d10a0d5b2
YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents:
171
diff
changeset
|
1289 (fname (if rin (substring latex-cmd (1+ rin)) "")) |
86 | 1290 (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
|
1291 (ext (if r (cdr r) ""))) |
325
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1292 (and (null r) |
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1293 (eq (get 'dvi2-command 'format) 'pdf) |
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1294 (setq ext "pdf")) |
80 | 1295 (concat |
1296 (if (string= fname "") | |
172
429d10a0d5b2
YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents:
171
diff
changeset
|
1297 (setq fname (substring (file-name-nondirectory |
429d10a0d5b2
YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents:
171
diff
changeset
|
1298 (buffer-file-name)) |
429d10a0d5b2
YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents:
171
diff
changeset
|
1299 0 -4)) |
429d10a0d5b2
YaTeX-typeset-buffer: Change the method of constructing ppcmd.
yuuji@gentei.org
parents:
171
diff
changeset
|
1300 (setq fname (substring fname 0 (rindex fname ?.)))) |
80 | 1301 ext))) |
51 | 1302 |
1303 (defun YaTeX-get-latex-command (&optional switch) | |
1304 "Specify the latex-command name and its argument. | |
1305 If there is a line which begins with string: \"%#!\", the following | |
1306 strings are assumed to be the latex-command and arguments. The | |
1307 default value of latex-command is: | |
1308 tex-command FileName | |
388 | 1309 and if you write \"%#!platex\" in the beginning of certain line. |
1310 \"platex \" FileName | |
51 | 1311 will be the latex-command, |
388 | 1312 and you write \"%#!platex main.tex\" on some line and argument SWITCH |
51 | 1313 is non-nil, then |
388 | 1314 \"platex main.tex\" |
51 | 1315 |
1316 will be given to the shell." | |
80 | 1317 (let (parent tparent magic) |
51 | 1318 (setq parent |
1319 (cond | |
80 | 1320 (YaTeX-parent-file |
1321 (if YaTeX-dos (expand-file-name YaTeX-parent-file) | |
1322 YaTeX-parent-file)) | |
51 | 1323 (t (save-excursion |
1324 (YaTeX-visit-main t) | |
1325 (file-name-nondirectory (buffer-file-name))))) | |
80 | 1326 magic (YaTeX-get-builtin "!") |
1327 tparent (file-name-nondirectory parent)) | |
1328 (YaTeX-replace-formats | |
1329 (cond | |
1330 (magic | |
1331 (cond | |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1332 (switch (if (string-match "\\s [^-]\\S *$" magic) magic |
80 | 1333 (concat magic " " parent))) |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1334 (t (concat (substring magic 0 (string-match "\\s [^-]\\S *$" magic)) " ")))) |
80 | 1335 (t (concat tex-command " " (if switch parent)))) |
1336 (list (cons "f" tparent) | |
1337 (cons "r" (substring tparent 0 (rindex tparent ?.))))))) | |
51 | 1338 |
1339 (defvar YaTeX-lpr-command-history nil | |
1340 "Holds command line history of YaTeX-lpr.") | |
1341 (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
|
1342 (defvar YaTeX-lpr-ask-page-range-default t) |
51 | 1343 (defun YaTeX-lpr (arg) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1344 "Print out. |
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1345 If prefix arg ARG is non nil, call print driver without |
51 | 1346 page range description." |
1347 (interactive "P") | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
1348 (or YaTeX-lpr-ask-page-range-default (setq arg (not arg))) |
51 | 1349 (let*((cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format)) |
52 | 1350 from to (lbuffer "*dvi-printing*") dir) |
51 | 1351 (setq |
1352 cmd | |
1353 (YaTeX-replace-format | |
1354 cmd "f" | |
1355 (if (or arg (not (string-match "%f" cmd))) | |
1356 "" | |
1357 (YaTeX-replace-format | |
1358 dviprint-from-format | |
1359 "b" | |
1360 (if (string= | |
1361 (setq from (read-string "From page(default 1): ")) "") | |
1362 "1" from)))) | |
1363 ) | |
1364 (setq | |
1365 cmd | |
1366 (YaTeX-replace-format | |
1367 cmd "t" | |
1368 (if (or arg (not (string-match "%t" cmd)) | |
1369 (string= | |
1370 (setq to (read-string "To page(default none): ")) "")) | |
1371 "" | |
1372 (YaTeX-replace-format dviprint-to-format "e" to))) | |
1373 ) | |
72 | 1374 (setq |
1375 cmd | |
1376 (YaTeX-replace-format | |
1377 cmd "p" | |
1378 (cdr (assoc (YaTeX-get-paper-type) YaTeX-dvips-paper-option-alist)))) | |
51 | 1379 (setq cmd |
1380 (read-string-with-history | |
1381 "Edit command line: " | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1382 (format cmd |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1383 (if (get 'dvi2-command 'region) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1384 (substring YaTeX-texput-file |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1385 0 (rindex YaTeX-texput-file ?.)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
1386 (YaTeX-get-preview-file-name))) |
51 | 1387 'YaTeX-lpr-command-history)) |
1388 (save-excursion | |
1389 (YaTeX-visit-main t) ;;change execution directory | |
52 | 1390 (setq dir default-directory) |
51 | 1391 (YaTeX-showup-buffer |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
352
diff
changeset
|
1392 lbuffer 'YaTeX-showup-buffer-bottom-most) |
51 | 1393 (set-buffer (get-buffer-create lbuffer)) |
1394 (erase-buffer) | |
52 | 1395 (cd dir) ;for 19 |
51 | 1396 (cond |
64 | 1397 ((not (fboundp 'start-process)) |
51 | 1398 (call-process shell-file-name "con" "*dvi-printing*" nil |
1399 YaTeX-shell-command-option cmd)) | |
1400 (t | |
1401 (set-process-buffer | |
86 | 1402 (let ((process-connection-type nil)) |
1403 (start-process "print" "*dvi-printing*" shell-file-name | |
1404 YaTeX-shell-command-option cmd)) | |
51 | 1405 (get-buffer lbuffer)) |
69 | 1406 (message "Starting printing command: %s..." cmd)))))) |
51 | 1407 |
1408 (defun YaTeX-main-file-p () | |
1409 "Return if current buffer is main LaTeX source." | |
1410 (cond | |
52 | 1411 (YaTeX-parent-file |
1412 (eq (get-file-buffer YaTeX-parent-file) (current-buffer))) | |
51 | 1413 ((YaTeX-get-builtin "!") |
70 | 1414 (string-match |
1415 (concat "^" (YaTeX-guess-parent (YaTeX-get-builtin "!"))) | |
1416 (buffer-name))) | |
51 | 1417 (t |
1418 (save-excursion | |
57 | 1419 (let ((latex-main-id |
1420 (concat "^\\s *" YaTeX-ec-regexp "document\\(style\\|class\\)"))) | |
51 | 1421 (or (re-search-backward latex-main-id nil t) |
69 | 1422 (re-search-forward latex-main-id nil t))))))) |
51 | 1423 |
1424 (defun YaTeX-visit-main (&optional setbuf) | |
1425 "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
|
1426 Use set-buffer instead of switch-to-buffer if the optional argument |
51 | 1427 SETBUF is t(Use it only from Emacs-Lisp program)." |
1428 (interactive "P") | |
1429 (if (and (interactive-p) setbuf) (setq YaTeX-parent-file nil)) | |
70 | 1430 (let ((ff (function (lambda (f) |
1431 (if setbuf (set-buffer (find-file-noselect f)) | |
1432 (find-file f))))) | |
325
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1433 b-in main-file mfa YaTeX-create-file-prefix-g |
70 | 1434 (hilit-auto-highlight (not setbuf))) |
51 | 1435 (if (setq b-in (YaTeX-get-builtin "!")) |
1436 (setq main-file (YaTeX-guess-parent b-in))) | |
1437 (if YaTeX-parent-file | |
1438 (setq main-file ;;(get-file-buffer YaTeX-parent-file) | |
1439 YaTeX-parent-file)) | |
1440 (if (YaTeX-main-file-p) | |
1441 (if (interactive-p) (message "I think this is main LaTeX source.") nil) | |
1442 (cond | |
70 | 1443 ((and ;;(interactive-p) |
1444 main-file | |
1445 (cond ((get-file-buffer main-file) | |
1446 (cond | |
1447 (setbuf (set-buffer (get-file-buffer main-file))) | |
1448 ((get-buffer-window (get-file-buffer main-file)) | |
1449 (select-window | |
1450 (get-buffer-window (get-file-buffer main-file)))) | |
1451 (t (switch-to-buffer (get-file-buffer main-file))))) | |
1452 ((file-exists-p main-file) | |
1453 (funcall ff main-file))))) | |
1454 ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf))) | |
51 | 1455 ((and main-file |
1456 (file-exists-p (setq main-file (concat "../" main-file))) | |
80 | 1457 (or b-in |
325
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1458 (y-or-n-p (concat (setq mfa (expand-file-name main-file)) |
80 | 1459 " is main file?:")))) |
325
2561570d7194
evince usage; YaTeX-parent-file handling:
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
1460 (setq YaTeX-parent-file mfa) |
70 | 1461 ;(YaTeX-switch-to-buffer main-file setbuf) |
1462 (funcall ff main-file) | |
1463 ) | |
51 | 1464 (t (setq main-file (read-file-name "Enter your main text: " nil nil 1)) |
326
d989511a492a
Keep YaTeX-parent-file in absolute-path
HIROSE Yuuji <yuuji@gentei.org>
parents:
325
diff
changeset
|
1465 (setq YaTeX-parent-file (expand-file-name main-file)) |
70 | 1466 ; (YaTeX-switch-to-buffer main-file setbuf)) |
1467 (funcall ff main-file)) | |
51 | 1468 ))) |
69 | 1469 nil) |
51 | 1470 |
1471 (defun YaTeX-guess-parent (command-line) | |
1472 (setq command-line | |
350
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1473 (if (string-match "\\s \\([^-]\\S *\\)$" command-line) |
91ba61bb536e
[prefix] g calls forward-search of previewers if -src is given to typesetting.
HIROSE Yuuji <yuuji@gentei.org>
parents:
328
diff
changeset
|
1474 (substring command-line (match-beginning 1)) |
51 | 1475 (file-name-nondirectory (buffer-file-name))) |
1476 command-line | |
1477 (concat (if (string-match "\\(.*\\)\\." command-line) | |
1478 (substring command-line (match-beginning 1) (match-end 1)) | |
1479 command-line) | |
69 | 1480 ".tex"))) |
51 | 1481 |
1482 (defun YaTeX-visit-main-other-window () | |
1483 "Switch to buffer main LaTeX source in other window." | |
1484 (interactive) | |
1485 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.") | |
1486 (YaTeX-switch-to-buffer-other-window | |
69 | 1487 (concat (YaTeX-get-preview-file-name) ".tex")))) |
51 | 1488 |
1489 (defun YaTeX-save-buffers () | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1490 "Save buffers whose major-mode is equal to current major-mode." |
51 | 1491 (basic-save-buffer) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1492 (let ((cmm major-mode)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1493 (save-excursion |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1494 (mapcar (function |
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1495 (lambda (buf) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1496 (set-buffer buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1497 (if (and (buffer-file-name buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1498 (eq major-mode cmm) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1499 (buffer-modified-p buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1500 (y-or-n-p (format "Save %s" (buffer-name buf)))) |
351
0fc7ea5baa5f
YaTeX-system takes two more args for utilization from YaTeX-preview-jump-file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
350
diff
changeset
|
1501 (save-buffer buf)))) |
69 | 1502 (buffer-list))))) |
51 | 1503 |
1504 (provide 'yatexprc) |