diff options
author | Karoly Lorentey <lorentey@elte.hu> | 2006-06-12 07:27:12 +0000 |
---|---|---|
committer | Karoly Lorentey <lorentey@elte.hu> | 2006-06-12 07:27:12 +0000 |
commit | 476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch) | |
tree | 4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /lisp/replace.el | |
parent | a13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff) | |
parent | 6b519504c3297595101628e823e72c91e562ab45 (diff) | |
download | emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz |
Merged from emacs@sv.gnu.org.
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-294
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-295
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-296
Update from CVS: admin/FOR-RELEASE: Update refcard section.
* emacs@sv.gnu.org/emacs--devo--0--patch-297
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-298
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-299
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-300
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-301
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-302
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-303
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-304
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-103
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-104
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'lisp/replace.el')
-rw-r--r-- | lisp/replace.el | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index f1792b499fc..2f8fe86860c 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -36,6 +36,11 @@ (defvar query-replace-history nil) +(defvar query-replace-defaults nil + "Default values of FROM-STRING and TO-STRING for `query-replace'. +This is a cons cell (FROM-STRING . TO-STRING), or nil if there is +no default value.") + (defvar query-replace-interactive nil "Non-nil means `query-replace' uses the last search string. That becomes the \"string to replace\".") @@ -94,32 +99,26 @@ The return value can also be a pair (FROM . TO) indicating that the user wants to replace FROM with TO." (if query-replace-interactive (car (if regexp-flag regexp-search-ring search-ring)) - (let* ((lastfrom (car (symbol-value query-replace-from-history-variable))) - (lastto (car (symbol-value query-replace-to-history-variable))) + (let* ((history-add-new-input nil) (from ;; 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 - (when (equal lastfrom lastto) - ;; Typically, this is because the two histlists are shared. - (setq lastfrom (cadr (symbol-value - query-replace-from-history-variable)))) (read-from-minibuffer - (if (and lastto lastfrom) + (if query-replace-defaults (format "%s (default %s -> %s): " prompt - (query-replace-descr lastfrom) - (query-replace-descr lastto)) + (query-replace-descr (car query-replace-defaults)) + (query-replace-descr (cdr query-replace-defaults))) (format "%s: " prompt)) nil nil nil query-replace-from-history-variable - nil t t)))) - (if (and (zerop (length from)) lastto lastfrom) - (progn - (set query-replace-from-history-variable - (cdr (symbol-value query-replace-from-history-variable))) - (cons lastfrom - (query-replace-compile-replacement lastto regexp-flag))) + nil t)))) + (if (and (zerop (length from)) query-replace-defaults) + (cons (car query-replace-defaults) + (query-replace-compile-replacement + (cdr query-replace-defaults) regexp-flag)) + (add-to-history query-replace-from-history-variable from nil t) ;; Warn if user types \n or \t, but don't reject the input. (and regexp-flag (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) @@ -177,10 +176,14 @@ the original string if not." "Query and return the `to' argument of a query-replace operation." (query-replace-compile-replacement (save-excursion - (read-from-minibuffer - (format "%s %s with: " prompt (query-replace-descr from)) - nil nil nil - query-replace-to-history-variable from t t)) + (let* ((history-add-new-input nil) + (to (read-from-minibuffer + (format "%s %s with: " prompt (query-replace-descr from)) + nil nil nil + query-replace-to-history-variable from t))) + (add-to-history query-replace-to-history-variable to nil t) + (setq query-replace-defaults (cons from to)) + to)) regexp-flag)) (defun query-replace-read-args (prompt regexp-flag &optional noerror) |