yatex
diff yatexprc.el @ 377:81413ee9c32d
Use overlay to distinguish border of on-the-fly preview area.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 04 Jan 2015 19:05:28 +0900 |
parents | 1bbd0c2b340f |
children | 9452537530ac |
line diff
1.1 --- a/yatexprc.el Sun Jan 04 00:39:44 2015 +0900 1.2 +++ b/yatexprc.el Sun Jan 04 19:05:28 2015 +0900 1.3 @@ -1,7 +1,7 @@ 1.4 ;;; yatexprc.el --- YaTeX process handler 1.5 ;;; 1.6 ;;; (c)1993-2014 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Sat Jan 3 23:37:49 2015 on firestorm 1.8 +;;; Last modified Sun Jan 4 19:00:38 2015 on firestorm 1.9 ;;; $Id$ 1.10 1.11 ;;; Code: 1.12 @@ -297,10 +297,14 @@ 1.13 shell-file-name YaTeX-shell-command-option 1.14 ppcmd) 1.15 'YaTeX-typeset-sentinel)) 1.16 - (t ;pull back original mode-name 1.17 - ;;Confirm process buffer to be shown when error occured 1.18 - (YaTeX-showup-buffer pbuf 'YaTeX-showup-buffer-bottom-most) 1.19 - (message "Command FAILED!") 1.20 + (t 1.21 + (if (equal 0 (process-exit-status proc)) 1.22 + ;;Confirm process buffer to be shown when error 1.23 + (progn 1.24 + (YaTeX-showup-buffer 1.25 + pbuf 'YaTeX-showup-buffer-bottom-most) 1.26 + (message "Command FAILED!"))) 1.27 + ;;pull back original mode-name 1.28 (setq mode-name "typeset")))) 1.29 (forward-char 1)) 1.30 (setq YaTeX-typeset-process nil) 1.31 @@ -558,6 +562,7 @@ 1.32 (q (nth 4 plist)) 1.33 (st (nth 5 plist)) 1.34 (tm (nth 6 plist)) 1.35 + (overlay YaTeX-on-the-fly-overlay) 1.36 (thresh (* 2 (or (get 'YaTeX-typeset-conv2image-chain 'elapse) 1)))) 1.37 (cond 1.38 ;; In minibuffer, do nothing 1.39 @@ -566,16 +571,15 @@ 1.40 ;;;((and (message "s=%d, e=%d, p=%d" s e (point)) nil)) 1.41 ((or (not (eq b (window-buffer (selected-window)))) 1.42 (< (point) s) 1.43 - (> (point) e)) 1.44 + (not (overlayp overlay)) 1.45 + (not (eq (overlay-buffer overlay) (current-buffer))) 1.46 + (> (point) (overlay-end overlay))) 1.47 (YaTeX-typeset-environment-cancel-auto)) 1.48 ;;;((and (message "e=%d, p=%d t=%s" e (point) (current-time)) nil)) 1.49 ;; If recently called, hold 1.50 - ((< (YaTeX-elapsed-time tm (current-time)) thresh) 1.51 - nil) 1.52 + ;;; ((< (YaTeX-elapsed-time tm (current-time)) thresh) nil) 1.53 ;; If condition changed from last call, do it 1.54 - ((and (/= p (preceding-char)) 1.55 - (/= q (char-after (- (point) 1))) 1.56 - (not (string= st (YaTeX-buffer-substring s (min e (point-max)))))) 1.57 + ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay)))) 1.58 (YaTeX-typeset-environment))))) 1.59 1.60 (defun YaTeX-typeset-environment () 1.61 @@ -585,6 +589,13 @@ 1.62 (save-excursion 1.63 (let ((math (YaTeX-in-math-mode-p)) usetimer) 1.64 (cond 1.65 + ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay) 1.66 + (member YaTeX-on-the-fly-overlay (overlays-at (point)))) 1.67 + ;; If current position is in on-the-fly overlay, 1.68 + ;; use that region again 1.69 + (setq math (get 'YaTeX-typeset-conv2image-chain 'math)) 1.70 + (push-mark (overlay-start YaTeX-on-the-fly-overlay)) 1.71 + (goto-char (overlay-end YaTeX-on-the-fly-overlay))) 1.72 ((and (fboundp 'region-active-p) (region-active-p)) 1.73 nil) ;if region is active, use it 1.74 (math (setq usetimer t) (YaTeX-mark-environment)) 1.75 @@ -615,7 +626,7 @@ 1.76 ))) 1.77 (YaTeX-typeset-region))))) 1.78 1.79 -(defvar YaTeX-on-the-fly-preview-image (string-to-number "0.1") 1.80 +(defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9") 1.81 "*Control the on-the-fly update of preview environment by an image. 1.82 Nil disables on-the-fly update. Otherwise on-the-fly update is enabled 1.83 with update interval specified by this value.") 1.84 @@ -628,10 +639,10 @@ 1.85 (run-with-idle-timer 1.86 (max (string-to-number "0.1") 1.87 (cond 1.88 - ((numberp YaTeX-on-the-fly-preview-image) 1.89 - YaTeX-on-the-fly-preview-image) 1.90 - ((stringp YaTeX-on-the-fly-preview-image) 1.91 - (string-to-number YaTeX-on-the-fly-preview-image)) 1.92 + ((numberp YaTeX-on-the-fly-preview-interval) 1.93 + YaTeX-on-the-fly-preview-interval) 1.94 + ((stringp YaTeX-on-the-fly-preview-interval) 1.95 + (string-to-number YaTeX-on-the-fly-preview-interval)) 1.96 (t 1))) 1.97 t 'YaTeX-typeset-environment-timer)))) 1.98