[Top][All Lists]

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

Re: recording-elisp.el - try recording commands as elisp code

From: Richard Stallman
Subject: Re: recording-elisp.el - try recording commands as elisp code
Date: Tue, 06 Nov 2007 03:37:50 -0500

    Another case that might help us to decide to what level to record
    Lisp code is converting M-% (`query-replace').  There are three basic
    levels of "interactivity":

    1. convert it to the call to `query-replace', e.g.

That is the only reasonable thing to do with M-%.

    2. convert M-% to the call to `replace-string';

That's just no good.  If the user wanted to replace with no queries he
would have run `replace-string' himself.

    3. but the doc-string of this command says:

        This function is usually the wrong thing to use in a Lisp program.
        What you probably want is a loop like this:
          (while (search-forward FROM-STRING nil t)
            (replace-match TO-STRING nil t))
        which will run faster and will not set the mark or print anything.

    So according to this guideline a Lisp program should use a loop with
    search-forward and replace-match.

If the user runs M-x replace-string, replacing it with a loop like this
is a good idea.

reply via email to

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