emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal for a insert-kbd-macro that inserts "real" elisp


From: Ævar Arnfjörð Bjarmason
Subject: Proposal for a insert-kbd-macro that inserts "real" elisp
Date: Thu, 03 Jan 2008 13:44:23 +0000
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:

>> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]