[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search 9463ad2 025/332: arrange we can use `call-int
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search 9463ad2 025/332: arrange we can use `call-interactively' when coming from isearch |
Date: |
Tue, 1 Dec 2020 15:48:03 -0500 (EST) |
branch: externals/el-search
commit 9463ad2a36b7bcf9eda5ca781f8d7bfb3b08c8d6
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
arrange we can use `call-interactively' when coming from isearch
---
el-search.el | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/el-search.el b/el-search.el
index bd7210e..e3826f2 100644
--- a/el-search.el
+++ b/el-search.el
@@ -236,9 +236,9 @@ expression."
(read-from-minibuffer prompt initial-contents
el-search-read-expression-map read
(or hist 'read-expression-history) default)))
-(defun el-search--read-pattern (prompt &optional default initial-contents read)
+(defun el-search--read-pattern (prompt &optional default read)
(el-search-read-expression
- prompt initial-contents 'el-search-history
+ prompt el-search--initial-mb-contents 'el-search-history
(or default (when-let ((this-sexp (sexp-at-point)))
(concat "'" (el-search--print this-sexp))))
read))
@@ -436,7 +436,7 @@ return nil (no error)."
(let ((pattern
(el-search--read-pattern "Find pcase pattern: "
(car el-search-history)
- nil t)))
+ t)))
;; A very common mistake: input "foo" instead of
"'foo"
(when (and (symbolp pattern)
(not (eq pattern '_))
@@ -444,11 +444,12 @@ return nil (no error)."
(not (eq (symbol-value pattern)
pattern))))
(error "Please don't forget the quote when
searching for a symbol"))
(el-search--wrap-pattern pattern)))))
+ (setq this-command 'el-search-pattern) ;in case we come from isearch
(setq el-search-current-pattern pattern)
- (setq el-search-success nil)
(let ((opoint (point)))
- (when (eq this-command last-command)
+ (when (and (eq this-command last-command) el-search-success)
(el-search--skip-expression nil t))
+ (setq el-search-success nil)
(when (condition-case nil
(el-search--search-pattern pattern)
(end-of-buffer (message "No match")
@@ -519,10 +520,15 @@ return nil (no error)."
(if (zerop nbr-skipped) ""
(format " (%d skipped)" nbr-skipped)))))
-(defun el-search-query-replace-read-args (&optional initial-contents)
+;; We need a variable for the initial contents because we want to
`call-interactively '
+;; `el-search-query-replace-read-args'
+(defvar el-search--initial-mb-contents nil)
+
+(defun el-search-query-replace-read-args ()
(barf-if-buffer-read-only)
- (let* ((from (el-search--read-pattern "Replace from: " nil initial-contents))
- (to (el-search--read-pattern "Replace with result of evaluation of:
" from)))
+ (let* ((from (el-search--read-pattern "Replace from: "))
+ (to (let ((el-search--initial-mb-contents nil))
+ (el-search--read-pattern "Replace with result of evaluation
of: " from))))
(list (el-search--wrap-pattern (read from)) (read to)
(with-temp-buffer
(insert to)
@@ -532,6 +538,7 @@ return nil (no error)."
(defun el-search-query-replace (from to &optional mapping)
"Replace some occurrences of FROM pattern with evaluated TO."
(interactive (el-search-query-replace-read-args))
+ (setq this-command 'el-search-query-replace) ;in case we come from isearch
(setq el-search-current-pattern from)
(barf-if-buffer-read-only)
(el-search-search-and-replace-pattern from to mapping))
@@ -550,17 +557,15 @@ return nil (no error)."
;; with Isearch, using `isearch-search-fun-function'.
;; Alas, this is not trivial if we want to transfer our optimizations.
(interactive)
- (el-search-pattern
- (el-search--read-pattern
- "Find pcase pattern: " nil (concat "'"
(el-search--take-over-from-isearch)) t))
- (setq this-command 'el-search-pattern))
+ (let ((el-search--initial-mb-contents (concat "'"
(el-search--take-over-from-isearch))))
+ ;; use `call-interactively' so we get recorded in
`extended-command-history'
+ (call-interactively #'el-search-pattern)))
;;;###autoload
(defun el-search-replace-from-isearch ()
(interactive)
- (let ((this-command 'el-search-query-replace))
- (apply #'el-search-query-replace
- (el-search-query-replace-read-args (concat "'"
(el-search--take-over-from-isearch))))))
+ (let ((el-search--initial-mb-contents (concat "'"
(el-search--take-over-from-isearch))))
+ (call-interactively #'el-search-query-replace)))
- [elpa] externals/el-search 10e596b 113/332: Add `el-search--macroexpand', (continued)
- [elpa] externals/el-search 10e596b 113/332: Add `el-search--macroexpand', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 70477a2 150/332: Explicitly require pcase, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4b8780f 026/332: allow search wrapping, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 125d653 084/332: Fix el-search--ensure-sexp-start error at bob, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search ee096b0 092/332: Make sure not to lose the minibuffer-prompt face, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 80ff841 085/332: Make el-search-pattern accept an optional NO-ERROR arg, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 61c39c3 098/332: el-search version 0.2, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e9c3ed5 032/332: fix el-search-hl-post-command-fun auto-removal, Stefan Monnier, 2020/12/01
- [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 <=
- [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, 2020/12/01
- [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