Mercurial > emacs
changeset 56245:93e88c0fb51c
(query-replace-read-args): Swallow space after \,SYMBOL.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 24 Jun 2004 23:33:59 +0000 |
parents | 8b126cc57f70 |
children | b59328fbdeea |
files | lisp/replace.el |
diffstat | 1 files changed, 23 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/replace.el Thu Jun 24 23:30:50 2004 +0000 +++ b/lisp/replace.el Thu Jun 24 23:33:59 2004 +0000 @@ -109,7 +109,19 @@ ((eq char ?\,) (setq pos (read-from-string to)) (push `(replace-quote ,(car pos)) list) - (setq to (substring to (cdr pos))))) + (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))))) + (1+ (cdr pos)) + (cdr pos)))) + (setq to (substring to end))))) (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))) (setq to (nreverse (delete "" (cons to list))))) (replace-match-string-symbols to) @@ -188,19 +200,17 @@ `\\?' lets you edit the replacement text in the minibuffer at the given position for each replacement. -In interactive calls, the replacement text may contain `\\,' -followed by a Lisp expression used as part of the replacement -text. Inside of that expression, `\\&' is a string denoting the -whole match, `\\N' a partial matches, `\\#&' and `\\#N' the -respective numeric values from `string-to-number', and `\\#' -itself for `replace-count', the number of replacements occured so -far. +In interactive calls, the replacement text can contain `\\,' +followed by a Lisp expression. Each +replacement evaluates that expression to compute the replacement +string. Inside of that expression, `\\&' is a string denoting the +whole match as a sting, `\\N' for a partial match, `\\#&' and `\\#N' +for the whole or a partial match converted to a number with +`string-to-number', and `\\#' itself for the number of replacements +done so far (starting with zero). -If your Lisp expression is an identifier and the next letter in -the replacement string would be interpreted as part of it, you -can wrap it with an expression like `\\,(or \\#)'. Incidentally, -for this particular case you may also enter `\\#' in the -replacement text directly. +If the replacement expression is a symbol, write a space after it +to terminate it. One space there, if any, will be discarded. When using those Lisp features interactively in the replacement text, TO-STRING is actually made a list instead of a string. @@ -216,7 +226,6 @@ (region-beginning)) (if (and transient-mark-mode mark-active) (region-end))))) - (perform-replace regexp to-string t t delimited nil nil start end)) (define-key esc-map [?\C-%] 'query-replace-regexp)