emacs-devel
[Top][All Lists]
Advanced

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

Re: how-many/count-matches for non-interactive use


From: Robert J. Chassell
Subject: Re: how-many/count-matches for non-interactive use
Date: Wed, 20 Oct 2004 09:28:53 -0400 (EDT)

As Luc Teirlinck said,

    A keyboard macro is a poor man's Lisp function. 

Ten or twelve years ago, GNU Emacs Calc contained a function that
converted keyboard macros to GNU Emacs Lisp functions.  It might be
useful to focus again on this.  Such a conversion function might help
novices and those who put short expressions in their .emacs files.

The original conversion function was not very good.  It did not print
the resulting defun right and it did not take arguments.  It changed a
few commands to others.  But it was good enough as a beginning.

For example, if I remember rightly, the conversion function could take
a keyboard macro named `foo'

     C-x ( C-s Emacs C-b C-b C-b C-b C-b GNU C-n C-a C-x )

and create a function that looked like this:

    (defun foo ()
      (interactive)
      (search-forward "Emacs")
      (backward-char)
      (backward-char)
      (backward-char)
      (backward-char)
      (backward-char)
      (insert "G")
      (insert "N")
      (insert "U")
      (insert " ")
      (next-line)
      (beginning-of-line))

(except that the result was more poorly pretty printed), rather than
this:

    C-s Emacs 5*C-b GNU SPC C-n C-a
or
    (fset 'foo
       (lambda (&optional arg) "Keyboard macro." (interactive "p") 
(kmacro-exec-ring-item (quote ("EmacsGNU " 0 "%d")) arg)))

I lost interest in the function and now cannot find it.  Either I have
not looked well enough or it has been removed from the sources.

Interestingly, the `kmacro-edit-macro-repeat' command (`C-x C-k C-e')
lists command names as comments.  Perhaps the fairly deficient
conversion function transmogrified into this command.

-- 
    Robert J. Chassell                         
    address@hidden                         GnuPG Key ID: 004B4AC8
    http://www.rattlesnake.com                  http://www.teak.cc




reply via email to

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