[Top][All Lists]

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

Re: query-replace-interactive not documented

From: Juri Linkov
Subject: Re: query-replace-interactive not documented
Date: Sat, 26 Jun 2004 19:18:41 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

David Kastrup <address@hidden> writes:
> Juri Linkov <address@hidden> writes:
>> Richard Stallman <address@hidden> 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

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

reply via email to

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