emacs-devel
[Top][All Lists]
Advanced

[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 02:12:23 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

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'.  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.

Index: lisp/replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.175
diff -u -r1.175 replace.el
--- lisp/replace.el     24 Jun 2004 23:33:59 -0000      1.175
+++ lisp/replace.el     25 Jun 2004 18:22:33 -0000
@@ -112,20 +121,16 @@
                     (let ((end
                            ;; 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)))))
+                           (if (string-match
+                                 "[^])] " (substring to (1- (cdr pos))
+                                                        (1+ (cdr pos))))
                                (1+ (cdr pos))
                              (cdr pos))))
                       (setq to (substring to end)))))

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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