From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: avar@cpan.org (=?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason) Newsgroups: gmane.emacs.devel Subject: Proposal for a insert-kbd-macro that inserts "real" elisp Date: Thu, 03 Jan 2008 13:44:23 +0000 Message-ID: <86k5mrf2h4.fsf@cpan.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1199367895 13802 80.91.229.12 (3 Jan 2008 13:44:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Jan 2008 13:44:55 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 03 14:45:16 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JAQNl-0006gf-RP for ged-emacs-devel@m.gmane.org; Thu, 03 Jan 2008 14:45:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JAQNP-0006US-Ej for ged-emacs-devel@m.gmane.org; Thu, 03 Jan 2008 08:44:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JAQNM-0006UC-0N for emacs-devel@gnu.org; Thu, 03 Jan 2008 08:44:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JAQNK-0006U0-HB for emacs-devel@gnu.org; Thu, 03 Jan 2008 08:44:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JAQNK-0006Tx-Ds for emacs-devel@gnu.org; Thu, 03 Jan 2008 08:44:46 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JAQNJ-0004YX-UB for emacs-devel@gnu.org; Thu, 03 Jan 2008 08:44:46 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JAQNC-0000RB-MZ for emacs-devel@gnu.org; Thu, 03 Jan 2008 13:44:38 +0000 Original-Received: from u.nix.is ([208.78.101.240]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Jan 2008 13:44:38 +0000 Original-Received: from avar by u.nix.is with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Jan 2008 13:44:38 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: u.nix.is User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:4+V4e/l+ERlSVMsqyPkZ4s2LxxY= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:85993 Archived-At: The following came up on http://www.emacswiki.org/cgi-bin/wiki/KeyboardMacrosTricks and I thought I'd post it here: >> ChristopherSmith wrote: >> Is there a way to convert an existing keyboard macro to elisp code? >> >> The use-case for such a facility would be to explore the way emacs >> works internally. In cough MS Office cough applications, you can >> discover much about the object model from recording macros (though >> the comparison may be unfair). – > avar wrote: > > You can do this with M-x insert-kbd-macro but the result is probably > not to your liking. If I do: > > C-x ( > C-n > foo > C-x ) > M-x name-last-kbd-macro RET newline-and-foo > M-x insert-kbd-macro RET newline-and-foo RET > > emacs will insert the following into the buffer: > > (fset 'newline-and-foo > "\C-nfoo") > > I would very much like to be able to insert something like this: > > (defun newline-and-foo () > (interactive) > (next-line) > (insert "foo")) > > But it appears emacs does not have this feature. A casual glance at > the source for insert-kbd-macro in macros.el would suggest that the > best way to go about this would be to write a function that called > (key-binding) on each key it was about to insert and inserted the > corresponding function name instead.