From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Elena Newsgroups: gmane.emacs.help Subject: How do you know whether a keybinding already exists? Date: Wed, 9 Jun 2010 03:25:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: <61b16d04-f678-49cb-98f3-e678dbd13fe8@x21g2000yqa.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291829553 32674 80.91.229.12 (8 Dec 2010 17:32:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 17:32:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 18:32:30 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQNsT-0004OY-NE for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 18:32:29 +0100 Original-Received: from localhost ([127.0.0.1]:50358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQNsT-0004dR-10 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 12:32:29 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!x21g2000yqa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Original-NNTP-Posting-Host: 89.96.190.244 Original-X-Trace: posting.google.com 1276079131 5470 127.0.0.1 (9 Jun 2010 10:25:31 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 9 Jun 2010 10:25:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x21g2000yqa.googlegroups.com; posting-host=89.96.190.244; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.24 Version/10.53,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:178757 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75703 Archived-At: 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.