yatex

diff yatexprc.el @ 517:668632d9392e

Initial implementation of SpecialFilterRegion
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 06 Jan 2018 23:54:17 +0900
parents 8e0822416fc6
children a6a80e2b6f5a
line diff
     1.1 --- a/yatexprc.el	Thu Jan 04 23:53:17 2018 +0900
     1.2 +++ b/yatexprc.el	Sat Jan 06 23:54:17 2018 +0900
     1.3 @@ -1,7 +1,7 @@
     1.4  ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*-
     1.5  ;;; 
     1.6  ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Thu Jan  4 00:09:28 2018 on firestorm
     1.8 +;;; Last modified Fri Jan  5 22:48:43 2018 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;; Code:
    1.12 @@ -353,7 +353,7 @@
    1.13  	 reg-begin reg-end lineinfo)
    1.14        (setq ppcmd (if (stringp pp) (concat pp " " texputroot) pp))
    1.15        (save-excursion
    1.16 -	(if (search-backward "%#BEGIN" nil t)
    1.17 +	(if (re-search-backward "%#BEGIN\\s *$" nil t)
    1.18  	    (progn
    1.19  	      (setq typeout "--- Region from BEGIN to "
    1.20  		    end "the end of the buffer ---"
    1.21 @@ -478,6 +478,36 @@
    1.22  The value is generated from YaTeX-typeset-pdf2image-chain and
    1.23  YaTeX-typeset-dvi2image-chain.")
    1.24  
    1.25 +(defun YaTeX-popup-image (imagesrc buffer &optional func)
    1.26 +  (let ((sw (selected-window)) image
    1.27 +	(data-p (and (> (length imagesrc) 128)
    1.28 +		     (not (file-readable-p imagesrc)))))
    1.29 +    (save-excursion
    1.30 +      (cond
    1.31 +       ((featurep 'image) window-system
    1.32 +	(YaTeX-showup-buffer		;showup and select
    1.33 +	 (get-buffer-create buffer)
    1.34 +	 (or func 'YaTeX-showup-buffer-bottom-most)
    1.35 +	 t)
    1.36 +	(remove-images (point-min) (point-max))
    1.37 +	(erase-buffer)
    1.38 +	(insert-image
    1.39 +	 (setq image (create-image
    1.40 +		      (if data-p imagesrc (expand-file-name imagesrc))
    1.41 +		      nil data-p)))
    1.42 +	(YaTeX-preview-image-mode)
    1.43 +	(let ((height (1+ (cdr (image-size image)))))
    1.44 +	  (enlarge-window
    1.45 +	   (- (ceiling (min height (/ (frame-height) 2)))
    1.46 +	      (window-height))))
    1.47 +	(select-window sw))
    1.48 +       (t	;; Without direct image, display image with image viewer
    1.49 +	(YaTeX-system
    1.50 +	 (format "%s %s" YaTeX-cmd-view-images target)
    1.51 +	 "YaTeX-region-image"
    1.52 +	 'noask)))
    1.53 +  )))
    1.54 +
    1.55  (defvar YaTeX-typeset-conv2image-process nil "Process of conv2image chain")
    1.56  (defun YaTeX-typeset-conv2image-chain ()
    1.57    (let*((proc (or YaTeX-typeset-process YaTeX-typeset-conv2image-process))
    1.58 @@ -531,39 +561,11 @@
    1.59  			     'YaTeX-typeset-conv2image-chain)
    1.60  		       (get 'YaTeX-typeset-process 'ppcmd))))
    1.61  	;; After all chain executed, display image in current window
    1.62 -	(cond
    1.63 -	 ((and (featurep 'image) window-system)
    1.64 -	  ;; If direct image displaying available in running Emacs,
    1.65 -	  ;; display target image into the next window in Emacs.
    1.66 -	  (select-window w)
    1.67 -	  ;(setq foo (selected-window))
    1.68 -	  (YaTeX-showup-buffer
    1.69 -	   (get-buffer-create " *YaTeX-region-image*")
    1.70 -	   'YaTeX-showup-buffer-bottom-most t)
    1.71 -	  (remove-images (point-min) (point-max))
    1.72 -	  (erase-buffer)
    1.73 -	  (cd pwd)			;when reuse from other source
    1.74 -					;(put-image (create-image (expand-file-name target)) (point))
    1.75 -	  (insert-image-file target)
    1.76 -	  (setq img (plist-get (text-properties-at (point)) 'intangible))
    1.77 -	  (YaTeX-preview-image-mode)
    1.78 -	  (if img
    1.79 -	      (let ((height (1+ (cdr (image-size img)))))
    1.80 -		(enlarge-window
    1.81 -		 (- (ceiling (min height (/ (frame-height) 2)))
    1.82 -		    (window-height)))))
    1.83 -	  ;; Remember elapsed time, which will be threshold in onthefly-preview
    1.84 -	  (put 'YaTeX-typeset-conv2image-chain 'elapse
    1.85 -	       (YaTeX-elapsed-time
    1.86 -		(get 'YaTeX-typeset-conv2image-chain 'start) (current-time))))
    1.87 -	 (t
    1.88 -	  ;; Without direct image, display image with image viewer
    1.89 -	  (YaTeX-system
    1.90 -	   (format "%s %s" YaTeX-cmd-view-images target)
    1.91 -	   "YaTeX-region-image"
    1.92 -	   'noask)
    1.93 -	  )
    1.94 -	 )))))
    1.95 +	(YaTeX-popup-image target " *YaTeX-popup-image*")
    1.96 +	(put 'YaTeX-typeset-conv2image-chain 'elapse
    1.97 +	     (YaTeX-elapsed-time
    1.98 +	      (get 'YaTeX-typeset-conv2image-chain 'start) (current-time)))
    1.99 +	))))
   1.100  
   1.101  
   1.102  (defvar YaTeX-typeset-environment-timer nil)
   1.103 @@ -657,6 +659,14 @@
   1.104  	  (if usetimer (YaTeX-typeset-environment-auto b e)))
   1.105        (YaTeX-typeset-region))))
   1.106  
   1.107 +(defun YaTeX-filter-BEGEND ()
   1.108 +  (let ((begend-info (YaTeX-in-BEGEND-p)))
   1.109 +    (if begend-info
   1.110 +	(progn
   1.111 +	  (require 'yatexflt)
   1.112 +	  (YaTeX-filter-pass-to-filter begend-info)
   1.113 +	  ))))
   1.114 +
   1.115  (defun YaTeX-typeset-environment ()
   1.116    "Typeset current environment or paragraph.
   1.117  If region activated, use it."
   1.118 @@ -664,7 +674,8 @@
   1.119    (let ((md (match-data)))
   1.120      (unwind-protect
   1.121  	(save-excursion
   1.122 -	  (YaTeX-typeset-environment-1))
   1.123 +	  (or (YaTeX-filter-BEGEND)
   1.124 +	      (YaTeX-typeset-environment-1)))
   1.125        (store-match-data md))))
   1.126  
   1.127