aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index cac4470c9cd..4c381c658e5 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -118,14 +118,19 @@ strings or patterns."
118 ((eq char ?\,) 118 ((eq char ?\,)
119 (setq pos (read-from-string to)) 119 (setq pos (read-from-string to))
120 (push `(replace-quote ,(car pos)) list) 120 (push `(replace-quote ,(car pos)) list)
121 (setq to (substring 121 (let ((end
122 to (+ (cdr pos) 122 ;; Swallow a space after a symbol
123 ;; Swallow a space after a symbol 123 ;; if there is a space.
124 ;; if there is a space. 124 (if (and (or (symbolp (car pos))
125 (if (string-match 125 ;; Swallow a space after 'foo
126 "^[^])\"] " 126 ;; but not after (quote foo).
127 (substring to (1- (cdr pos)))) 127 (and (eq (car-safe (car pos)) 'quote)
128 1 0)))))) 128 (not (= ?\( (aref to 0)))))
129 (eq (string-match " " to (cdr pos))
130 (cdr pos)))
131 (1+ (cdr pos))
132 (cdr pos))))
133 (setq to (substring to end)))))
129 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))) 134 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)))
130 (setq to (nreverse (delete "" (cons to list))))) 135 (setq to (nreverse (delete "" (cons to list)))))
131 (replace-match-string-symbols to) 136 (replace-match-string-symbols to)
@@ -208,7 +213,7 @@ In interactive calls, the replacement text can contain `\\,'
208followed by a Lisp expression. Each 213followed by a Lisp expression. Each
209replacement evaluates that expression to compute the replacement 214replacement evaluates that expression to compute the replacement
210string. Inside of that expression, `\\&' is a string denoting the 215string. Inside of that expression, `\\&' is a string denoting the
211whole match as a sting, `\\N' for a partial match, `\\#&' and `\\#N' 216whole match as a string, `\\N' for a partial match, `\\#&' and `\\#N'
212for the whole or a partial match converted to a number with 217for the whole or a partial match converted to a number with
213`string-to-number', and `\\#' itself for the number of replacements 218`string-to-number', and `\\#' itself for the number of replacements
214done so far (starting with zero). 219done so far (starting with zero).