/[emacs]/emacs/lisp/replace.el
ViewVC logotype

Diff of /emacs/lisp/replace.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.174 by dak, Thu Jun 24 10:26:24 2004 UTC revision 1.175 by rms, Thu Jun 24 23:33:59 2004 UTC
# Line 109  strings or patterns." Line 109  strings or patterns."
109                      ((eq char ?\,)                      ((eq char ?\,)
110                       (setq pos (read-from-string to))                       (setq pos (read-from-string to))
111                       (push `(replace-quote ,(car pos)) list)                       (push `(replace-quote ,(car pos)) list)
112                       (setq to (substring to (cdr pos)))))                       (let ((end
113                                ;; Swallow a space after a symbol
114                                ;; if there is a space.
115                                (if (and (or (symbolp (car pos))
116                                             ;; Swallow a space after 'foo
117                                             ;; but not after (quote foo).
118                                             (and (eq (car-safe (car pos)) 'quote)
119                                                  (= ?\( (aref to-string 0))))
120                                         (equal " " (substring to-string (cdr pos)
121                                                               (1+ (cdr pos)))))
122                                    (1+ (cdr pos))
123                                  (cdr pos))))
124                           (setq to (substring to end)))))
125                (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)))                (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)))
126          (setq to (nreverse (delete "" (cons to list)))))          (setq to (nreverse (delete "" (cons to list)))))
127        (replace-match-string-symbols to)        (replace-match-string-symbols to)
# Line 188  whatever what matched the Nth `\\(...\\) Line 200  whatever what matched the Nth `\\(...\\)
200  `\\?' lets you edit the replacement text in the minibuffer  `\\?' lets you edit the replacement text in the minibuffer
201  at the given position for each replacement.  at the given position for each replacement.
202    
203  In interactive calls, the replacement text may contain `\\,'  In interactive calls, the replacement text can contain `\\,'
204  followed by a Lisp expression used as part of the replacement  followed by a Lisp expression.  Each
205  text.  Inside of that expression, `\\&' is a string denoting the  replacement evaluates that expression to compute the replacement
206  whole match, `\\N' a partial matches, `\\#&' and `\\#N' the  string.  Inside of that expression, `\\&' is a string denoting the
207  respective numeric values from `string-to-number', and `\\#'  whole match as a sting, `\\N' for a partial match, `\\#&' and `\\#N'
208  itself for `replace-count', the number of replacements occured so  for the whole or a partial match converted to a number with
209  far.  `string-to-number', and `\\#' itself for the number of replacements
210    done so far (starting with zero).
211  If your Lisp expression is an identifier and the next letter in  
212  the replacement string would be interpreted as part of it, you  If the replacement expression is a symbol, write a space after it
213  can wrap it with an expression like `\\,(or \\#)'.  Incidentally,  to terminate it.  One space there, if any, will be discarded.
 for this particular case you may also enter `\\#' in the  
 replacement text directly.  
214    
215  When using those Lisp features interactively in the replacement  When using those Lisp features interactively in the replacement
216  text, TO-STRING is actually made a list instead of a string.  text, TO-STRING is actually made a list instead of a string.
# Line 216  Use \\[repeat-complex-command] after thi Line 226  Use \\[repeat-complex-command] after thi
226                 (region-beginning))                 (region-beginning))
227             (if (and transient-mark-mode mark-active)             (if (and transient-mark-mode mark-active)
228                 (region-end)))))                 (region-end)))))
   
229    (perform-replace regexp to-string t t delimited nil nil start end))    (perform-replace regexp to-string t t delimited nil nil start end))
230    
231  (define-key esc-map [?\C-%] 'query-replace-regexp)  (define-key esc-map [?\C-%] 'query-replace-regexp)

Legend:
Removed from v.1.174  
changed lines
  Added in v.1.175

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26