Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexflt.el @ 545:ea6956f10ce7 dev
When %#SRC specified, should send content of that file.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 02 Jun 2018 15:57:55 +0900 |
parents | ab6c176c676a |
children | 826b0766f6ba |
rev | line source |
---|---|
518 | 1 ;;; yatexflt.el --- YaTeX filter command utilizer -*- coding: sjis -*- |
2 ;;; | |
3 ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org] | |
545
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
4 ;;; Last modified Sat Jun 2 15:55:38 2018 on firestorm |
518 | 5 ;;; $Id$ |
6 | |
7 ;;; Commentary: | |
8 ;;; | |
9 ;;; This lisp enables passing inline text to some external filter | |
10 ;;; command to generate files such as graphic files. | |
11 ;;; | |
12 ;;; Typical situation is using blockdiag/dot(graphviz) command to | |
13 ;;; generate png/pdf file. | |
14 ;;; | |
15 ;;; Example: | |
16 ;;; | |
17 ;;; [[LaTeX Source]] | |
18 ;;; %#BEGIN FILTER{foo.pdf}{dot -T %t -o o} | |
19 ;;; \if0 | |
20 ;;; === | |
21 ;;; digraph { | |
22 ;;; A -> B; | |
23 ;;; B -> C; | |
24 ;;; } | |
25 ;;; === | |
26 ;;; \fi | |
27 ;;; %#END | |
28 ;;; \includegraphics{foo.pdf} | |
29 ;;; | |
30 ;;; In this case above, when you type `[prefix] t e' between two | |
31 ;;; `===' lines, the content in a region are fed to dot command as | |
32 ;;; follows: | |
33 ;;; | |
34 ;;; echo TEXT | dot -T pdf -o foo.pdf | |
35 ;;; | |
36 ;;; Then foo.pdf file will be generated and the image (as PNG) will | |
37 ;;; be displayed in the next window. | |
38 | |
521
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
39 |
518 | 40 ;;; Code: |
521
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
41 (require 'yatexlib) |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
42 (defvar YaTeX-filter-special-env-alist-default |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
43 '((".blockdiag" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
44 "blockdiag -T %t -o %o -" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
45 "blockdiag { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
46 default_fontsize = 32; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
47 A -> B; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
48 }") |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
49 (".seqdiag" "seqdiag -T %t -o %o -" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
50 "seqdiag { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
51 client -> server [label = \"SYN\"]; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
52 client <- server [label = \"SYN/ACK\"]; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
53 client -> server [label = \"ACK\"];}") |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
54 (".actdiag" "actdiag -T %t -o %o -" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
55 "actdiag { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
56 sayHo -> ho -> hohoho |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
57 lane dj { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
58 label = \"DJ\" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
59 sayHo [label = \"Say Ho\"]; hohoho [label = \"Ho Ho Ho!\"]; } |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
60 lane mc { label = \"MC\"; ho [label = \"Hooooh!\"]}}") |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
61 (".nwdiag" "nwdiag -T %t -o %o -" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
62 "nwdiag { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
63 network ext { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
64 address = \"10.1.2.0/24\" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
65 router [address = \"10.1.2.1\"] |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
66 } |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
67 network int { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
68 address = \"192.168.22.0/24\" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
69 router [address = \"192.168.22.1\"] |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
70 websrv [address = \"192.168.22.80\"] |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
71 cli-1; cli-2 |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
72 } |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
73 }") |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
74 (".rackdiag" "rackdiag -T %t -o %o -" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
75 "rackdiag { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
76 16U; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
77 1: UPS [4U]; 5: Storage [3U]; 8: PC [2U]; 8: PC [2U]; |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
78 }") |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
79 (".dot" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
80 "dot -T %t -o %o" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
81 "digraph { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
82 graph [charset=\"utf-8\"] |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
83 } |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
84 bigraph { |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
85 graph [charset=\"utf-8\"]}" |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
86 ))) |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
87 |
544
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
88 ;;;###autoload |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
89 (defun YaTeX-filter-goto-source (file other-win) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
90 "Go to corresponding text source of the graphic file" |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
91 (cond |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
92 ((file-exists-p file) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
93 (let ((buf (find-file-noselect file))) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
94 (funcall (cond (other-win 'YaTeX-switch-to-buffer-other-window) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
95 ((get-buffer-window buf) 'goto-buffer-window) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
96 (t 'YaTeX-switch-to-buffer)) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
97 buf))))) |
ab6c176c676a
Move all dot-filter definitions to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
524
diff
changeset
|
98 |
521
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
99 (defvar YaTeX-filter-special-env-alist-private nil) |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
100 (defvar YaTeX-filter-special-env-alist |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
101 (append YaTeX-filter-special-env-alist-private |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
102 YaTeX-filter-special-env-alist-default)) |
cef987df070f
Move main stuffs of SpecialFilter to yatexflt.el
HIROSE Yuuji <yuuji@gentei.org>
parents:
518
diff
changeset
|
103 |
518 | 104 (defun YaTeX-filter-filter-set-conversion-flag () |
105 (let ((ovl (get 'YaTeX-filter-filter-sentinel 'overlay))) | |
106 (if ovl ;; When successful conversion met, | |
107 (progn ;; (1)Set conversion complete flag | |
108 (add-hook ;; (2)Add hook of seim-automatic | |
109 'write-file-hooks ;; update of convert to write- | |
110 'YaTeX-filter-update-all) ;; file hook. | |
111 (overlay-put ovl 'converted t))))) | |
112 | |
113 (defun YaTeX-filter-filter-unset-conversion-flag | |
114 (ovl after beg end &optional length) | |
115 (if after (overlay-put ovl 'converted nil))) | |
116 | |
117 | |
118 (defun YaTeX-filter-pngify-sentinel (proc msg) | |
119 (save-excursion | |
120 (let ((b (process-buffer proc)) (selw (selected-window)) | |
121 img) | |
122 (set-buffer b) | |
123 (cond | |
124 ((eq (process-status proc) 'run) | |
125 (put-text-property (point-min) (point-max) 'invisible t)) | |
126 ((eq (process-status proc) 'exit) | |
127 (set-buffer b) | |
128 (YaTeX-popup-image | |
129 (YaTeX-buffer-substring | |
130 (get 'YaTeX-filter-pngify-sentinel 'start) (point-max)) | |
131 b) | |
132 (YaTeX-filter-filter-set-conversion-flag)) | |
133 (t | |
134 (set-buffer b) | |
135 (remove-text-properties (point-min) (point-max) '(invisible t)) | |
136 (insert "\nProcess aborted %s\n" msg)))))) | |
137 | |
138 (defvar YaTeX-filter-pdf2png-stdout | |
139 (cond | |
140 ((YaTeX-executable-find "convert") "convert -trim %s PNG:-") | |
141 (t | |
142 "gs -dNOPAUSE -sDEVICE=png256 -sOutputFile=- -dBATCH -q -r75 %s")) | |
143 "Command line syntax to convert PDF file to PNG stream") | |
144 | |
145 (defun YaTeX-filter-modified-BEGEND-regions () | |
146 "Return the list of overlays which contains un-converted text." | |
147 (save-excursion | |
148 (save-restriction | |
149 (widen) | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
150 (let (r prop dest src pl (list (overlays-in (point-min) (point-max)))) |
518 | 151 (while list |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
152 (setq prop (overlay-properties (car list))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
153 (if (setq dest (plist-get prop 'filter-output)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
154 (if (if (setq src (plist-get prop 'filter-source)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
155 (file-newer-than-file-p src dest) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
156 (and (setq pl (plist-member prop 'converted)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
157 (not (plist-get pl 'converted)))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
158 (setq r (cons (car list) r)))) |
518 | 159 (setq list (cdr list))) |
160 (nconc r) | |
161 r)))) | |
162 | |
163 (defun YaTeX-filter-update-all () | |
164 "Update all destination files from built-in source text." | |
165 (interactive) | |
166 (let ((timeout 4) | |
167 ans ovl (update-list (YaTeX-filter-modified-BEGEND-regions))) | |
168 (if update-list | |
169 (save-excursion | |
170 (save-window-excursion | |
171 (catch 'abort | |
172 (while update-list | |
173 (goto-char (overlay-start (setq ovl (car update-list)))) | |
174 (or (pos-visible-in-window-p) | |
175 (set-window-start nil (point))) | |
176 (unwind-protect | |
177 (progn | |
178 (overlay-put ovl 'face 'YaTeX-on-the-fly-activated-face) | |
179 (message "Non-update source found: Update here: %s " | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
180 "Y)es N)o S)top-watching-Here A)bort") |
518 | 181 (setq ans (read-char)) |
182 (cond | |
183 ((memq ans '(?Y ?y)) | |
184 (YaTeX-filter-BEGEND) | |
185 (while (and (> (setq timeout (1- timeout))) | |
186 (eq (process-status "Filter") 'run)) | |
187 (message "Waiting for conversion process to finish") | |
188 (sit-for 1))) | |
189 ((memq ans '(?A ?a)) (throw 'abort t)) | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
190 ((memq ans '(?S ?s)) (delete-overlay ovl)) |
518 | 191 (t nil))) |
192 (overlay-put ovl 'face nil)) | |
193 (setq update-list (cdr update-list))))))) | |
194 ;; Write file hook should return nil | |
195 nil)) | |
196 | |
197 (defun YaTeX-filter-filter-sentinel (proc msg) | |
198 (put 'YaTeX-filter-pngify-sentinel 'start nil) | |
199 (let ((b (process-buffer proc)) | |
200 (imagefile (get 'YaTeX-filter-filter-sentinel 'outfile)) | |
201 ovl | |
202 (selw (selected-window))) | |
203 (save-excursion | |
204 (cond | |
205 ((eq (process-status proc) 'run)) | |
206 ((eq (process-status proc) 'exit) | |
207 (set-buffer b) | |
208 (remove-images (point-min) (point-max)) | |
209 (if (and (file-regular-p imagefile) | |
210 (file-readable-p imagefile)) | |
211 (save-excursion | |
212 (setq buffer-read-only nil) | |
213 (cond | |
214 ((string-match "\\.\\(jpg\\|png\\)" imagefile) | |
215 (erase-buffer) | |
216 (YaTeX-popup-image imagefile b) | |
217 (YaTeX-filter-filter-set-conversion-flag)) | |
218 (t ;Convert again to PNG file | |
219 (goto-char (point-max)) | |
220 (insert "\nConvert Again to PNG file...\n") | |
221 (put 'YaTeX-filter-pngify-sentinel 'start (point)) | |
222 (set-process-sentinel | |
223 (start-process | |
224 "Filter" b ;Safe to reuse | |
225 shell-file-name YaTeX-shell-command-option | |
226 (format YaTeX-filter-pdf2png-stdout imagefile)) | |
227 'YaTeX-filter-pngify-sentinel) | |
228 (set-buffer-multibyte nil) | |
229 )) | |
230 (select-window selw))) | |
231 (YaTeX-preview-image-mode) | |
232 ) | |
233 (t ;Other status might be an error | |
234 (set-buffer b) | |
235 (goto-char (point-max)) | |
236 (insert (format "%s\n" (process-status proc)))))))) | |
237 | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
238 (defun YaTeX-filter-parse-filter-region (begend-info) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
239 "Return the list of SpecialFilter region. If not on, return nil. |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
240 BEGEND-INFO is a value from the function YaTeX-in-BEGEND-p. |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
241 Return the alist of: |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
242 '((outfile $OutPutFileName) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
243 (source $InputFileName) ; or nil for embeded data source |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
244 (cmdline $CommandLine) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
245 (begin $TextRegionBeginning) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
246 (end TextRegionEnd))" |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
247 (if begend-info |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
248 (let ((b (car begend-info)) (e (nth 1 begend-info)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
249 delim (args (nth 2 begend-info)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
250 (p (point)) openb closeb outfile source cmdline point-beg point-end) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
251 (save-excursion |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
252 (and |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
253 (string-match "FILTER" args) ;easy test |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
254 (goto-char (car begend-info)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
255 (re-search-forward |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
256 "FILTER\\s *{\\([^}]+\\)}" e t) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
257 (setq outfile (YaTeX-match-string 1)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
258 (goto-char (match-end 0)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
259 (prog2 ;Step into the second brace |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
260 (skip-chars-forward "\t ") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
261 (looking-at "{") ;Check if 2nd brace surely exists |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
262 (skip-chars-forward "{") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
263 (skip-chars-forward "\t")) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
264 (setq openb (point)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
265 (condition-case nil |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
266 (progn (up-list 1) t) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
267 (error nil)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
268 (setq closeb (1- (point)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
269 cmdline (YaTeX-buffer-substring openb closeb)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
270 (cond |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
271 ((re-search-forward "^\\\\if0\\>" p t) ;; Embedded source |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
272 (forward-line 1) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
273 (setq point-beg (if (looking-at "\\(.\\)\\1\\1") ;Triple chars |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
274 (progn (setq delim (YaTeX-match-string 0)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
275 (forward-line 1) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
276 (point)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
277 (point))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
278 (re-search-forward "^\\\\fi\\>" e t) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
279 (goto-char (match-beginning 0)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
280 (setq point-end (if delim |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
281 (progn |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
282 (re-search-backward |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
283 (concat "^" (regexp-quote delim)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
284 (1+ point-beg) t) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
285 (match-beginning 0)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
286 (point)))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
287 ((re-search-forward "^\\s *%#SRC{\\(.*\\)}" e t) ; external file |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
288 (setq source (YaTeX-match-string 1) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
289 point-beg (match-beginning 0) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
290 point-end (match-end 0))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
291 (t ;; If source notation not found, |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
292 (let ((ovl (overlays-in b e))) ;; clear all remaining overlays |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
293 (while ovl |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
294 (delete-overlay (car ovl)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
295 (setq ovl (cdr ovl)))))) ;; Return nil |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
296 |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
297 ;; Then return all values |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
298 (list (cons 'outfile outfile) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
299 (cons 'source source) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
300 (cons 'cmdline cmdline) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
301 (cons 'begin point-beg) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
302 (cons 'end point-end))))))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
303 |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
304 ;;debug;; (YaTeX-filter-parse-filter-region (YaTeX-in-BEGEND-p)) |
518 | 305 (defun YaTeX-filter-pass-to-filter (begend-info) |
306 "Pass current BEGIN FILTER environment to external command." | |
307 (put 'YaTeX-filter-filter-sentinel 'outfile nil) | |
308 ;; begend-info is from YaTeX-in-BEGEND-p: (BEG END ARGS) | |
309 (let ((b (car begend-info)) (e (nth 1 begend-info)) | |
545
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
310 (r (YaTeX-filter-parse-filter-region begend-info)) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
311 insmark) |
518 | 312 (save-excursion |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
313 (if r (let*((case-fold-search t) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
314 (outfile (cdr (assq 'outfile r))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
315 (source (cdr (assq 'source r))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
316 (type (cond |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
317 ((string-match "\\.png$" outfile) "png") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
318 ((string-match "\\.svg$" outfile) "svg") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
319 ((string-match "\\.tex$" outfile) "tex") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
320 (t "pdf"))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
321 (newcmdline (YaTeX-replace-formats |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
322 (cdr (assq 'cmdline r)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
323 (list (cons "t" type) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
324 (cons "o" outfile) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
325 (cons "i" source)))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
326 (text-start (cdr (assq 'begin r))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
327 (text-end (cdr (assq 'end r))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
328 (text (and (numberp text-start) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
329 (numberp text-end) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
330 (YaTeX-buffer-substring text-start text-end))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
331 ;; |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
332 ;; Now it's time to start filter process |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
333 ;; |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
334 (procbuf (YaTeX-system newcmdline "Filter" 'force)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
335 (proc (get-buffer-process procbuf)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
336 ;;(procbuf (get-buffer-create " *Filter*")) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
337 (ovl (progn |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
338 (remove-overlays text-start text-end) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
339 (make-overlay text-start text-end))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
340 (ovlmodhook ;hook function to reset conv-success flag |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
341 'YaTeX-filter-filter-unset-conversion-flag)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
342 (if proc |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
343 (progn |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
344 (overlay-put ovl 'filter-output outfile) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
345 (overlay-put ovl 'filter-source source) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
346 (overlay-put ovl 'converted nil) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
347 (overlay-put ovl 'modification-hooks (list ovlmodhook)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
348 (set-process-coding-system proc 'undecided 'utf-8) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
349 (set-process-sentinel proc 'YaTeX-filter-filter-sentinel) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
350 (YaTeX-showup-buffer procbuf) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
351 (set-buffer procbuf) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
352 (setq buffer-read-only nil) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
353 (erase-buffer) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
354 (insert (format "Starting process `%s'...\n" newcmdline)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
355 (set-marker (process-mark proc) (point-max)) |
545
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
356 (setq insmark (point-max)) |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
357 (cond |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
358 (text |
545
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
359 (process-send-string |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
360 proc |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
361 (if source |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
362 (progn |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
363 (insert-file-contents-literally source) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
364 (YaTeX-buffer-substring insmark (point-max))) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
365 text)) |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
366 (process-send-string proc "\n") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
367 (process-send-eof proc) ;Notify stream chunk end |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
368 (process-send-eof proc))) ;Notify real EOF |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
369 (put 'YaTeX-filter-filter-sentinel 'outfile outfile) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
370 (put 'YaTeX-filter-filter-sentinel 'overlay ovl)))))))) |
518 | 371 |
372 (defun YaTeX-insert-filter-special (filter list &optional region-p) | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
373 (let*((f (YaTeX-read-string-or-skip |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
374 "Output file(Maybe *.(pdf|png|jpg|tex)): ")) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
375 (insert-default-directory) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
376 (cmdargs (car list)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
377 (template-text (car (cdr list))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
378 (ifile (read-file-name "Data source(Default: in this buffer): " nil)) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
379 (in-line (string= "" ifile))) |
518 | 380 (if region-p |
381 (if (< (point) (mark)) (exchange-point-and-mark))) | |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
382 (save-excursion |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
383 (insert (if in-line "===\n\\fi\n" "") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
384 "%#END\n" |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
385 (cond |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
386 ((string-match "\\.tex$" f) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
387 (format "\\input{%s}\n" (substring f 0 (match-beginning 0)))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
388 ((string-match "\\.\\(pdf\\|png\\|jpe?g\\|tiff?\\)$" f) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
389 (format "%%# \\includegraphics{%s}\n" f))))) |
518 | 390 (and region-p (exchange-point-and-mark)) |
524
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
391 (insert (format "%%#BEGIN FILTER{%s}{%s}\n%s" |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
392 f (or cmdargs "") |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
393 (if in-line "\\if0\n===\n" ""))) |
b1896ef49747
Detection of region passed to filter modified.
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
394 (save-excursion |
545
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
395 (insert |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
396 (format "%%#%% If you call program in yatex-mode, type `%se'\n" |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
397 (key-description |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
398 (car (where-is-internal 'YaTeX-typeset-menu)))) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
399 (if in-line |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
400 (cond (template-text |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
401 (concat template-text |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
402 (or (string-match "\n$" template-text) "\n"))) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
403 (t "\n")) |
ea6956f10ce7
When %#SRC specified, should send content of that file.
HIROSE Yuuji <yuuji@gentei.org>
parents:
544
diff
changeset
|
404 (format "%%#SRC{%s}\n" ifile)))))) |
518 | 405 |
406 (provide 'yatexflt) | |
407 | |
408 ; Local variables: | |
409 ; fill-prefix: ";;; " | |
410 ; paragraph-start: "^$\\|\\|;;;$" | |
411 ; paragraph-separate: "^$\\|\\|;;;$" | |
412 ; End: |