comparison lisp/replace.el @ 20860:1432a2b3c44e

(occur): Apply default by hand after read-from-minibuffer. No need to clear text props from the result. (query-replace-read-args, map-query-replace-regexp): Offer the FROM arg as the default for the TO arg.
author Richard M. Stallman <rms@gnu.org>
date Sun, 08 Feb 1998 07:34:28 +0000
parents 24a1fcdc31d7
children 59f75e1f5541
comparison
equal deleted inserted replaced
20859:ef38c9fcbc28 20860:1432a2b3c44e
61 nil nil nil 61 nil nil nil
62 query-replace-from-history-variable 62 query-replace-from-history-variable
63 nil t))) 63 nil t)))
64 (setq to (read-from-minibuffer (format "%s %s with: " string from) 64 (setq to (read-from-minibuffer (format "%s %s with: " string from)
65 nil nil nil 65 nil nil nil
66 query-replace-to-history-variable nil t)) 66 query-replace-to-history-variable from t))
67 (list from to current-prefix-arg))) 67 (list from to current-prefix-arg)))
68 68
69 (defun query-replace (from-string to-string &optional arg) 69 (defun query-replace (from-string to-string &optional arg)
70 "Replace some occurrences of FROM-STRING with TO-STRING. 70 "Replace some occurrences of FROM-STRING with TO-STRING.
71 As each match is found, the user must type a character saying 71 As each match is found, the user must type a character saying
140 'query-replace-history nil t))) 140 'query-replace-history nil t)))
141 (setq to (read-from-minibuffer 141 (setq to (read-from-minibuffer
142 (format "Query replace %s with (space-separated strings): " 142 (format "Query replace %s with (space-separated strings): "
143 from) 143 from)
144 nil nil nil 144 nil nil nil
145 'query-replace-history nil t)) 145 'query-replace-history from t))
146 (list from to current-prefix-arg))) 146 (list from to current-prefix-arg)))
147 (let (replacements) 147 (let (replacements)
148 (if (listp to-strings) 148 (if (listp to-strings)
149 (setq replacements to-strings) 149 (setq replacements to-strings)
150 (while (/= (length to-strings) 0) 150 (while (/= (length to-strings) 0)
421 (if default 421 (if default
422 (format "List lines matching regexp (default `%s'): " 422 (format "List lines matching regexp (default `%s'): "
423 default) 423 default)
424 "List lines matching regexp: ") 424 "List lines matching regexp: ")
425 nil nil nil 'regexp-history default t))) 425 nil nil nil 'regexp-history default t)))
426 (set-text-properties 0 (length input) nil input) 426 (and (equal input "") default
427 (setq input default))
427 input) 428 input)
428 current-prefix-arg)) 429 current-prefix-arg))
429 (let ((nlines (if nlines 430 (let ((nlines (if nlines
430 (prefix-numeric-value nlines) 431 (prefix-numeric-value nlines)
431 list-matching-lines-default-context-lines)) 432 list-matching-lines-default-context-lines))