[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Looking up key myself
From: |
Herbert Euler |
Subject: |
Looking up key myself |
Date: |
Tue, 11 Apr 2006 11:46:45 +0800 |
Hello,
When writing my first minor mode, I was told that if I want commands
in this minor mode able to call commands bound to the same key while
this minor mode is not activated, I should lookup key myself. Following
(info "(elisp)Searching Keymaps"), I write
(defun xgp-casi2-lookup-key (key)
(or (if overriding-terminal-local-map
(lookup-key overriding-terminal-local-map key)
(if overriding-local-map
(lookup-key overriding-local-map key)
(or
(let ((map (get-text-property (point) 'keymap)))
(if map
(lookup-key map key)))
(let (val)
(find t emulation-mode-map-alists
:test 'equal
:key '(lambda (alist)
(if (setq val (xgp-casi2-lookup-key-from-alist
key alist))
t)))
val)
(xgp-casi2-lookup-key-from-alist key
minor-mode-overriding-map-alist)
(xgp-casi2-lookup-key-from-alist key minor-mode-map-alist)
(let ((map (get-text-property (point) 'local-map)))
(if map
(lookup-key map key)))
(lookup-key (current-local-map) key))))
(lookup-key (current-global-map) key)))
(defun xgp-casi2-lookup-key-from-alist (key alist)
(let (val)
(find t alist :test 'equal :key '(lambda (map)
(setq map (cdr map))
(if (setq val (lookup-key map key))
t)))
val))
Could somebody give me suggestions on this code? Thanks in
advance.
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/