[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a plan to record kbd macro as elisp code?
From: |
yzhh |
Subject: |
Re: Is there a plan to record kbd macro as elisp code? |
Date: |
Sun, 28 Oct 2007 06:49:13 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Juri Linkov <juri <at> jurta.org> writes:
> > I think what was expected was to first record a keyboard macro and later to
> > turn that into elisp code.
>
> That's was exactly my first attempt when I tried to implement this feature.
> However, this approach doesn't work because a macro highly depends on its
> context, and will fail when repeating it in different buffers, modes, etc.
I agree. Keymap changes caused by mode/buffer changes DURING the recording
can messup the "translation". So I didn't try this in the first place :)
> > Another approach is to use a pre-command-hook to record the value of
> > `this-command' for each command run.
>
> After failing with the first approach, I tried to do this, but this doesn't
> work because `this-command' doesn't record the arguments of the last
> command. So when I added a new variable `this-command-args' that records
> the arguments of the command being executed, this approach produced
> good results.
>
> Also I added a new variable `last-kbd-macro-commands', and a new command
> `insert-last-kbd-macro-commands' to convert the recorded commands with
> their arguments to a Lisp function. A change in isearch was also required
> to convert all isearch subcommands into one search function.
This approach looks quite promising. I vote for this.
> Since yzhh doesn't want to post his code, I will post mine.
> I ask yzhh to comment on this code, compare with his own,
> and suggest further improvements:
Great work Juri!
I'm actually busy on work these days. As soon as I have time I'll investigate
your code and give any suggestion I can. Hope this will progress into something
in the emacs CVS.
And inspired by you and others, I post my code here.
Basically, I did these:
Add a variable (V)kbd-macro-command-history, insert commands into it on ervey
ocurrence of possible insertion into command-history (that's guarded by
record_flag), when defining-kbd-macro is on. So it's not complete. You have to
M-x eval-expression kbd-macro-command-history to see the recorded thing, in
reverse order. And its length is guarded by history-length.
regards,
yzhh
- Re: Is there a plan to record kbd macro as elisp code?, (continued)
- Re: Is there a plan to record kbd macro as elisp code?, Kim F. Storm, 2007/10/27
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Kim F. Storm, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, yzhh, 2007/10/29
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/29
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/29
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/27
- Re: Is there a plan to record kbd macro as elisp code?, Stefan Monnier, 2007/10/27
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/27
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?,
yzhh <=
- Re: Is there a plan to record kbd macro as elisp code?, yzhh, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/29
- Re: Is there a plan to record kbd macro as elisp code?, yzhh, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/28
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/29
- Re: Is there a plan to record kbd macro as elisp code?, Juri Linkov, 2007/10/30
- Re: Is there a plan to record kbd macro as elisp code?, Richard Stallman, 2007/10/31