help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do you know whether a keybinding already exists?


From: Elena
Subject: How do you know whether a keybinding already exists?
Date: Wed, 08 Dec 2010 15:12:36 -0000
User-agent: G2/1.0

Hello,

I'd like to trace whenever a key-binding is being overwritten, and
eventually forbidding some overwrites.

My understanding is that both "global-set-key" and "local-set-key"
rely on "define-key", therefore I've written this advice:

(defadvice define-key (around protect-bindings
                              (keymap key def)
                              activate) ;; I'm using an "around"
advice to eventually disable the overwrite.
        (when (key-binding-exists key keymap) ;; For "key-binding-exists",
read on.
                (message "Overwriting %S binding." key))
        ad-do-it)

I don't know how to write the "key-binding-exists" function.

Or it would be better to follow a different route altogether?

Thanks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]