From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive not documented Date: Sat, 26 Jun 2004 19:18:41 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <871xk2uwbi.fsf@mail.jurta.org> References: <20040528.181649.25475113.wl@gnu.org> <87659snbd8.fsf@mail.jurta.org> <87llin98sc.fsf@mail.jurta.org> <87hdtbtnsg.fsf@mail.jurta.org> <87brjhwe2c.fsf@mail.jurta.org> <874qoz15tx.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1088267201 5399 80.91.224.253 (26 Jun 2004 16:26:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 26 Jun 2004 16:26:41 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Jun 26 18:26:30 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BeG0b-0004xS-00 for ; Sat, 26 Jun 2004 18:26:29 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BeG0b-0006Do-00 for ; Sat, 26 Jun 2004 18:26:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BeG27-0000Me-ML for emacs-devel@quimby.gnus.org; Sat, 26 Jun 2004 12:28:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BeG23-0000JZ-Lw for emacs-devel@gnu.org; Sat, 26 Jun 2004 12:27:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BeG20-0000EW-6i for emacs-devel@gnu.org; Sat, 26 Jun 2004 12:27:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BeG20-0000EE-0c for emacs-devel@gnu.org; Sat, 26 Jun 2004 12:27:56 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BeG08-00063C-Q3; Sat, 26 Jun 2004 12:26:01 -0400 Original-Received: from mail.jurta.org (80-235-41-6-dsl.mus.estpak.ee [80.235.41.6]) by spatula.dreamhost.com (Postfix) with ESMTP id BD8CD17D024; Sat, 26 Jun 2004 09:25:54 -0700 (PDT) Original-To: David Kastrup In-Reply-To: (David Kastrup's message of "26 Jun 2004 09:34:26 +0200") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25268 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25268 David Kastrup writes: > Juri Linkov writes: >> Richard Stallman writes: >> > ;; Swallow a space after a symbol >> > ;; if there is a space. >> > (if (and (or (symbolp (car pos)) >> > ;; Swallow a space after 'foo >> > ;; but not after (quote foo). >> > (and (eq (car-safe (car pos)) 'quote) >> > (= ?\( (aref to-string 0)))) >> > (equal " " (substring to-string (cdr pos) >> > (1+ (cdr pos))))) >> >> This code doesn't work in `query-replace-read-args' since this >> function uses the variable `to' instead of `to-string'. > > Oh, come on. You can't blame Richard for proposing a change to code > I changed afterwards. I don't blame Richard. I know Richard has very little time to test code before installing to CVS. But I tested it from CVS and reported problems. Another problem with this code is that it fails on final symbols in the replacement string (which have no characters after the symbol read by `read-from-string') because `substring' with (1+ (cdr pos)) signals an error. > \,?\) gobble > \,"xx" don't gobble > \,?" gobble > \,() don't gobble (note that (symbolp '()) -> t) > (xxx) don't gobble > \(xxx\) gobble > > But it would be near to impossible to explain this behavior such that > people would actually be easily able to predict it. So if we try > something like conditional gobbling, we should rather try for "caters > for most cases and is easy to explain" rule, like allowing an > optional space after everything except ) " ], regardless of whether > the last three characters my happen to be part of a symbol or not. The simplest solution is not to mess with swallowing spaces at all and to let users to add artificial separators like `(or variable)text'. In this case users should learn no additional rules other than rules of reading symbols by `read'. IMHO. -- Juri Linkov http://www.jurta.org/emacs/