[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert a keyboard macro to equivalent Lisp code
From: |
Stefan Monnier |
Subject: |
Re: Convert a keyboard macro to equivalent Lisp code |
Date: |
Wed, 09 Jun 2010 10:17:29 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> But your objection prompted me to look closely at `self-insert-command',
> and I found another reason (`translate_char') why it won't work ;-)
AFAIK translate-char is not used. I suggested to get rid of it in
Emacs-23, so it's obsolete since Emacs-23.1.
AFAIK it's only ever been used for Emacs-22's char-unification support.
>> 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.
Yes and no: yes, in the sense that the difference is considered
a feature, but no in the sense that it's *very* similar, used for the
same purpose, and could use the same keybindings.
> This is more like command translation during recording and running
> a macro. This is already possible to do without core support with:
If it can be done without changing C code, that's an advantage.
> (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))))))
Yuck.
> (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))))))
Even more yuck!
Those settings would be enabled disabled when you enter/leave the macro
recording/running mode rather than around each command. Still, the
above does not record the commands, so there's more work to do.
Stefan