From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: recording-elisp.el - try recording commands as elisp code Date: Tue, 06 Nov 2007 03:37:50 -0500 Message-ID: References: <87k5p05qsy.fsf@jurta.org> <87ve8g5kws.fsf@jurta.org> Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: ger.gmane.org 1194338386 1199 80.91.229.12 (6 Nov 2007 08:39:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Nov 2007 08:39:46 +0000 (UTC) Cc: yezonghui@gmail.com, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 06 09:39:48 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IpJyO-0006jK-ER for ged-emacs-devel@m.gmane.org; Tue, 06 Nov 2007 09:39:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpJyD-00076x-Hg for ged-emacs-devel@m.gmane.org; Tue, 06 Nov 2007 03:39:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpJwY-0006I1-4N for emacs-devel@gnu.org; Tue, 06 Nov 2007 03:37:54 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpJwW-0006Fi-H6 for emacs-devel@gnu.org; Tue, 06 Nov 2007 03:37:53 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpJwW-0006FV-5v for emacs-devel@gnu.org; Tue, 06 Nov 2007 03:37:52 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IpJwV-0005hj-P2 for emacs-devel@gnu.org; Tue, 06 Nov 2007 03:37:51 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1IpJwU-0002FK-US; Tue, 06 Nov 2007 03:37:51 -0500 In-reply-to: <87ve8g5kws.fsf@jurta.org> (message from Juri Linkov on Tue, 06 Nov 2007 02:45:47 +0200) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82637 Archived-At: 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.