diff options
author | Juri Linkov <juri@jurta.org> | 2004-07-01 10:01:32 +0000 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2004-07-01 10:01:32 +0000 |
commit | 0ec4febda2d72e79bd90ab25bada4f8b34f4ab54 (patch) | |
tree | 1a946ca27eba29a6a9e095011067a6ce82007495 /lisp/replace.el | |
parent | 74820eb5215e5e21f084c70e7770e0a04c1f6033 (diff) | |
download | emacs-0ec4febda2d72e79bd90ab25bada4f8b34f4ab54.tar.gz |
(query-replace-interactive): Change type from boolean
to choice. Add value `initial'.
(query-replace-read-args): Handle value `initial' of
query-replace-interactive.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r-- | lisp/replace.el | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index c2305cdecc6..cac4470c9cd 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -38,8 +38,12 @@ (defcustom query-replace-interactive nil "Non-nil means `query-replace' uses the last search string. -That becomes the \"string to replace\"." - :type 'boolean +That becomes the \"string to replace\". +If value is `initial', the last search string is inserted into +the minibuffer as an initial value for \"string to replace\"." + :type '(choice (const :tag "Off" nil) + (const :tag "Initial content" initial) + (other :tag "Use default value" t)) :group 'matching) (defcustom query-replace-from-history-variable 'query-replace-history @@ -70,16 +74,20 @@ strings or patterns." (unless noerror (barf-if-buffer-read-only)) (let (from to) - (if query-replace-interactive - (setq from (car (if regexp-flag regexp-search-ring search-ring))) + (if (and query-replace-interactive + (not (eq query-replace-interactive 'initial))) + (setq from (car (if regexp-flag regexp-search-ring search-ring))) ;; The save-excursion here is in case the user marks and copies ;; a region in order to specify the minibuffer input. ;; That should not clobber the region for the query-replace itself. (save-excursion - (setq from (read-from-minibuffer (format "%s: " string) - nil nil nil - query-replace-from-history-variable - nil t))) + (setq from (read-from-minibuffer + (format "%s: " string) + (if (eq query-replace-interactive 'initial) + (car (if regexp-flag regexp-search-ring search-ring))) + nil nil + query-replace-from-history-variable + nil t))) ;; Warn if user types \n or \t, but don't reject the input. (and regexp-flag (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) @@ -92,9 +100,10 @@ strings or patterns." (sit-for 2)))) (save-excursion - (setq to (read-from-minibuffer (format "%s %s with: " string from) - nil nil nil - query-replace-to-history-variable from t))) + (setq to (read-from-minibuffer + (format "%s %s with: " string from) + nil nil nil + query-replace-to-history-variable from t))) (when (and regexp-flag (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)) (let (pos list char) |