yatex

changeset 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 071cd0ab1c71
files yatex.el yatexflt.el
diffstat 2 files changed, 38 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/yatex.el	Sat Jun 02 10:39:58 2018 +0900
     1.2 +++ b/yatex.el	Sat Jun 02 15:57:55 2018 +0900
     1.3 @@ -1,6 +1,6 @@
     1.4  ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*-
     1.5  ;;; (c)1991-2018 by HIROSE Yuuji.[yuuji@yatex.org]
     1.6 -;;; Last modified Fri Jun  1 08:30:26 2018 on firestorm
     1.7 +;;; Last modified Sat Jun  2 14:13:17 2018 on firestorm
     1.8  ;;; $Id$
     1.9  ;;; The latest version of this software is always available at;
    1.10  ;;; https://www.yatex.org/
    1.11 @@ -1955,8 +1955,9 @@
    1.12  
    1.13  (defun YaTeX-goto-corresponding-file (&optional other)
    1.14    "Visit or switch buffer of corresponding file,
    1.15 -looking at \\input or \\include or \\includeonly on current line."
    1.16 -  (if (not (YaTeX-on-includes-p)) nil
    1.17 +looking at \\input or \\include or \\includeonly or %#SRC{} on current line."
    1.18 +  (cond
    1.19 +   ((YaTeX-on-includes-p)
    1.20      (let ((parent buffer-file-name) input-file b)
    1.21        (save-excursion
    1.22  	(if (and (re-search-forward "[{%]" (point-end-of-line) t)
    1.23 @@ -1975,7 +1976,12 @@
    1.24         (t (YaTeX-switch-to-buffer input-file)))
    1.25        (or (YaTeX-get-builtin "!")
    1.26  	  YaTeX-parent-file
    1.27 -	  (setq YaTeX-parent-file parent)))))
    1.28 +	  (setq YaTeX-parent-file parent))))
    1.29 +   ;; On %#SRC{somefilters.src}
    1.30 +   ((YaTeX-on-SRC-p)
    1.31 +    (let ((src (YaTeX-match-string 1)))
    1.32 +      (if other (YaTeX-switch-to-buffer-other-window src)
    1.33 +	(goto-buffer-window (find-file-noselect src)))))))
    1.34  
    1.35  (defun YaTeX-goto-corresponding-BEGIN-END ()
    1.36    (if (not (YaTeX-on-BEGIN-END-p)) nil
    1.37 @@ -2273,6 +2279,13 @@
    1.38        (re-search-forward
    1.39         "\\(%#BEGIN\\)\\|\\(%#END\\)" (point-end-of-line) t))))
    1.40  
    1.41 +(defun YaTeX-on-SRC-p ()
    1.42 +  (save-excursion
    1.43 +    (let ((case-fold-search nil))
    1.44 +      (beginning-of-line)
    1.45 +      (re-search-forward
    1.46 +       "%#SRC{\\([^}]+\\)}" (point-end-of-line) t))))
    1.47 +
    1.48  (defun YaTeX-goto-corresponding-* (arg)
    1.49    "Parse current line and call suitable function."
    1.50    (interactive "P")
     2.1 --- a/yatexflt.el	Sat Jun 02 10:39:58 2018 +0900
     2.2 +++ b/yatexflt.el	Sat Jun 02 15:57:55 2018 +0900
     2.3 @@ -1,7 +1,7 @@
     2.4  ;;; yatexflt.el --- YaTeX filter command utilizer -*- coding: sjis -*-
     2.5  ;;; 
     2.6  ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org]
     2.7 -;;; Last modified Fri Jun  1 08:28:40 2018 on firestorm
     2.8 +;;; Last modified Sat Jun  2 15:55:38 2018 on firestorm
     2.9  ;;; $Id$
    2.10  
    2.11  ;;; Commentary:
    2.12 @@ -307,7 +307,8 @@
    2.13    (put 'YaTeX-filter-filter-sentinel 'outfile nil)
    2.14    ;; begend-info is from YaTeX-in-BEGEND-p: (BEG END ARGS)
    2.15    (let ((b (car begend-info)) (e (nth 1 begend-info))
    2.16 -	(r (YaTeX-filter-parse-filter-region begend-info)))
    2.17 +	(r (YaTeX-filter-parse-filter-region begend-info))
    2.18 +	insmark)
    2.19      (save-excursion
    2.20        (if r (let*((case-fold-search t)
    2.21  		  (outfile (cdr (assq 'outfile r)))
    2.22 @@ -352,9 +353,16 @@
    2.23  		    (erase-buffer)
    2.24  		    (insert (format "Starting process `%s'...\n" newcmdline))
    2.25  		    (set-marker (process-mark proc) (point-max))
    2.26 +		    (setq insmark (point-max))
    2.27  		    (cond
    2.28  		     (text
    2.29 -		      (process-send-string proc text)
    2.30 +		      (process-send-string
    2.31 +		       proc
    2.32 +		       (if source
    2.33 +			   (progn
    2.34 +			     (insert-file-contents-literally source)
    2.35 +			     (YaTeX-buffer-substring insmark (point-max)))
    2.36 +			 text))
    2.37  		      (process-send-string proc "\n")
    2.38  		      (process-send-eof proc)	;Notify stream chunk end
    2.39  		      (process-send-eof proc)))	;Notify real EOF
    2.40 @@ -384,12 +392,16 @@
    2.41  		    f (or cmdargs "")
    2.42  		    (if in-line "\\if0\n===\n" "")))
    2.43      (save-excursion
    2.44 -      (insert (if in-line
    2.45 -		  (cond (template-text
    2.46 -			 (concat template-text
    2.47 -				 (or (string-match "\n$" template-text) "\n")))
    2.48 -			(t "\n"))
    2.49 -		(format "%%#SRC{%s}\n" ifile))))))
    2.50 +      (insert
    2.51 +       (format "%%#%% If you call program in yatex-mode, type `%se'\n"
    2.52 +	       (key-description
    2.53 +		(car (where-is-internal 'YaTeX-typeset-menu))))
    2.54 +       (if in-line
    2.55 +	   (cond (template-text
    2.56 +		  (concat template-text
    2.57 +			  (or (string-match "\n$" template-text) "\n")))
    2.58 +		 (t "\n"))
    2.59 +	 (format "%%#SRC{%s}\n" ifile))))))
    2.60  
    2.61  (provide 'yatexflt)
    2.62