From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: get the binding in macro notation for this-command Date: Mon, 8 Sep 2008 13:56:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <46afccb2-b4ce-4a12-863b-16078da044fe@a18g2000pra.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1220910051 4592 80.91.229.12 (8 Sep 2008 21:40:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Sep 2008 21:40:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 08 23:41:46 2008 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.50) id 1KcoUN-0000dd-LC for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Sep 2008 23:41:39 +0200 Original-Received: from localhost ([127.0.0.1]:40270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KcoTN-0002KB-PF for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Sep 2008 17:40:37 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a18g2000pra.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1220907377 9769 127.0.0.1 (8 Sep 2008 20:56:17 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 8 Sep 2008 20:56:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a18g2000pra.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:162004 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:57346 Archived-At: There's this-command-keys and this-command-keys-vector. Is there a command that returns using the syntax of keyboard macro like =E2=80=9CM-=E2=80=B9key=E2=80=BA=E2=80=9D or =E2=80=9CC-=E2=80=B9key=E2=80= =BA=E2=80=9D? Or, how to convert the above to the macro syntax string? also when i do M-x narrow-to-region, emacs will tell me that it is bound to C-x n n. Similar for other command that has a binding but called with M-x. How to find out programatically the keys of a given command? I looked at the source but didn't see any mechanism that reminds user of a existence of a binding. here's some detail of what i want to do: Basically, i want to write a function like this: (global-set-key (kbd "C-a") 'binding-changed-notify) (defun binding-changed-notify () "Notify user that a keybinding has changed. Display a message of the last key press, the the command associated with that key press by default keybinding, and the new binding for the command." (interactive) (let (thisKeyPress desiredCmd desiredCmdKey)) (setq thisKeyPress (this-command-keys)) (setq desiredCmd 'someCmd) (setq desiredCmdKey (where-is-internal desiredCmd)) (message "You pressed %s. You probably wanted to call command %s, bound to key %s" thisKeyPress desiredCmd desiredCmdKey) ) Thanks. Xah =E2=88=91 http://xahlee.org/ =E2=98=84