From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Grant Rettke Newsgroups: gmane.emacs.help Subject: Re: Reporting when keymapping stomped... best approach Date: Tue, 10 Jun 2014 18:56:41 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1402445288 4645 80.91.229.3 (11 Jun 2014 00:08:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Jun 2014 00:08:08 +0000 (UTC) Cc: Emacs Help To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 11 02:08:02 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WuW5B-0001pv-7F for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jun 2014 02:08:01 +0200 Original-Received: from localhost ([::1]:42641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuW5A-00058z-6L for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Jun 2014 20:08:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuVuF-000118-O5 for help-gnu-emacs@gnu.org; Tue, 10 Jun 2014 19:56:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuVuE-0004Yl-E8 for help-gnu-emacs@gnu.org; Tue, 10 Jun 2014 19:56:43 -0400 Original-Received: from mail-ob0-x22c.google.com ([2607:f8b0:4003:c01::22c]:53746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuVuE-0004Yd-9I for help-gnu-emacs@gnu.org; Tue, 10 Jun 2014 19:56:42 -0400 Original-Received: by mail-ob0-f172.google.com with SMTP id uy5so6522117obc.31 for ; Tue, 10 Jun 2014 16:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=9Frq1I9z9erbBs6LF7XTKbrdhIzNT0Q5uQSxaG7td3M=; b=VAlIUvLIJJvTJMVaPI/JQJ1kKVA6h4XxyzIftrFew376paX4h5s9eipJSC684pQ1G5 B+Z+diTMt3W0rCN8bY6P4IgtnBmON6CUAOKNpWzKufpOE0eijBFroKqZnzHoDwfgG3zB lFQ+Trrr/FXOH+BJGX4+/jbeo5KplNKQPIU69uOxVrA4A/rios/UR6ian+M/3OguEJ04 9+haR2neFEbD6Fljj7Nq2X3GqU30nOp/VVJM2YPcCs9Aid7DmXFUCmBAJGHD6B0J+NjR tmkSdbu1ftjV4QfzrPE/55Ep39Egb0tnRn8RhEZqVpQ01/SzGRaevluysOS+nZg55En4 iMcA== X-Received: by 10.182.232.166 with SMTP id tp6mr34966131obc.18.1402444601455; Tue, 10 Jun 2014 16:56:41 -0700 (PDT) Original-Received: by 10.183.4.70 with HTTP; Tue, 10 Jun 2014 16:56:41 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: y_jOIYT_Ogp-ZIVUbJDxDIsU2EU X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22c X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98130 Archived-At: Thanks so much. I'll check also if there is something good for a "local-set-key" check. Grant Rettke | AAAS, ACM, ASA, FSF, IEEE, SIAM, Sigma Xi gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/ =E2=80=9CWisdom begins in wonder.=E2=80=9D --Socrates ((=CE=BB (x) (x x)) (=CE=BB (x) (x x))) =E2=80=9CLife has become immeasurably better since I have been forced to st= op taking it seriously.=E2=80=9D --Thompson On Tue, Jun 10, 2014 at 2:24 PM, Stefan Monnier wrote: >> (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 > >