From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive not documented Date: 21 Jun 2004 11:50:00 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20040528.181649.25475113.wl@gnu.org> <873c5jug73.fsf@mail.jurta.org> <87oenqa4lu.fsf@mail.jurta.org> <873c51w5rq.fsf@mail.jurta.org> <87659snbd8.fsf@mail.jurta.org> <87llin98sc.fsf@mail.jurta.org> <87hdtbtnsg.fsf@mail.jurta.org> <87brjhwe2c.fsf@mail.jurta.org> Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BcLRf-00048E-00 for ; Mon, 21 Jun 2004 11:50:31 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BcLRe-0006sA-00 for ; Mon, 21 Jun 2004 11:50:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BcLSt-0004o2-Rf for emacs-devel@quimby.gnus.org; Mon, 21 Jun 2004 05:51:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BcLSq-0004nw-Dp for emacs-devel@gnu.org; Mon, 21 Jun 2004 05:51:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BcLSq-0004nk-01 for emacs-devel@gnu.org; Mon, 21 Jun 2004 05:51:44 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BcLSp-0004nh-UO for emacs-devel@gnu.org; Mon, 21 Jun 2004 05:51:43 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BcLRJ-0001aG-9V for emacs-devel@gnu.org; Mon, 21 Jun 2004 05:50:09 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1BcLRC-0003ot-9J; Mon, 21 Jun 2004 05:50:02 -0400 Original-To: rms@gnu.org In-Reply-To: Original-Lines: 49 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 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:25147 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25147 Richard Stallman writes: > So what is the rule? The problem is that currently I just use > read-from-string, and that can't distinguish between > 'symbol > and > (quote symbol) > > I had not been thinking about that because I was assuming that the > reader itself would swallow the space. However, in writing my code > I found it does not. Indeed I forgot to handle this distinction. > > Since the value is supposed to be a string, perhaps neither of these > cases matters much. However, I think it would be easy to distinguish > them by testing whether the expression began with an open-paren. > > ;; 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))))) Well, and then we have vectors and strings (which again usually are properly matched). In order to allow an optional space only where it "is needed", one would probably have to use one's own STREAM function by using `read' instead of `read-from-string': read is a built-in function in `C source code'. (read &optional STREAM) Read one Lisp expression as text from STREAM, return as Lisp object. If STREAM is nil, use the value of `standard-input' (which see). STREAM or the value of `standard-input' may be: [...] a function (call it with no arguments for each character, call it with a char as argument to push a char back) [...] and record when a trailing space gets unread again. And then one still has to explain the behavior in the DOC string. I just doubt that the gain in convenience is worth the trouble. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum