unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Herbert Euler" <herberteuler@hotmail.com>
Subject: Looking up key myself
Date: Tue, 11 Apr 2006 11:46:45 +0800	[thread overview]
Message-ID: <BAY112-F33639DD7E42A518D652F13DACD0@phx.gbl> (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/

             reply	other threads:[~2006-04-11  3:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-11  3:46 Herbert Euler [this message]
2006-04-11  4:05 ` Looking up key myself 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
2006-04-11 14:18   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY112-F33639DD7E42A518D652F13DACD0@phx.gbl \
    --to=herberteuler@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).