[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search bff759c 047/332: el-search-query-replace: add
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search bff759c 047/332: el-search-query-replace: add s (toggle splicing) and ? (help) keys |
Date: |
Tue, 1 Dec 2020 15:48:08 -0500 (EST) |
branch: externals/el-search
commit bff759c88b7f2695252df63c9b9f5ac95a8c90bc
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
el-search-query-replace: add s (toggle splicing) and ? (help) keys
---
el-search.el | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/el-search.el b/el-search.el
index 05cbc74..8450b86 100644
--- a/el-search.el
+++ b/el-search.el
@@ -165,6 +165,12 @@
;; y and n work like in isearch (meaning "yes" and "no") if you are
;; used to that.
;;
+;; It is possible to replace a match with multiple expressions using
+;; "splicing mode". When it is active, the replacement expression
+;; must evaluate to a list, and is spliced instead of inserted into
+;; the buffer for any replaced match. Use s to toggle splicing mode
+;; in a `el-search-query-replace' session.
+;;
;;
;; Suggested key bindings
;; ======================
@@ -637,6 +643,22 @@ The following additional pattern types are currently
defined:\n"
(setq el-search-success t)
(el-search-hl-sexp))))
+(defvar el-search-search-and-replace-help-string
+ "\
+y Replace this match and move to the next.
+SPC or n Skip this match and move to the next.
+r Replace this match but don't move.
+! Replace all remaining matches automatically.
+q Quit. To resume, use e.g. `repeat-complex-command'.
+? Show this help.
+s Toggle splicing mode. When splicing mode is
+ on (default off), the replacement expression must
+ evaluate to a list, and the result is spliced into the
+ buffer, instead of just inserted.
+
+Hit any key to proceed."
+ "Help string for ? in `el-search-query-replace'.")
+
(defun el-search-search-and-replace-pattern (pattern replacement &optional
mapping splice)
(let ((replace-all nil) (nbr-replaced 0) (nbr-skipped 0) (done nil)
(el-search-keep-hl t) (opoint (point))
@@ -674,7 +696,8 @@ The following additional pattern types are currently
defined:\n"
(if replace-all
(funcall do-replace)
(while (not (pcase (if replaced-this
- (read-char-choice "[SPC ! q]" '(?\ ?! ?q
?n))
+ (read-char-choice "[SPC ! q] (? for
help)"
+ '(?\ ?! ?q ?n ??))
(read-char-choice
(concat "Replace this occurrence"
(if (or (string-match-p "\n"
to-insert)
@@ -682,8 +705,8 @@ The following additional pattern types are currently
defined:\n"
"" (format " with `%s'"
to-insert))
"? "
(if splice "{splice} " "")
- "[y SPC r ! q]" )
- '(?y ?n ?r ?\ ?! ?q ?s)))
+ "[y SPC r ! s q] (? for help)" )
+ '(?y ?n ?r ?\ ?! ?q ?s ??)))
(?r (funcall do-replace)
nil)
(?y (funcall do-replace)
@@ -699,7 +722,9 @@ The following additional pattern types are currently
defined:\n"
(setq to-insert (funcall
get-replacement-string))
nil)
(?q (setq done t)
- t)))))
+ t)
+ (?? (ignore (read-char
el-search-search-and-replace-help-string))
+ nil)))))
(unless (or done (eobp)) (el-search--skip-expression nil t)))))
(el-search-hl-remove)
(goto-char opoint)
- [elpa] externals/el-search a2c97a1 009/332: el-search: add autoload cookies, (continued)
- [elpa] externals/el-search a2c97a1 009/332: el-search: add autoload cookies, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 7b1b6dd 013/332: change default of el-search-this-expression-identifier, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 9463ad2 025/332: arrange we can use `call-interactively' when coming from isearch, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 29c34cc 027/332: remove not so useful message of how to repeat search, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 816e675 033/332: document el-search--do-subsexps, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1bbf5d9 035/332: give feedback in the echo area again, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 93079f5 042/332: el-search: bump version to 0.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 112612e 041/332: simplify el-search-hl-post-command-fun, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b4abe87 045/332: add a to do, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 20f670a 048/332: bump version to 0.1.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search bff759c 047/332: el-search-query-replace: add s (toggle splicing) and ? (help) keys,
Stefan Monnier <=
- [elpa] externals/el-search 0e71413 049/332: el-search--matcher: refine when to warn or error, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search aa4bd02 051/332: el-search: new pattern type `append', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d97f8fe 052/332: remove example using `message' in a guard, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e81afef 054/332: factor out `el-search--search-pattern-1', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2b4c194 055/332: remove annoying message on how to repeat el-search, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 30fef15 056/332: use more newlines in `el-search--make-docstring', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c090afe 057/332: el-search: new pattern type `contains', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 7e13746 058/332: When coming from isearch, don't move to other end, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5837187 059/332: el-search: bump version to 0.1.3, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 108466e 061/332: Support highlighting of all visible matches, Stefan Monnier, 2020/12/01