emacs-devel
[Top][All Lists]
Advanced

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

Re: Convert a keyboard macro to equivalent Lisp code


From: Juri Linkov
Subject: Re: Convert a keyboard macro to equivalent Lisp code
Date: Wed, 09 Jun 2010 11:34:04 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> The part you don't understand is that I only noticed your
>
>>   if (NILP (last_char))
>>     last_char = last_command_event;
>
> right *after* sending my email.

But your objection prompted me to look closely at `self-insert-command',
and I found another reason (`translate_char') why it won't work ;-)

>>> Of course, even better would be if the code run during macro recording
>>> is the code generated (so if the behavior is different from the normal
>>> command's behavior, you might see it during recording).
>> We could later add an option to verify to macro during recording.
>
> I'm heading towards a special "recording&running macro" mode where
> various commands may have a slightly different behavior (less DWIMish,
> more amenable to scripting, more amenable to transforming into Elisp
> code), so "verifying" might not be the right approach since a different
> behavior might not be a problem but a feature.

Then it's a different feature.  This is more like command translation
during recording and running a macro.  This is already possible to do
without core support with:

(add-hook 'pre-command-hook
          (lambda ()
            (when (or defining-kbd-macro executing-kbd-macro)
              (cond ((eq this-command 'next-line)
                     (setq this-command 'forward-line))))))

and maybe better:

(add-hook 'pre-command-hook
          (lambda ()
            (when (or defining-kbd-macro executing-kbd-macro)
              (cond ((memq this-command '(next-line previous-line))
                     (setq line-move-visual nil))))))

(add-hook 'post-command-hook
          (lambda ()
            (when (or defining-kbd-macro executing-kbd-macro)
              (cond ((memq this-command '(next-line previous-line))
                     (setq line-move-visual t))))))

-- 
Juri Linkov
http://www.jurta.org/emacs/



reply via email to

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