all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Looking up key myself
@ 2006-04-11  3:46 Herbert Euler
  2006-04-11  4:05 ` M Jared Finder
  0 siblings, 1 reply; 8+ messages in thread
From: Herbert Euler @ 2006-04-11  3:46 UTC (permalink / raw)


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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-04-11 21:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-11  3:46 Looking up key myself Herbert Euler
2006-04-11  4:05 ` M Jared Finder
2006-04-11  4:51   ` Herbert Euler
2006-04-11  5:00     ` Miles Bader
2006-04-11  5:10       ` Herbert Euler
2006-04-11 14:19       ` Stefan Monnier
     [not found]       ` <mailman.294.1144765276.9609.help-gnu-emacs@gnu.org>
2006-04-11 21:24         ` Miles Bader
2006-04-11 14:18   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.