[Top][All Lists]
[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: |
Wed, 16 Jun 2004 11:02:32 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
address@hidden (Kim F. Storm) writes:
> Also, \? could be used to ask the user for a string to insert at
> that point in each replacement...
Good idea! Below is an improved version.
Index: replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.172
diff -c -r1.172 replace.el
*** replace.el 10 Jun 2004 04:21:14 -0000 1.172
--- replace.el 15 Jun 2004 17:57:28 -0000
@@ -174,6 +183,23 @@
(if (and transient-mark-mode mark-active)
(region-end)))))
+ (if (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[`?]" to-string)
+ (let (to expr sym)
+ (while (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\\\([`?]\\)"
to-string)
+ (setq sym (match-string 3 to-string)
+ to (cons (substring to-string 0 (- (match-end 0) 2)) to)
+ to-string (substring to-string (match-end 0)))
+ (cond
+ ((equal sym "`")
+ (setq expr (read-from-string to-string)
+ to (cons `(format "%s" ,(car expr)) to)
+ to-string (substring to-string (cdr expr))))
+ ((equal sym "?")
+ (setq to (cons `(read-string "Enter string: ") to)))))
+ (setq to (nreverse (delete "" (cons to-string to))))
+ (replace-match-string-symbols to)
+ (setq to-string `(replace-eval-replacement concat ,@to))))
(perform-replace regexp to-string t t delimited nil nil start end))
(define-key esc-map [?\C-%] 'query-replace-regexp)
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: query-replace-interactive not documented, (continued)
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, Juri Linkov, 2004/06/15
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, Andreas Schwab, 2004/06/15
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, Kim F. Storm, 2004/06/15
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, Juri Linkov, 2004/06/16
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/16
- Re: query-replace-interactive not documented,
Juri Linkov <=
- Re: query-replace-interactive not documented, Richard Stallman, 2004/06/17
- Re: query-replace-interactive not documented, Juri Linkov, 2004/06/16
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/16
- Re: query-replace-interactive not documented, Kevin Rodgers, 2004/06/16
- Re: query-replace-interactive not documented, Andreas Schwab, 2004/06/16
- Re: query-replace-interactive not documented, Miles Bader, 2004/06/15
- Re: query-replace-interactive not documented, David Kastrup, 2004/06/15
- Re: query-replace-interactive not documented, Miles Bader, 2004/06/15
- Re: query-replace-interactive not documented, Richard Stallman, 2004/06/16
- Re: query-replace-interactive not documented, Andreas Schwab, 2004/06/15