comparison yatexprc.el @ 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 9452537530ac
children fc1ad3b337a9
comparison
equal deleted inserted replaced
379:09a2b5a3b3d8 380:f061b37c7542
1 ;;; yatexprc.el --- YaTeX process handler 1 ;;; yatexprc.el --- YaTeX process handler
2 ;;; 2 ;;;
3 ;;; (c)1993-2014 by HIROSE Yuuji.[yuuji@yatex.org] 3 ;;; (c)1993-2014 by HIROSE Yuuji.[yuuji@yatex.org]
4 ;;; Last modified Sun Jan 4 19:11:36 2015 on firestorm 4 ;;; Last modified Sun Jan 4 19:56:26 2015 on firestorm
5 ;;; $Id$ 5 ;;; $Id$
6 6
7 ;;; Code: 7 ;;; Code:
8 ;(require 'yatex) 8 ;(require 'yatex)
9 (require 'yatexlib) 9 (require 'yatexlib)
580 ;;; ((< (YaTeX-elapsed-time tm (current-time)) thresh) nil) 580 ;;; ((< (YaTeX-elapsed-time tm (current-time)) thresh) nil)
581 ;; If condition changed from last call, do it 581 ;; If condition changed from last call, do it
582 ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay)))) 582 ((not (string= st (YaTeX-buffer-substring s (overlay-end overlay))))
583 (YaTeX-typeset-environment))))) 583 (YaTeX-typeset-environment)))))
584 584
585 (defun YaTeX-typeset-environment-1 ()
586 (let ((math (YaTeX-in-math-mode-p)) usetimer)
587 (cond
588 ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay)
589 (member YaTeX-on-the-fly-overlay (overlays-at (point))))
590 ;; If current position is in on-the-fly overlay,
591 ;; use that region again
592 (setq math (get 'YaTeX-typeset-conv2image-chain 'math))
593 (push-mark (overlay-start YaTeX-on-the-fly-overlay))
594 (goto-char (overlay-end YaTeX-on-the-fly-overlay)))
595 ((and (fboundp 'region-active-p) (region-active-p))
596 nil) ;if region is active, use it
597 (math (setq usetimer t) (YaTeX-mark-environment))
598 ((equal (or (YaTeX-inner-environment t) "document") "document")
599 (mark-paragraph))
600 (t (setq usetimer t) (YaTeX-mark-environment)))
601 (if YaTeX-use-image-preview
602 (let ((YaTeX-typeset-buffer (concat "*bg:" YaTeX-typeset-buffer))
603 (b (region-beginning)) (e (region-end)))
604 (put 'YaTeX-typeset-conv2image-chain 'math math)
605 (put 'YaTeX-typeset-conv2image-chain 'srctype nil)
606 (put 'YaTeX-typeset-conv2image-chain 'win (selected-window))
607 (put 'YaTeX-typeset-conv2image-chain 'start (current-time))
608 (put 'YaTeX-typeset-environment-timer 'laststate
609 (list (current-buffer) b e (preceding-char)
610 (char-after (- (point) 2))
611 (YaTeX-buffer-substring b e)
612 (current-time)))
613 (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain)
614 (if usetimer
615 (progn
616 (if YaTeX-on-the-fly-overlay
617 (move-overlay YaTeX-on-the-fly-overlay b e)
618 (overlay-put
619 (setq YaTeX-on-the-fly-overlay (make-overlay b e))
620 'face 'YaTeX-on-the-fly-activated-face))
621 (YaTeX-typeset-environment-auto)
622 )))
623 (YaTeX-typeset-region))))
624
585 (defun YaTeX-typeset-environment () 625 (defun YaTeX-typeset-environment ()
586 "Typeset current environment or paragraph. 626 "Typeset current environment or paragraph.
587 If region activated, use it." 627 If region activated, use it."
588 (interactive) 628 (interactive)
589 (save-excursion 629 (let ((md (match-data)))
590 (let ((math (YaTeX-in-math-mode-p)) usetimer) 630 (unwind-protect
591 (cond 631 (save-excursion
592 ((and YaTeX-on-the-fly-overlay (overlayp YaTeX-on-the-fly-overlay) 632 (YaTeX-typeset-environment-1))
593 (member YaTeX-on-the-fly-overlay (overlays-at (point)))) 633 (store-match-data md))))
594 ;; If current position is in on-the-fly overlay, 634
595 ;; use that region again
596 (setq math (get 'YaTeX-typeset-conv2image-chain 'math))
597 (push-mark (overlay-start YaTeX-on-the-fly-overlay))
598 (goto-char (overlay-end YaTeX-on-the-fly-overlay)))
599 ((and (fboundp 'region-active-p) (region-active-p))
600 nil) ;if region is active, use it
601 (math (setq usetimer t) (YaTeX-mark-environment))
602 ((equal (or (YaTeX-inner-environment t) "document") "document")
603 (mark-paragraph))
604 (t (setq usetimer t) (YaTeX-mark-environment)))
605 (if YaTeX-use-image-preview
606 (let ((YaTeX-typeset-buffer (concat "*bg:" YaTeX-typeset-buffer))
607 (b (region-beginning)) (e (region-end)))
608 (put 'YaTeX-typeset-conv2image-chain 'math math)
609 (put 'YaTeX-typeset-conv2image-chain 'srctype nil)
610 (put 'YaTeX-typeset-conv2image-chain 'win (selected-window))
611 (put 'YaTeX-typeset-conv2image-chain 'start (current-time))
612 (put 'YaTeX-typeset-environment-timer 'laststate
613 (list (current-buffer) b e (preceding-char)
614 (char-after (- (point) 2))
615 (YaTeX-buffer-substring b e)
616 (current-time)))
617 (YaTeX-typeset-region 'YaTeX-typeset-conv2image-chain)
618 (if usetimer
619 (progn
620 (if YaTeX-on-the-fly-overlay
621 (move-overlay YaTeX-on-the-fly-overlay b e)
622 (overlay-put
623 (setq YaTeX-on-the-fly-overlay (make-overlay b e))
624 'face 'YaTeX-on-the-fly-activated-face))
625 (YaTeX-typeset-environment-auto)
626 )))
627 (YaTeX-typeset-region)))))
628 635
629 (defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9") 636 (defvar YaTeX-on-the-fly-preview-interval (string-to-number "0.9")
630 "*Control the on-the-fly update of preview environment by an image. 637 "*Control the on-the-fly update of preview environment by an image.
631 Nil disables on-the-fly update. Otherwise on-the-fly update is enabled 638 Nil disables on-the-fly update. Otherwise on-the-fly update is enabled
632 with update interval specified by this value.") 639 with update interval specified by this value.")

yatex.org