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