Mercurial > hgrepos > hgweb.cgi > yatex
comparison 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 |
comparison
equal
deleted
inserted
replaced
544:ab6c176c676a | 545:ea6956f10ce7 |
---|---|
1 ;;; yatexflt.el --- YaTeX filter command utilizer -*- coding: sjis -*- | 1 ;;; yatexflt.el --- YaTeX filter command utilizer -*- coding: sjis -*- |
2 ;;; | 2 ;;; |
3 ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org] | 3 ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org] |
4 ;;; Last modified Fri Jun 1 08:28:40 2018 on firestorm | 4 ;;; Last modified Sat Jun 2 15:55:38 2018 on firestorm |
5 ;;; $Id$ | 5 ;;; $Id$ |
6 | 6 |
7 ;;; Commentary: | 7 ;;; Commentary: |
8 ;;; | 8 ;;; |
9 ;;; This lisp enables passing inline text to some external filter | 9 ;;; This lisp enables passing inline text to some external filter |
305 (defun YaTeX-filter-pass-to-filter (begend-info) | 305 (defun YaTeX-filter-pass-to-filter (begend-info) |
306 "Pass current BEGIN FILTER environment to external command." | 306 "Pass current BEGIN FILTER environment to external command." |
307 (put 'YaTeX-filter-filter-sentinel 'outfile nil) | 307 (put 'YaTeX-filter-filter-sentinel 'outfile nil) |
308 ;; begend-info is from YaTeX-in-BEGEND-p: (BEG END ARGS) | 308 ;; begend-info is from YaTeX-in-BEGEND-p: (BEG END ARGS) |
309 (let ((b (car begend-info)) (e (nth 1 begend-info)) | 309 (let ((b (car begend-info)) (e (nth 1 begend-info)) |
310 (r (YaTeX-filter-parse-filter-region begend-info))) | 310 (r (YaTeX-filter-parse-filter-region begend-info)) |
311 insmark) | |
311 (save-excursion | 312 (save-excursion |
312 (if r (let*((case-fold-search t) | 313 (if r (let*((case-fold-search t) |
313 (outfile (cdr (assq 'outfile r))) | 314 (outfile (cdr (assq 'outfile r))) |
314 (source (cdr (assq 'source r))) | 315 (source (cdr (assq 'source r))) |
315 (type (cond | 316 (type (cond |
350 (set-buffer procbuf) | 351 (set-buffer procbuf) |
351 (setq buffer-read-only nil) | 352 (setq buffer-read-only nil) |
352 (erase-buffer) | 353 (erase-buffer) |
353 (insert (format "Starting process `%s'...\n" newcmdline)) | 354 (insert (format "Starting process `%s'...\n" newcmdline)) |
354 (set-marker (process-mark proc) (point-max)) | 355 (set-marker (process-mark proc) (point-max)) |
356 (setq insmark (point-max)) | |
355 (cond | 357 (cond |
356 (text | 358 (text |
357 (process-send-string proc text) | 359 (process-send-string |
360 proc | |
361 (if source | |
362 (progn | |
363 (insert-file-contents-literally source) | |
364 (YaTeX-buffer-substring insmark (point-max))) | |
365 text)) | |
358 (process-send-string proc "\n") | 366 (process-send-string proc "\n") |
359 (process-send-eof proc) ;Notify stream chunk end | 367 (process-send-eof proc) ;Notify stream chunk end |
360 (process-send-eof proc))) ;Notify real EOF | 368 (process-send-eof proc))) ;Notify real EOF |
361 (put 'YaTeX-filter-filter-sentinel 'outfile outfile) | 369 (put 'YaTeX-filter-filter-sentinel 'outfile outfile) |
362 (put 'YaTeX-filter-filter-sentinel 'overlay ovl)))))))) | 370 (put 'YaTeX-filter-filter-sentinel 'overlay ovl)))))))) |
382 (and region-p (exchange-point-and-mark)) | 390 (and region-p (exchange-point-and-mark)) |
383 (insert (format "%%#BEGIN FILTER{%s}{%s}\n%s" | 391 (insert (format "%%#BEGIN FILTER{%s}{%s}\n%s" |
384 f (or cmdargs "") | 392 f (or cmdargs "") |
385 (if in-line "\\if0\n===\n" ""))) | 393 (if in-line "\\if0\n===\n" ""))) |
386 (save-excursion | 394 (save-excursion |
387 (insert (if in-line | 395 (insert |
388 (cond (template-text | 396 (format "%%#%% If you call program in yatex-mode, type `%se'\n" |
389 (concat template-text | 397 (key-description |
390 (or (string-match "\n$" template-text) "\n"))) | 398 (car (where-is-internal 'YaTeX-typeset-menu)))) |
391 (t "\n")) | 399 (if in-line |
392 (format "%%#SRC{%s}\n" ifile)))))) | 400 (cond (template-text |
401 (concat template-text | |
402 (or (string-match "\n$" template-text) "\n"))) | |
403 (t "\n")) | |
404 (format "%%#SRC{%s}\n" ifile)))))) | |
393 | 405 |
394 (provide 'yatexflt) | 406 (provide 'yatexflt) |
395 | 407 |
396 ; Local variables: | 408 ; Local variables: |
397 ; fill-prefix: ";;; " | 409 ; fill-prefix: ";;; " |