[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0d1cd51: Treat inserted replacements as potential to-repla
From: |
Michael Heerdegen |
Subject: |
[elpa] master 0d1cd51: Treat inserted replacements as potential to-replace candidates |
Date: |
Tue, 20 Feb 2018 18:10:27 -0500 (EST) |
branch: master
commit 0d1cd51db574526c78ff6d8d8b865a9f62fba7e3
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
Treat inserted replacements as potential to-replace candidates
Don't skip the inserted replacement so that it can potentially be
subject to query-replace once more when matching the current search
pattern unless the user chooses to skip matches in replacements.
* packages/el-search/el-search.el
(el-search--search-and-replace-pattern): Do it.
---
packages/el-search/el-search.el | 63 +++++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index 6f123ea..94c9460 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -3231,14 +3231,13 @@ Thanks!"))))
(to-insert (funcall get-replacement-string))
(replacement-contains-another-match-p
(lambda ()
+ ;; This intentionally includes the
replacement itself
(with-temp-buffer
(emacs-lisp-mode)
(insert to-insert)
(goto-char 1)
- (el-search--skip-expression new-expr)
(condition-case nil
- (progn (el-search--ensure-sexp-start)
- (el-search--search-pattern-1
matcher 'noerror))
+ (el-search--search-pattern-1 matcher
'noerror)
(end-of-buffer nil)))))
(replacement-contains-another-match
(funcall replacement-contains-another-match-p))
@@ -3344,34 +3343,36 @@ Toggle splicing mode (\\[describe-function]
el-search-query-replace for details)
(when replacement-contains-another-match
(el-search-hl-other-matches matcher))
(unless (eobp)
- (cond
- ((not (and replaced-this
- replacement-contains-another-match
- skip-matches-in-replacement))
- (el-search--skip-expression nil t))
- ((eq skip-matches-in-replacement 'ask)
- (pcase (car (read-multiple-choice
- (propertize
- "There are matches in this
replacement - skip them? "
- 'face
'el-search-highlight-in-prompt-face)
- '((?y "yes")
- (?n "no")
- (?Y "always Yes")
- (?N "always No")
- (?q "quit"))))
- ((and (or ?y ?Y) answer)
- (when (= answer ?Y) (setq
skip-matches-in-replacement t))
- (forward-sexp))
- (?q (signal 'quit t))
- (answer
- (when (= answer ?N) (setq
skip-matches-in-replacement nil))
- (el-search--skip-expression nil t)
- (when replace-all
- (setq replace-all nil) ;FIXME: can this be
annoying? Problem: we need
- ;to catch possibly
infinite loops
- (message "Falling back to interactive mode")
- (sit-for 2.)))))
- (t (forward-sexp)))))))
+ (let ((skip-replacement
+ (lambda () (forward-sexp (if splice (length
replacement) 1)))))
+ (cond
+ ((not (and replaced-this
+ replacement-contains-another-match
+ skip-matches-in-replacement))
+ (unless (or replaced-this (eobp))
+ (el-search--skip-expression nil t)))
+ ((eq skip-matches-in-replacement 'ask)
+ (pcase (car (read-multiple-choice
+ (propertize
+ "There are matches in this
replacement - skip them? "
+ 'face
'el-search-highlight-in-prompt-face)
+ '((?y "yes")
+ (?n "no")
+ (?Y "always Yes")
+ (?N "always No")
+ (?q "quit"))))
+ ((and (or ?y ?Y) answer)
+ (when (= answer ?Y) (setq
skip-matches-in-replacement t))
+ (funcall skip-replacement))
+ (?q (signal 'quit t))
+ (answer
+ (when (= answer ?N) (setq
skip-matches-in-replacement nil))
+ (when replace-all
+ (setq replace-all nil) ;FIXME: can this be
annoying? Problem:
+ ;we need to catch
possibly infinite loops
+ (message "Falling back to interactive
mode")
+ (sit-for 2.)))))
+ (t (funcall skip-replacement))))))))
(quit (setq should-quit t))
((error debug) (setq should-quit (lambda () (error "%s"
(error-message-string err))))))
(el-search-hl-remove)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 0d1cd51: Treat inserted replacements as potential to-replace candidates,
Michael Heerdegen <=