[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposal for a insert-kbd-macro that inserts "real" elisp
From: |
Juri Linkov |
Subject: |
Re: Proposal for a insert-kbd-macro that inserts "real" elisp |
Date: |
Fri, 04 Jan 2008 00:42:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
> The following came up on
> http://www.emacswiki.org/cgi-bin/wiki/KeyboardMacrosTricks and I thought
> I'd post it here:
Are you aware of the recent efforts to implement this in Emacs?
http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00038.html
>>> 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.
--
Juri Linkov
http://www.jurta.org/emacs/