Source

skk / skk-cursor.el

Diff from to

skk-cursor.el

 ;;; skk-cursor.el --- SKK cursor control.
-;; Copyright (C) 1996, 1997, 1998, 1999
-;; Masatake YAMATO <jet@airlab.cs.ritsumei.ac.jp>
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000
+;; Masatake YAMATO <masata-y@is.aist-nara.ac.jp>
 
-;; Author: Masatake YAMATO <jet@airlab.cs.ritsumei.ac.jp>
+;; Author: Masatake YAMATO <masata-y@is.aist-nara.ac.jp>
 ;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
 ;; Version: $Id$
 ;; Keywords: japanese
       (set-cursor-color color)
     (error
      (set-cursor-color skk-default-cursor-color)
-     (and skk-cursor-report-set-error
+     (and skk-report-set-cursor-error
 	  (skk-message
 	   "$B%+%i!<%^%C%W@Z$l$G$9!#%G%#%U%)%k%H$N%+%i!<$r;H$$$^$9!#(B"
 	   "Color map is exhausting, use default cursor color" )))))
 	(skk-cursor-set-color 
 	 (cond (color)
 	       ((not skk-mode) skk-default-cursor-color)
+	       (skk-abbrev-mode skk-abbrev-cursor-color)
 	       (skk-jisx0208-latin-mode
 		skk-jisx0208-latin-cursor-color)
 	       (skk-katakana skk-katakana-cursor-color)
     (and skk-use-cursor-change (skk-cursor-change-when-ovwrt))))
 
 ;;; advices.
+(defadvice kill-buffer (after skk-cursor-ad activate)
+  "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (interactive "bKill buffer: ")
+  (skk-cursor-set-properly))
+
+(defadvice other-window (after skk-cursor-ad activate)
+  "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (interactive "p")
+  (skk-cursor-set-properly))
+
+(static-cond
+ ((featurep 'xemacs)
+  (defadvice select-frame (after skk-cursor-ad activate)
+    "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+    (skk-cursor-set-properly)))
+ (t
+  (defadvice select-frame (after skk-cursor-ad activate)
+    "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+    (interactive "e")
+    (skk-cursor-set-properly))))
+
+(defadvice switch-to-buffer (after skk-cursor-ad activate)
+  "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+  (interactive "BSwitch to buffer: ")
+  (skk-cursor-set-properly))
+
 (let ((funcs '(
 	       ;; cover to original Emacs functions.
 	       bury-buffer
 	       delete-frame
 	       delete-window
-	       execute-extended-command 
-	       kill-buffer
-	       other-window
+	       ;; execute-extended-command 
+;	       kill-buffer
+;	       other-window
 	       overwrite-mode
 	       pop-to-buffer
-	       select-frame
+;	       select-frame
 	       select-window
-	       switch-to-buffer
+;	       switch-to-buffer
 	       ;; cover to SKK functions.
 	       skk-auto-fill-mode 
 	       skk-gyakubiki-katakana-message 
 	(skk-cursor-set-properly))))
     (setq funcs (cdr funcs))))
 
+(static-cond
+ ((featurep 'xemacs)
+  (defadvice recenter (after skk-cursor-ad activate)
+    "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+    (and skk-mode (skk-cursor-set-properly))))
+ (t
+  (defadvice recenter (after skk-cursor-ad activate)
+    "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+    (interactive "P")
+    (and skk-mode (skk-cursor-set-properly)))))
+
 (let ((funcs '(
 	       goto-line 
 	       insert-file 
-	       recenter 
+	       keyboard-quit
+;	       recenter 
 	       yank
 	       yank-pop 
 	       ;; cover to hilit functions.
 	(and skk-mode (skk-cursor-set-properly)))))
     (setq funcs (cdr funcs))))
 
-(let ((funcs '(abort-recursive-edit exit-minibuffer)))
-  (if (eq skk-emacs-type 'xemacs)
+;;$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B
+;; CLASS $B$O(B before.
+;; $B%_%K%P%C%U%!$+$i85$N%+%l%s%H%P%C%U%!$rC5$7=P$7!"%+!<%=%k$r%;%C%H!#(B
+(let ((funcs '(exit-minibuffer)))
+  (static-if (eq skk-emacs-type 'xemacs)
       (setq funcs (cons 'minibuffer-keyboard-quit funcs)))
   (while funcs
     (eval
 	(with-current-buffer (skk-minibuffer-origin) (skk-cursor-set-properly)))))
     (setq funcs (cdr funcs))))
 
+;; $BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B
+;; CLASS $B$O(B around.
+;; skk-abbrev-mode $B$N$H$-$@$1%+!<%=%k$r%;%C%H!#(B
+(let ((funcs '(
+	       ;; cover to original Emacs functions.
+	       newline 
+	       ;; cover to SKK functions.
+	       skk-delete-backward-char 
+	       skk-insert 
+	       skk-start-henkan 
+	       )))
+  (while funcs
+    (eval
+     (`
+      (defadvice (, (intern (symbol-name (car funcs))))
+	(around skk-cursor-ad activate preactivate)
+	"$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+	;; CLASS $B$O(B around.
+	;; skk-abbrev-mode $B$N$H$-$@$1%+!<%=%k$r%;%C%H!#(B
+	(if skk-abbrev-mode
+	    (progn ad-do-it (skk-cursor-set-properly))
+	  ad-do-it))))
+    (setq funcs (cdr funcs))))
+
+(static-when (featurep 'xemacs)
+  (defadvice abort-recursive-edit (before skk-cursor-ad activate preactivate)
+    "$BF~NO%b!<%I$K1~$8%+!<%=%k?'$rJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
+    (with-current-buffer (skk-minibuffer-origin) (skk-cursor-set-properly))))
+
 (defadvice skk-latin-mode (after skk-cursor-ad activate)
   "$B%+!<%=%k?'$r(B skk-latin-cursor-color $B$KJQ2=$5$;$k!#(BOvwrt $B%b!<%I$N$H$-$K%+!<%=%kI}$r>.$5$/$9$k!#(B"
   (skk-cursor-set-properly skk-latin-cursor-color))