From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Reporting when keymapping stomped... best approach Date: Thu, 12 Jun 2014 00:50:20 -0600 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1402555866 19117 80.91.229.3 (12 Jun 2014 06:51:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Jun 2014 06:51:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 12 08:50:59 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 1Wuyqh-0007I9-2c for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jun 2014 08:50:59 +0200 Original-Received: from localhost ([::1]:52055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wuyqg-0008TM-N3 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jun 2014 02:50:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuyqP-0008MG-7t for help-gnu-emacs@gnu.org; Thu, 12 Jun 2014 02:50:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuyqF-00082x-KS for help-gnu-emacs@gnu.org; Thu, 12 Jun 2014 02:50:41 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuyqF-00082c-DK for help-gnu-emacs@gnu.org; Thu, 12 Jun 2014 02:50:31 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WuyqD-0006lq-Nd for help-gnu-emacs@gnu.org; Thu, 12 Jun 2014 08:50:29 +0200 Original-Received: from 71-212-253-190.hlrn.qwest.net ([71.212.253.190]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Jun 2014 08:50:29 +0200 Original-Received: from kevin.d.rodgers by 71-212-253-190.hlrn.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Jun 2014 08:50:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 71-212-253-190.hlrn.qwest.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:98168 Archived-At: On 6/10/14 1:15 PM, Grant Rettke wrote: > My goal is to issue a warning whenever a keymapping is stomped on my > myself or anyone else. For example, say I replace self-insert for 1 > like this: > > (global-set-key (kbd "1") 'scheme-mode) > > Then I want to look up in the global keymap space whether the desired > key already exists, and if it does, then I want to warn the user what > function was rebound to that keymap. Eg: > > (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))))) > > > The only problem is that this doesn't work, as global-undo-tree starts > complaining and I'm not sure where to start looking . Setting > debug-on-error to true doesn't even reveal anything useful. > > Where might I start debugging further? Stefan already provided the solution, but FYI I think the problem with your original attempt is that you try to concat `command' (which is a symbol in most cases) to a string. His solution works because he uses the %S format specifier. I don't know why setting debug-on-error didn't work as expected. -- Kevin Rodgers Denver, Colorado, USA