emacs-devel
[Top][All Lists]
Advanced

[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: Richard Stallman
Subject: Re: Is there a plan to record kbd macro as elisp code?
Date: Sun, 28 Oct 2007 09:50:41 -0400

    Which reminds me that there is a big difference between replaying a keyboard
    macro and running the corresponding functions as a single command:

    - the pre-command-hook and post-command-hook are run for each key in
    the keyboard macro, but only once for the single command.

    This doesn't mean that the elisp code cannot be equivalent to the keyboard
    macro, but it may be much harder to do right.

There are various ideas of what is "right" for such a conversion.
I think the converted code should ignore these hooks, and if the
results are different, in most cases that will make sense.

Delete Selection mode is an exception.  In Delete Selection mode,
if these hooks are not run, the results will clearly be wrong.
The same may be true of CUA mode.

The conversion program could test for the presence of these specific
hook functions in pre-command-hook, and generate appropriate code in
the output Lisp function.  Rather than calling these hook functions
before each command, it should call them only in the places where they
would do real work.  And it wouldn't call the same function, but
rather a related one.  Here's what it could look like:

(put 'delete-selection-pre-hook 'lisp-conversion-function
     (lambda (function)
       (let ((type (and (symbolp this-command)
                        (get this-command 'delete-selection))))
         (when type
           `(delete-selection-pre-command-processing ,type)))))

where `delete-selection-pre-command-processing' would be
a new function that does the same work as `delete-selection-pre-hook'
but gets `type' as an argument.





reply via email to

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