yatex

changeset 179:a925cf5222f3 dev

mew, skk
author yuuji@gentei.org
date Thu, 31 Mar 2011 09:41:48 +0900
parents 2f9069006bdb
children 8b8593e02dad 9828ebe7b545
files yatex.el
diffstat 1 files changed, 81 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/yatex.el	Thu Mar 24 10:38:10 2011 +0900
     1.2 +++ b/yatex.el	Thu Mar 31 09:41:48 2011 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; Yet Another tex-mode for emacs - //–ì’¹//
     1.5  ;;; yatex.el rev. 1.74.4
     1.6  ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Wed Mar 16 10:16:18 2011 on firestorm
     1.8 +;;; Last modified Mon Mar 28 23:43:16 2011 on firestorm
     1.9  ;;; $Id$
    1.10  ;;; The latest version of this software is always available at;
    1.11  ;;; http://www.yatex.org/
    1.12 @@ -1256,22 +1256,45 @@
    1.13  
    1.14  (defun YaTeX-jmode ()
    1.15    (or (and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*)
    1.16 -      (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*)))
    1.17 +      (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*)
    1.18 +      (and (boundp 'skk-mode) skk-mode)
    1.19 +      (and (boundp 'default-input-method) default-input-method
    1.20 +	   current-input-method)))
    1.21  
    1.22  (defun YaTeX-jmode-off ()
    1.23 +  (if (cond
    1.24 +       ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*)
    1.25 +	(canna-toggle-japanese-mode) t)
    1.26 +       ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*)
    1.27 +	(egg:toggle-egg-mode-on-off) t)
    1.28 +       ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode)
    1.29 +	(cond
    1.30 +	 ((fboundp 'skk-latin-mode)	(skk-latin-mode t))
    1.31 +	 ((fboundp 'skk-mode-off)	(skk-mode-off))
    1.32 +	 (t (j-mode-off)))
    1.33 +	t)
    1.34 +       ((and (fboundp 'toggle-input-method) current-input-method)
    1.35 +	(toggle-input-method) t)
    1.36 +       ((and (fboundp 'fep-force-off) (fep-force-off))))
    1.37 +      (put 'YaTeX-jmode 'jmode t)))
    1.38 +
    1.39 +(defun YaTeX-jmode-on ()
    1.40    (cond
    1.41 -   ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*)
    1.42 -    (canna-toggle-japanese-mode))
    1.43 -   ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*)
    1.44 -    (egg:toggle-egg-mode-on-off))
    1.45 -   ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode)
    1.46 -    (cond
    1.47 -     ((fboundp 'skk-latin-mode)	(skk-latin-mode t))
    1.48 -     ((fboundp 'skk-mode-off)	(skk-mode-off))
    1.49 -     (t (j-mode-off))))
    1.50 -   ((and (fboundp 'toggle-input-method) current-input-method)
    1.51 -    (toggle-input-method))
    1.52 -   ((and (fboundp 'fep-force-off) (fep-force-off)))))
    1.53 +   ((boundp 'canna:*japanese-mode*)
    1.54 +    (if (not canna:*japanese-mode*) (canna-toggle-japanese-mode)))
    1.55 +   ((boundp 'egg:*mode-on*)
    1.56 +    (and (not egg:*mode-on*) (not egg:*input-mode*)
    1.57 +	 (egg:toggle-egg-mode-on-off)))
    1.58 +   ((and (fboundp 'skk-mode) (boundp 'skk-mode))
    1.59 +    (if (not skk-mode) (skk-mode 1)))
    1.60 +   ((fboundp 'toggle-input-method)
    1.61 +    (if (not current-input-method) (toggle-input-method)))
    1.62 +   ((and (fboundp 'fep-force-on) (fep-force-on)))))
    1.63 +
    1.64 +(defun YaTeX-jmode-back ()
    1.65 +  (if (get 'YaTeX-jmode 'jmode)
    1.66 +      (YaTeX-jmode-on))
    1.67 +  (setplist 'YaTeX-jmode nil))
    1.68  
    1.69  (defun YaTeX-self-insert (arg)
    1.70    (call-interactively (global-key-binding (char-to-string last-command-char))))
    1.71 @@ -1414,6 +1437,43 @@
    1.72  ;    (backward-char 1))
    1.73     (t (YaTeX-self-insert arg))))
    1.74  
    1.75 +(defun YaTeX-jmode-hook (old new)
    1.76 +  "A hook controling jmode on/off."
    1.77 +  (let ((inhibit-point-motion-hooks t)
    1.78 +	(oldp (plist-get (text-properties-at old) 'point-left))
    1.79 +	(newp (plist-get (text-properties-at new) 'point-left))
    1.80 +	(lnew (plist-get (text-properties-at new) 'last-new))
    1.81 +	(bmp (buffer-modified-p)) ;(endc ?x)
    1.82 +	(jm (YaTeX-jmode)) b e)
    1.83 +    ;;(if (eq 'YaTeX-jmode-hook newp)
    1.84 +    ;;	(setq endc (char-after (next-single-property-change new 'point-left))))
    1.85 +    ;;(message "n[%c]=%s o[%c]=%s end=[%c] jm=%s"
    1.86 +    ;;	     (char-after new) newp (char-after old) oldp endc jm)
    1.87 +    (cond
    1.88 +     ((eq lnew new) nil)		;Do nothing if continuous entry
    1.89 +     ((and (not (eq newp 'YaTeX-jmode-hook))
    1.90 +	   (eq oldp 'YaTeX-jmode-hook))
    1.91 +      ;; leave
    1.92 +      (remove-text-properties
    1.93 +       (1+ (or (previous-single-property-change old 'point-left)
    1.94 +	       (1- (point))))
    1.95 +       (1- (or (next-single-property-change old 'point-left)
    1.96 +	       (1+ (point))))
    1.97 +       (list 'last-new nil))
    1.98 +      (if (plist-get (text-properties-at old) 'jmode)
    1.99 +	  (YaTeX-jmode-on)))
   1.100 +     ((and (not (eq oldp 'YaTeX-jmode-hook))
   1.101 +	   (eq newp 'YaTeX-jmode-hook))
   1.102 +      ;; enter
   1.103 +      (add-text-properties
   1.104 +       (1+ (or (previous-single-property-change new 'point-left)
   1.105 +	       (1- (point))))
   1.106 +       (1- (or (next-single-property-change new 'point-left)
   1.107 +	       (1+ (point))))
   1.108 +       (list 'jmode jm 'last-new new))
   1.109 +      (set-buffer-modified-p bmp)
   1.110 +      (YaTeX-jmode-off)))))
   1.111 +
   1.112  (defun YaTeX-insert-dollar ()
   1.113    (interactive)
   1.114    (if (or (not (YaTeX-closable-p))
   1.115 @@ -1423,6 +1483,12 @@
   1.116        (insert "$")
   1.117      (insert "$$")
   1.118      (forward-char -1)
   1.119 +    (if (fboundp 'add-text-properties)
   1.120 +	(add-text-properties
   1.121 +	 (1- (point)) (1+ (point))
   1.122 +	 (list 'point-left 'YaTeX-jmode-hook
   1.123 +	       'point-entered 'YaTeX-jmode-hook
   1.124 +	       'jmode (YaTeX-jmode))))
   1.125      (YaTeX-jmode-off)
   1.126      (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1))))
   1.127  
   1.128 @@ -2275,7 +2341,7 @@
   1.129    (interactive)
   1.130    (if (not (YaTeX-on-begin-end-p)) nil
   1.131      (save-excursion
   1.132 -      (let (p env (m1 (match-beginning 1)) (m2 (match-beginning 2)))
   1.133 +      (let (p env newenv (m1 (match-beginning 1)) (m2 (match-beginning 2)))
   1.134  	(setq env (if m1 (YaTeX-buffer-substring m1 (match-end 1))
   1.135  		    (YaTeX-buffer-substring m2 (match-end 2))))
   1.136  	(goto-char (match-beginning 0))