yatex

changeset 380:f061b37c7542 dev

Equalize boundary of non-math environment with math environment.
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 04 Jan 2015 21:41:00 +0900
parents 09a2b5a3b3d8
children fc1ad3b337a9
files yatexlib.el yatexprc.el
diffstat 2 files changed, 53 insertions(+), 44 deletions(-) [+]
line diff
     1.1 --- a/yatexlib.el	Sun Jan 04 21:06:32 2015 +0900
     1.2 +++ b/yatexlib.el	Sun Jan 04 21:41:00 2015 +0900
     1.3 @@ -1,7 +1,7 @@
     1.4  ;;; yatexlib.el --- YaTeX and yahtml common libraries
     1.5  ;;; 
     1.6  ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Sun Jan  4 00:16:04 2015 on firestorm
     1.8 +;;; Last modified Sun Jan  4 21:04:29 2015 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;; Code:
    1.12 @@ -1119,7 +1119,7 @@
    1.13  	    (goto-char curp)
    1.14  	    (error "Cannot found the end of current environment."))
    1.15  	(YaTeX-goto-corresponding-environment)
    1.16 -	(beginning-of-line)		;for confirmation
    1.17 +	;;(beginning-of-line)		;for confirmation ;OUT 2015/1/4
    1.18  	(if (< curp (point))
    1.19  	    (progn
    1.20  	      (message "Mark this environment?(y or n): ")
    1.21 @@ -1128,8 +1128,10 @@
    1.22  		(error "Abort.  Please call again at more proper position."))))
    1.23  	(set-mark-command nil)
    1.24  	(YaTeX-goto-corresponding-environment)
    1.25 -	(end-of-line)
    1.26 -	(if (eobp) nil (forward-char 1))))))
    1.27 +	(goto-char (match-end 0))
    1.28 +	;;(end-of-line)				;OUT 2015/1/5
    1.29 +	;;(if (eobp) nil (forward-char 1))	;OUT 2015/1/5
    1.30 +	))))
    1.31  
    1.32  (defun YaTeX-kill-buffer (buffer)
    1.33    "Make effort to show parent buffer after kill."
     2.1 --- a/yatexprc.el	Sun Jan 04 21:06:32 2015 +0900
     2.2 +++ b/yatexprc.el	Sun Jan 04 21:41:00 2015 +0900
     2.3 @@ -1,7 +1,7 @@
     2.4  ;;; yatexprc.el --- YaTeX process handler
     2.5  ;;; 
     2.6  ;;; (c)1993-2014 by HIROSE Yuuji.[yuuji@yatex.org]
     2.7 -;;; Last modified Sun Jan  4 19:11:36 2015 on firestorm
     2.8 +;;; Last modified Sun Jan  4 19:56:26 2015 on firestorm
     2.9  ;;; $Id$
    2.10  
    2.11  ;;; Code:
    2.12 @@ -582,49 +582,56 @@
    2.13       ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay))))
    2.14        (YaTeX-typeset-environment)))))
    2.15  
    2.16 +(defun YaTeX-typeset-environment-1 ()
    2.17 +  (let ((math (YaTeX-in-math-mode-p)) usetimer)
    2.18 +    (cond
    2.19 +     ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay)
    2.20 +	   (member YaTeX-on-the-fly-overlay (overlays-at (point))))
    2.21 +      ;; If current position is in on-the-fly overlay,
    2.22 +      ;; use that region again
    2.23 +      (setq math (get 'YaTeX-typeset-conv2image-chain 'math))
    2.24 +      (push-mark (overlay-start YaTeX-on-the-fly-overlay))
    2.25 +      (goto-char (overlay-end YaTeX-on-the-fly-overlay)))
    2.26 +     ((and (fboundp 'region-active-p) (region-active-p))
    2.27 +      nil)				;if region is active, use it
    2.28 +     (math (setq usetimer t) (YaTeX-mark-environment))
    2.29 +     ((equal (or (YaTeX-inner-environment t) "document") "document")
    2.30 +      (mark-paragraph))
    2.31 +     (t (setq usetimer t) (YaTeX-mark-environment)))
    2.32 +    (if YaTeX-use-image-preview
    2.33 +	(let ((YaTeX-typeset-buffer (concat "*bg:" YaTeX-typeset-buffer))
    2.34 +	      (b (region-beginning)) (e (region-end)))
    2.35 +	  (put 'YaTeX-typeset-conv2image-chain 'math math)
    2.36 +	  (put 'YaTeX-typeset-conv2image-chain 'srctype nil)
    2.37 +	  (put 'YaTeX-typeset-conv2image-chain 'win (selected-window))
    2.38 +	  (put 'YaTeX-typeset-conv2image-chain 'start (current-time))
    2.39 +	  (put 'YaTeX-typeset-environment-timer 'laststate
    2.40 +	       (list (current-buffer) b e (preceding-char)
    2.41 +		     (char-after (- (point) 2))
    2.42 +		     (YaTeX-buffer-substring b e)
    2.43 +		     (current-time)))
    2.44 +	  (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain)
    2.45 +	  (if usetimer
    2.46 +	      (progn
    2.47 +		(if YaTeX-on-the-fly-overlay
    2.48 +		    (move-overlay YaTeX-on-the-fly-overlay b e)
    2.49 +		  (overlay-put
    2.50 +		   (setq YaTeX-on-the-fly-overlay (make-overlay b e))
    2.51 +		   'face 'YaTeX-on-the-fly-activated-face))
    2.52 +		(YaTeX-typeset-environment-auto)
    2.53 +		)))
    2.54 +      (YaTeX-typeset-region))))
    2.55 +
    2.56  (defun YaTeX-typeset-environment ()
    2.57    "Typeset current environment or paragraph.
    2.58  If region activated, use it."
    2.59    (interactive)
    2.60 -  (save-excursion
    2.61 -    (let ((math (YaTeX-in-math-mode-p)) usetimer)
    2.62 -      (cond
    2.63 -       ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay)
    2.64 -	     (member YaTeX-on-the-fly-overlay (overlays-at (point))))
    2.65 -	;; If current position is in on-the-fly overlay,
    2.66 -	;; use that region again
    2.67 -	(setq math (get 'YaTeX-typeset-conv2image-chain 'math))
    2.68 -	(push-mark (overlay-start YaTeX-on-the-fly-overlay))
    2.69 -	(goto-char (overlay-end YaTeX-on-the-fly-overlay)))
    2.70 -       ((and (fboundp 'region-active-p) (region-active-p))
    2.71 -	nil)				;if region is active, use it
    2.72 -       (math (setq usetimer t) (YaTeX-mark-environment))
    2.73 -       ((equal (or (YaTeX-inner-environment t) "document") "document")
    2.74 -	(mark-paragraph))
    2.75 -       (t (setq usetimer t) (YaTeX-mark-environment)))
    2.76 -      (if YaTeX-use-image-preview
    2.77 -	  (let ((YaTeX-typeset-buffer (concat "*bg:" YaTeX-typeset-buffer))
    2.78 -		(b (region-beginning)) (e (region-end)))
    2.79 -	    (put 'YaTeX-typeset-conv2image-chain 'math math)
    2.80 -	    (put 'YaTeX-typeset-conv2image-chain 'srctype nil)
    2.81 -	    (put 'YaTeX-typeset-conv2image-chain 'win (selected-window))
    2.82 -	    (put 'YaTeX-typeset-conv2image-chain 'start (current-time))
    2.83 -	    (put 'YaTeX-typeset-environment-timer 'laststate
    2.84 -		 (list (current-buffer) b e (preceding-char)
    2.85 -		       (char-after (- (point) 2))
    2.86 -		       (YaTeX-buffer-substring b e)
    2.87 -		       (current-time)))
    2.88 -	    (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain)
    2.89 -	    (if usetimer
    2.90 -		(progn
    2.91 -		  (if YaTeX-on-the-fly-overlay
    2.92 -		      (move-overlay YaTeX-on-the-fly-overlay b e)
    2.93 -		    (overlay-put
    2.94 -		     (setq YaTeX-on-the-fly-overlay (make-overlay b e))
    2.95 -		     'face 'YaTeX-on-the-fly-activated-face))
    2.96 -		  (YaTeX-typeset-environment-auto)
    2.97 -		  )))
    2.98 -	(YaTeX-typeset-region)))))
    2.99 +  (let ((md (match-data)))
   2.100 +    (unwind-protect
   2.101 +	(save-excursion
   2.102 +	  (YaTeX-typeset-environment-1))
   2.103 +      (store-match-data md))))
   2.104 +
   2.105  
   2.106  (defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9")
   2.107    "*Control the on-the-fly update of preview environment by an image.