X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Fegg.git;a=blobdiff_plain;f=its-keydef.el;h=5e3a8353d22964e72d2d88297762741a19bf08df;hp=93724910774214972440267eab641e9a2f36a49a;hb=HEAD;hpb=efad2997c240e23522ab1a4c94e400420738b1e4 diff --git a/its-keydef.el b/its-keydef.el index 9372491..5e3a835 100644 --- a/its-keydef.el +++ b/its-keydef.el @@ -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))) @@ -23,31 +23,45 @@ (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)