Merge egg-980316.
[elisp/egg.git] / its-keydef.el
index 5e3a835..9372491 100644 (file)
@@ -5,7 +5,7 @@
 (make-variable-buffer-local 'its-zhuyin)
 (put 'its-zhuyin 'permanent-local t)
 
-(eval-and-compile
+(eval-when (eval compile)
   (defun its-make-select-func (key1 key2 func file map &optional zhuyin)
     (setq func (intern (concat "its-select-" (symbol-name func)))
          file (intern (concat "its/" (symbol-name file)))
              (its-put-cursor t))
             ((egg-get-bunsetsu-info (point))
              (egg-exit-conversion)))
-           (setq its-current-select-func ',func
-                 its-current-map ',map)
-           (if (its-get-language ,map)
-               (setq its-current-language (its-get-language ,map)))
+           (setq its-current-select-func ',func)
+           (setq its-current-map ,map)
+           (if (its-get-language its-current-map)
+               (setq its-current-language (its-get-language its-current-map)))
            ,(if zhuyin `(setq its-zhuyin ,(eq zhuyin 'T)))
            (if (null mode-line-unchange)
                (its-set-mode-line-title)))))
-     `(,func ,(concat "\C-x\C-m" key1) ,(concat "\e" key2)))))
+     `(define-key map
+       (if fence
+           ,(concat "\e" key2)
+         ,(concat "\C-x\C-m" key1))
+       ',func))))
 
 (defmacro its-do-list-make-select-func (list)
-  (let (funcs keydefs pair)
-    (while list
-      (setq pair (apply 'its-make-select-func (car list))
-           funcs (cons (car pair) funcs)
-           keydefs (cons (cdr pair) keydefs)
-           list (cdr list)))
-    `(progn
-       ,@funcs
-       (defvar its-define-select-key-list ',keydefs))))
-
-(defmacro its-add-select-funcs (list)
-  (let (funcs keydefs pair)
-    (while list
-      (setq pair (apply 'its-make-select-func (car list))
-           funcs (cons (car pair) funcs)
-           keydefs (cons (cdr pair) keydefs)
-           list (cdr list)))
-    `(progn
-       ,@funcs
-       (setq its-define-select-key-list
-            (append ',keydefs its-define-select-key-list)))))
-
-(defun its-define-select-keys (map &optional fence)
-  (let ((key-list its-define-select-key-list))
-    (while key-list
-      (define-key map (nth 1 (car key-list)) (car (car key-list)))
-      (if fence
-         (define-key map (nth 2 (car key-list)) (car (car key-list))))
-      (setq key-list (cdr key-list)))))
+  (eval-when (eval compile)
+    (let (funcs keydefs pair)
+      (while list
+       (setq pair (apply 'its-make-select-func (car list)))
+       (setq funcs (cons (car pair) funcs)
+             keydefs (cons (cdr pair) keydefs))
+       (setq list (cdr list)))
+      `(progn
+        ,@funcs
+        (defun its-define-select-keys (map &optional fence)
+          ,@keydefs)))))
 
 (its-do-list-make-select-func
  (("Q"    "Q"    upcase               ascii    up)