emacs-devel
[Top][All Lists]
Advanced

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

Comments on emacs keyboard macros


From: Nelson H. F. Beebe
Subject: Comments on emacs keyboard macros
Date: Wed, 14 Feb 2001 09:20:18 -0700 (MST)

I've now been using emacs keyboard macros since about 1979 (TOPS-20
Emacs in TECO and assembler, through the current emacs-21.0.97
pretest), and I probably use them scores of times daily.

There are two features that I would very much like to see, since they
would substantially enhance keyboard macros, and also make it easier
for emacs novices to begin learning to program in Emacs Lisp:

(1) Instead of recording keystrokes, as in this output from
    insert-kbd-macro (a simple test that finds the next word starting
    with the letter `n', and occurring at beginning a line, and stuffs
    it into register 1):

    (fset 'foo-example
      [escape ?\C-s ?^ ?n ?\C-a ?\C-  escape ?f ?\C-x ?x ?1 ?\C-n])

    why not replace the keystrokes by the names of the functions that
    they invoke (remember, key bindings are mode dependent, so the
    named macro as currently stored might work differently in a buffer
    with different keybindings, which is bad), and insert something
    like this instead:

    (defun foo-example ()
     "PLEASE INSERT YOUR DOCUMENTATION HERE!"
      (isearch-forward-regexp "^n")
      (beginning-of-line)
      (forward-word)
      (copy-to-register-compatibility-binding ?1)
      (command next-line))

    I suspect that the reason that this has not been done before now
    is that many functions invoked interactively via a key binding
    behave differently than those invoked inline from Lisp code, with
    respect to their argument collection.  If this is indeed the
    stumbling block, then perhaps we need to think about how to
    redesign emacs to remove this deficiency. 

    Java bytecodes can now be turned back into fairly respectible Java
    programs, and people who use page markup languages keep clamoring
    for preservation of their markup in the output page description
    language, since doing so offers the potential for significant new
    things at the document processing back end.  Emacs keystrokes and
    bytecodes are just another example of this.

(2) I often create long complex keyboard macros that are not easy to
    express quickly in Emacs Lisp, and am frequently stymied by a call
    to (error "...") which aborts the keyboard macro collection.

    Usually, the error call happens because I mistyped a search
    string, or sometimes, a command name.  Then, the only recourse is
    to start over.  This restart sometimes has to be done several
    times, because I'm a fumble-fingered typist, and I also field a
    lot of external interrupts from door knocks and telephone rings.

    Would it possible to redefine error during keyboard macro
    collection in such a way that it produced a soft error that didn't
    abort the macro collection?

If neither of these is possible, then perhaps a function could be
provided to annotate a keyboard macro definition with the names of the
functions that it invokes, either in Lisp comments, or as string
objects.  That could then be manually edited into a proper Emacs Lisp
function.  

Most emacs users have learned hundreds of key strokes, knowing what
they do, but rarely knowing their exact names. I spend a lot of time
when writing Emacs Lisp in just looking up the binding of a key
stroke.  

That in turn suggests an enhancement: something akin to C-q
(quoted-insert), which instead inserts the name of the function bound
to the key, in parentheses, with the cursor following the name, ready
to insert an argument.  Maybe it could be called
quoted-function-insert, and be bound to A-q, which doesn't seem to
carry a default binding already.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah                    Internet e-mail: address@hidden  -
- Department of Mathematics, 322 INSCC      address@hidden  address@hidden -
- 155 S 1400 E RM 233                       address@hidden                    -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------



reply via email to

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