[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 65369d8 02/22: arrange we can use `call-interactively' whe
From: |
Michael Heerdegen |
Subject: |
[elpa] master 65369d8 02/22: arrange we can use `call-interactively' when coming from isearch |
Date: |
Sat, 31 Oct 2015 18:41:34 +0000 |
branch: master
commit 65369d8e1dc14bfac611d2a8f4057f77aa9cd310
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
arrange we can use `call-interactively' when coming from isearch
---
packages/el-search/el-search.el | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index bd7210e..e3826f2 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/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] master updated (7507951 -> a91ed2f), Michael Heerdegen, 2015/10/31
- [elpa] master 65369d8 02/22: arrange we can use `call-interactively' when coming from isearch,
Michael Heerdegen <=
- [elpa] master 723bb57 08/22: fix el-search--repair-replacement-layout: don't move when replacing, Michael Heerdegen, 2015/10/31
- [elpa] master f7207e1 01/22: call syntax functions less often for better efficiency, Michael Heerdegen, 2015/10/31
- [elpa] master 0da07c0 06/22: some doc tweaks, Michael Heerdegen, 2015/10/31
- [elpa] master a621d16 04/22: remove not so useful message of how to repeat search, Michael Heerdegen, 2015/10/31
- [elpa] master 3459015 03/22: allow search wrapping, Michael Heerdegen, 2015/10/31
- [elpa] master ef3e3a0 07/22: rename a local variable, Michael Heerdegen, 2015/10/31
- [elpa] master d020482 05/22: change a TODO entry; no code change, Michael Heerdegen, 2015/10/31
- [elpa] master 113e0fd 11/22: fix whitespace, Michael Heerdegen, 2015/10/31
- [elpa] master 7d645e6 18/22: fix whitespace, Michael Heerdegen, 2015/10/31
- [elpa] master 61c3b71 13/22: require cl-lib only at compile time, Michael Heerdegen, 2015/10/31