(query-replace-interactive): Change type from boolean

to choice.  Add value `initial'.
(query-replace-read-args): Handle value `initial' of
query-replace-interactive.
This commit is contained in:
Juri Linkov 2004-07-01 10:01:32 +00:00
parent 74820eb521
commit 0ec4febda2
2 changed files with 39 additions and 11 deletions

View file

@ -1,3 +1,22 @@
2004-07-01 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-mode-map): Bind C-M-w to isearch-del-char,
C-M-y to isearch-yank-char. Bind M-% to isearch-query-replace,
C-M-% to isearch-query-replace-regexp.
(minibuffer-local-isearch-map): Add arrow key bindings.
Bind C-f to isearch-yank-char-in-minibuffer.
(isearch-forward): Doc fix.
(isearch-edit-string): Doc fix.
(isearch-query-replace, isearch-query-replace-regexp): New funs.
(isearch-del-char): Add optional arg. Set isearch-yank-flag to t.
(isearch-yank-char): Add optional arg.
(isearch-yank-char-in-minibuffer): New fun.
* replace.el (query-replace-interactive): Change type from boolean
to choice. Add value `initial'.
(query-replace-read-args): Handle value `initial' of
query-replace-interactive.
2004-06-29 Kim F. Storm <storm@cua.dk>
* progmodes/gdb-ui.el (breakpoint-enabled-bitmap-face)

View file

@ -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)