|
From: | Stefan Monnier |
Subject: | Re: Reporting when keymapping stomped... best approach |
Date: | Tue, 10 Jun 2014 15:24:02 -0400 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
> (defadvice global-set-key (before check-keymapping activate) > (let ((key (ad-get-arg 0)) > (command (ad-get-arg 1))) > (when command > (warn (concat "Just stomped on a global keymapping bound to: " > command))))) This doesn't check whether the key was already bound. You'll probably prefer something like (defadvice global-set-key (before check-keymapping activate) (let* ((key (ad-get-arg 0)) (command (ad-get-arg 1)) (old (lookup-key global-map key))) (when old (message "Replacing %S with %S in global-map" old command)))) and you'll probably also want to advise `define-key' similarly. Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |