[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search d4ad652 278/332: [el-search] Implement an exp
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search d4ad652 278/332: [el-search] Implement an explicit quit command |
Date: |
Tue, 1 Dec 2020 15:49:03 -0500 (EST) |
branch: externals/el-search
commit d4ad652bf637be73c2b937fdb44914db9df00a8d
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
[el-search] Implement an explicit quit command
Let C-g quit and jump to the starting position like in
isearch ('el-search-keyboard-quit').
Update header comment and bump version to 1.8.4.
* packages/el-search/el-search.el
(el-search--set-search-origin-maybe): New function.
(el-search-keyboard-quit): New command.
(el-search-basic-transient-map): Add binding for
'el-search-keyboard-quit'.
(el-search-setup-search-1, el-search-jump-to-search-head)
(el-search-continue-search, el-search-from-beginning)
(el-search-last-buffer-match): Call
'el-search--set-search-origin-maybe'.
(el-search-display-match-count): Handle quit.
---
NEWS | 5 +++++
el-search.el | 46 ++++++++++++++++++++++++++++++++++++----------
2 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index a27b322..138d2b5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
Some of the user visible news were:
+Version: 1.8.4
+
+ Quitting (C-g) while el-searching now brings you back to the
+ starting point like in isearch.
+
Version: 1.8.3
`el-search-query-replace' now adds undo boundaries for each manual
diff --git a/el-search.el b/el-search.el
index ee3b641..a2ce888 100644
--- a/el-search.el
+++ b/el-search.el
@@ -7,7 +7,7 @@
;; Created: 29 Jul 2015
;; Keywords: lisp
;; Compatibility: GNU Emacs 25
-;; Version: 1.8.3
+;; Version: 1.8.4
;; Package-Requires: ((emacs "25") (stream "2.2.4") (cl-print "1.0"))
@@ -80,7 +80,8 @@
;; minibuffer). All commands that are not search or scrolling
;; commands terminate the search, while the state of the search is
;; always automatically saved. Like in isearch you can also just
-;; hit RET to exit.
+;; hit RET to exit or C-g to abort and jump back to where you
+;; started.
;;
;; C-R, M-s e r (el-search-pattern-backward)
;; Search backward.
@@ -409,10 +410,6 @@
;;
;; TODO:
;;
-;; - There should be a way to go back to the starting position, like
-;; in Isearch, which does this with (push-mark isearch-opoint t) in
-;; `isearch-done'.
-;;
;; - Add a help command that can be called while searching.
;;
;; - Make searching work in comments, too? (->
@@ -675,6 +672,8 @@ useful for debugging.")
(defvar el-search--current-search nil
"The currently active search, an `el-search-object', or nil.")
+(defvar el-search--search-origin nil)
+
(defvar-local el-search--temp-buffer-flag nil
"Non-nil tags file visiting buffers as temporarily opened for searching.")
@@ -1767,10 +1766,31 @@ any case."
(interactive)
nil)
+(defun el-search--set-search-origin-maybe ()
+ (unless (el-search--pending-search-p)
+ (setq el-search--search-origin
+ (list (copy-marker (point))
+ (selected-window)))))
+
+(defun el-search-keyboard-quit (&optional dont-quit)
+ "Abort el-search, signaling quit.
+Go back to the place where the search had been started."
+ (interactive)
+ (setq el-search--success nil)
+ (el-search-hl-post-command-fun) ;clear highlighting
+ (let ((w (cadr el-search--search-origin)))
+ (when (window-live-p w)
+ (select-frame-set-input-focus (window-frame w))
+ (select-window w)))
+ (switch-to-buffer (marker-buffer (car el-search--search-origin)))
+ (goto-char (car el-search--search-origin))
+ (unless dont-quit (signal 'quit nil)))
+
(defvar el-search-basic-transient-map
(let ((transient-map (make-sparse-keymap)))
- (define-key transient-map [return] #'el-search-pause-search)
- (define-key transient-map (kbd "RET") #'el-search-pause-search)
+ (define-key transient-map [return] #'el-search-pause-search)
+ (define-key transient-map (kbd "RET") #'el-search-pause-search)
+ (define-key transient-map [(control ?g)] #'el-search-keyboard-quit)
transient-map))
(defvar el-search-prefix-key-transient-map
@@ -1834,6 +1854,7 @@ any case."
(setq el-search-use-transient-map t))
(defun el-search-setup-search-1 (pattern get-buffer-stream &optional
from-here setup-function)
+ (el-search--set-search-origin-maybe)
(setq el-search--success nil)
(setq el-search--current-search
(el-search-make-search pattern get-buffer-stream))
@@ -2326,7 +2347,8 @@ created.")
(concat "[Not at a match] "
(if (= matches-<=-here total-matches)
(format "(%s/%s <-)" matches-<=-here
total-matches)
- (format "(-> %s/%s)" (1+ matches-<=-here)
total-matches))))))))))))
+ (format "(-> %s/%s)" (1+ matches-<=-here)
total-matches))))))))))
+ (when quit-flag (el-search-keyboard-quit 'dont-quit))))
(defun el-search-hl-other-matches (matcher)
"Highlight all visible matches.
@@ -2411,6 +2433,7 @@ In a non-interactive call, ARG should be an integer,
having the
same meaning as a numeric prefix arg, or an el-search-object to
make current."
(interactive "P")
+ (el-search--set-search-origin-maybe)
(when (integerp arg)
(el-search-barf-if-not-search-buffer
(current-buffer)
@@ -2517,6 +2540,8 @@ instead of the position where the search would normally be
continued."
(interactive "P")
(setq this-command 'el-search-pattern)
+ (unless (eq last-command this-command)
+ (el-search--set-search-origin-maybe))
(el-search-compile-pattern-in-search el-search--current-search)
(el-search-protect-search-head
(unwind-protect
@@ -2687,6 +2712,7 @@ executed, and nil else."
With prefix ARG, restart the current search when positive; go to the
last match in the current buffer when negative."
(interactive "P")
+ (el-search--set-search-origin-maybe)
(cond
((< (prefix-numeric-value arg) 0)
(el-search-last-buffer-match))
@@ -2704,7 +2730,7 @@ last match in the current buffer when negative."
(defun el-search-last-buffer-match ()
"Go to the last of this buffer's matches."
(interactive)
- (setq this-command 'el-search-pattern)
+ (el-search--set-search-origin-maybe)
(el-search-barf-if-not-search-buffer)
(el-search--unless-no-buffer-match
(goto-char (point-max))
- [elpa] externals/el-search 8175417 237/332: * el-search/el-search.el: More minor tweaks, (continued)
- [elpa] externals/el-search 8175417 237/332: * el-search/el-search.el: More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1f81442 241/332: [el-search] Improve forward search functions, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5c3bd4e 247/332: [el-search] Add bindings for first/last match jumping, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3699425 246/332: [el-search] Add command 'el-search-last-buffer-match', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search cf68daf 249/332: [el-search] Avoid most calls to 'scan-sexps', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 894f8b1 254/332: [el-search] More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6c5a6b4 265/332: [el-search] Fix an infloop in el-search--search-pattern-1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b830be5 263/332: [el-search] Some scrolling tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e60f228 267/332: [el-search] Don't try to kill modified buffers, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 34f734e 258/332: [el-search] Add special scroll commands, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d4ad652 278/332: [el-search] Implement an explicit quit command,
Stefan Monnier <=
- [elpa] externals/el-search fbe70bf 284/332: [el-search] Add C-h help, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search fac5586 285/332: [el-search] Improve my last commit "Add C-h help", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 23911d1 288/332: [el-search] Add menus, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 68fcfcd 286/332: [el-search] Include preceding comments in occur defun context, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 90062c5 290/332: Update copyrights of some packages, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 120c662 296/332: [el-search] Minibuffer pattern prompt hints part 2, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 668d049 302/332: [el-search] Add el-search-list-defined-patterns, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search bb978b2 306/332: [el-search] Fix behavior after completed single-buffer search, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 985ca3c 312/332: [el-search] Add "List patterns" menu item, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f5e8235 321/332: [el-search] C-c C-c in edit-replacement means replace, Stefan Monnier, 2020/12/01