[Top][All Lists]

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

Re: query-replace-interactive not documented

From: David Kastrup
Subject: Re: query-replace-interactive not documented
Date: 26 Jun 2004 09:34:26 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

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.

> Moreover, I noticed that comments don't correspond to the code: it
> swallows a space after (quote foo) but not after 'foo.
> I regret spending time on this useless issue (there are no symbols
> useful in the replacement string other than `replace-count' which
> already has an abbreviation \#) but if swallowing a space is so
> needed I think more appropriate condition would be to swallow a space
> after any character except close-paren.

Symbols may look like \)...  So it is clear that we won't get both
"correct", "convenient" and "easy to explain" behavior.

"correct" would be, in my opinion "an optional space is gobbled where
the Lisp parser actually looks forward a character".

That would mean:

\,?\)  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.

David Kastrup, Kriemhildstr. 15, 44793 Bochum

reply via email to

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