summaryrefslogtreecommitdiff
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2007-11-10 21:48:46 +0000
committerJuri Linkov <juri@jurta.org>2007-11-10 21:48:46 +0000
commite7b2631ebe25df8ffd7991f93aca4561844735b1 (patch)
tree695b453c4f1ac482b06167438ae0c9fe06d39f0b /lisp/replace.el
parent3c7304e12dea9e48c687667feb29b0e6a2e04dda (diff)
downloademacs-e7b2631ebe25df8ffd7991f93aca4561844735b1.tar.gz
(query-replace-show-replacement): New defcustom.
(perform-replace): Use `match-substitute-replacement' if `query-replace-show-replacement' is non-nil.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 5fe8ad43d22..7876f9bb47c 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -69,6 +69,12 @@ strings or patterns."
:group 'matching
:version "22.1")
+(defcustom query-replace-show-replacement t
+ "*Non-nil means to show what actual replacement text will be."
+ :type 'boolean
+ :group 'matching
+ :version "23.1")
+
(defcustom query-replace-highlight t
"*Non-nil means to highlight matches during query replacement."
:type 'boolean
@@ -1570,10 +1576,17 @@ make, or the user didn't cancel the call."
(or delimited-flag regexp-flag) case-fold-search)
;; Bind message-log-max so we don't fill up the message log
;; with a bunch of identical messages.
- (let ((message-log-max nil))
+ (let ((message-log-max nil)
+ (replacement-presentation
+ (if query-replace-show-replacement
+ (save-match-data
+ (set-match-data real-match-data)
+ (match-substitute-replacement next-replacement
+ nocasify literal))
+ next-replacement)))
(message message
(query-replace-descr from-string)
- (query-replace-descr next-replacement)))
+ (query-replace-descr replacement-presentation)))
(setq key (read-event))
;; Necessary in case something happens during read-event
;; that clobbers the match data.