yatex
changeset 377:81413ee9c32d dev
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 |
files | yatex23.el yatexprc.el |
diffstat | 2 files changed, 29 insertions(+), 18 deletions(-) [+] |
line diff
1.1 --- a/yatex23.el Sun Jan 04 00:39:44 2015 +0900 1.2 +++ b/yatex23.el Sun Jan 04 19:05:28 2015 +0900 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; yatex23.el --- YaTeX facilities for Emacs 23 or later -*- coding: sjis -*- 1.5 ;;; (c)2014 by HIROSE Yuuji.[yuuji@yatex.org] 1.6 -;;; Last modified Sat Jan 3 23:34:41 2015 on firestorm 1.7 +;;; Last modified Sun Jan 4 17:14:59 2015 on firestorm 1.8 ;;; $Id$ 1.9 1.10 ;;; Code: 1.11 @@ -89,7 +89,7 @@ 1.12 (insert "\\input{" path "}")))) 1.13 (t (message "%s" action))))) 1.14 1.15 -(defvar YaTeX-on-the-fly-bg-face '("#f0f0c0" . "#404020") 1.16 +(defvar YaTeX-on-the-fly-bg-face '("#f0f0c0" . "#706868") 1.17 "Background color of on-the-fly preview image activated environment.") 1.18 (defvar YaTeX-on-the-fly-overlay nil 1.19 "Overlay of on-the-fly preview image")
2.1 --- a/yatexprc.el Sun Jan 04 00:39:44 2015 +0900 2.2 +++ b/yatexprc.el Sun Jan 04 19:05:28 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 Sat Jan 3 23:37:49 2015 on firestorm 2.8 +;;; Last modified Sun Jan 4 19:00:38 2015 on firestorm 2.9 ;;; $Id$ 2.10 2.11 ;;; Code: 2.12 @@ -297,10 +297,14 @@ 2.13 shell-file-name YaTeX-shell-command-option 2.14 ppcmd) 2.15 'YaTeX-typeset-sentinel)) 2.16 - (t ;pull back original mode-name 2.17 - ;;Confirm process buffer to be shown when error occured 2.18 - (YaTeX-showup-buffer pbuf 'YaTeX-showup-buffer-bottom-most) 2.19 - (message "Command FAILED!") 2.20 + (t 2.21 + (if (equal 0 (process-exit-status proc)) 2.22 + ;;Confirm process buffer to be shown when error 2.23 + (progn 2.24 + (YaTeX-showup-buffer 2.25 + pbuf 'YaTeX-showup-buffer-bottom-most) 2.26 + (message "Command FAILED!"))) 2.27 + ;;pull back original mode-name 2.28 (setq mode-name "typeset")))) 2.29 (forward-char 1)) 2.30 (setq YaTeX-typeset-process nil) 2.31 @@ -558,6 +562,7 @@ 2.32 (q (nth 4 plist)) 2.33 (st (nth 5 plist)) 2.34 (tm (nth 6 plist)) 2.35 + (overlay YaTeX-on-the-fly-overlay) 2.36 (thresh (* 2 (or (get 'YaTeX-typeset-conv2image-chain 'elapse) 1)))) 2.37 (cond 2.38 ;; In minibuffer, do nothing 2.39 @@ -566,16 +571,15 @@ 2.40 ;;;((and (message "s=%d, e=%d, p=%d" s e (point)) nil)) 2.41 ((or (not (eq b (window-buffer (selected-window)))) 2.42 (< (point) s) 2.43 - (> (point) e)) 2.44 + (not (overlayp overlay)) 2.45 + (not (eq (overlay-buffer overlay) (current-buffer))) 2.46 + (> (point) (overlay-end overlay))) 2.47 (YaTeX-typeset-environment-cancel-auto)) 2.48 ;;;((and (message "e=%d, p=%d t=%s" e (point) (current-time)) nil)) 2.49 ;; If recently called, hold 2.50 - ((< (YaTeX-elapsed-time tm (current-time)) thresh) 2.51 - nil) 2.52 + ;;; ((< (YaTeX-elapsed-time tm (current-time)) thresh) nil) 2.53 ;; If condition changed from last call, do it 2.54 - ((and (/= p (preceding-char)) 2.55 - (/= q (char-after (- (point) 1))) 2.56 - (not (string= st (YaTeX-buffer-substring s (min e (point-max)))))) 2.57 + ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay)))) 2.58 (YaTeX-typeset-environment))))) 2.59 2.60 (defun YaTeX-typeset-environment () 2.61 @@ -585,6 +589,13 @@ 2.62 (save-excursion 2.63 (let ((math (YaTeX-in-math-mode-p)) usetimer) 2.64 (cond 2.65 + ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay) 2.66 + (member YaTeX-on-the-fly-overlay (overlays-at (point)))) 2.67 + ;; If current position is in on-the-fly overlay, 2.68 + ;; use that region again 2.69 + (setq math (get 'YaTeX-typeset-conv2image-chain 'math)) 2.70 + (push-mark (overlay-start YaTeX-on-the-fly-overlay)) 2.71 + (goto-char (overlay-end YaTeX-on-the-fly-overlay))) 2.72 ((and (fboundp 'region-active-p) (region-active-p)) 2.73 nil) ;if region is active, use it 2.74 (math (setq usetimer t) (YaTeX-mark-environment)) 2.75 @@ -615,7 +626,7 @@ 2.76 ))) 2.77 (YaTeX-typeset-region))))) 2.78 2.79 -(defvar YaTeX-on-the-fly-preview-image (string-to-number "0.1") 2.80 +(defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9") 2.81 "*Control the on-the-fly update of preview environment by an image. 2.82 Nil disables on-the-fly update. Otherwise on-the-fly update is enabled 2.83 with update interval specified by this value.") 2.84 @@ -628,10 +639,10 @@ 2.85 (run-with-idle-timer 2.86 (max (string-to-number "0.1") 2.87 (cond 2.88 - ((numberp YaTeX-on-the-fly-preview-image) 2.89 - YaTeX-on-the-fly-preview-image) 2.90 - ((stringp YaTeX-on-the-fly-preview-image) 2.91 - (string-to-number YaTeX-on-the-fly-preview-image)) 2.92 + ((numberp YaTeX-on-the-fly-preview-interval) 2.93 + YaTeX-on-the-fly-preview-interval) 2.94 + ((stringp YaTeX-on-the-fly-preview-interval) 2.95 + (string-to-number YaTeX-on-the-fly-preview-interval)) 2.96 (t 1))) 2.97 t 'YaTeX-typeset-environment-timer)))) 2.98