annotate yatexprc.el @ 605:38a414d755c1 draft dev

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

yatex.org