Sync up with egg-980712.
[elisp/egg.git] / its-keydef.el
index 9372491..5e3a835 100644 (file)
@@ -5,7 +5,7 @@
 (make-variable-buffer-local 'its-zhuyin)
 (put 'its-zhuyin 'permanent-local t)
 
-(eval-when (eval compile)
+(eval-and-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)
-           (setq its-current-map ,map)
-           (if (its-get-language its-current-map)
-               (setq its-current-language (its-get-language its-current-map)))
+           (setq its-current-select-func ',func
+                 its-current-map ',map)
+           (if (its-get-language ,map)
+               (setq its-current-language (its-get-language ,map)))
            ,(if zhuyin `(setq its-zhuyin ,(eq zhuyin 'T)))
            (if (null mode-line-unchange)
                (its-set-mode-line-title)))))
-     `(define-key map
-       (if fence
-           ,(concat "\e" key2)
-         ,(concat "\C-x\C-m" key1))
-       ',func))))
+     `(,func ,(concat "\C-x\C-m" key1) ,(concat "\e" key2)))))
 
 (defmacro its-do-list-make-select-func (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)))))
+  (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)))))
 
 (its-do-list-make-select-func
  (("Q"    "Q"    upcase               ascii    up)