[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/mheerdegen-preview b4b94b0 11/35: WIP [el-search] Impleme
From: |
Michael Heerdegen |
Subject: |
[elpa] scratch/mheerdegen-preview b4b94b0 11/35: WIP [el-search] Implement 'el-search-keyboard-quit' |
Date: |
Mon, 29 Oct 2018 22:24:05 -0400 (EDT) |
branch: scratch/mheerdegen-preview
commit b4b94b0dd124cc3c59735197c48d7db8ce976744
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
WIP [el-search] Implement 'el-search-keyboard-quit'
---
packages/el-search/el-search.el | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index dd1ddf7..90b8d04 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -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 hit C-g to abort and jump back to where you
+;; started.
;;
;; C-R, M-s e r (el-search-pattern-backward)
;; Search backward.
@@ -414,10 +415,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? (->
@@ -677,6 +674,9 @@ 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
+ "Doc...")
+
(defvar-local el-search--temp-buffer-flag nil
"Non-nil tags file visiting buffers as temporarily opened for searching.")
@@ -1779,10 +1779,24 @@ any case."
(interactive)
nil)
+(defun el-search--set-search-origin-maybe ()
+ (unless (el-search--pending-search-p)
+ (setq el-search--search-origin (copy-marker (point)))))
+
+(defun el-search-keyboard-quit (&optional dont-quit)
+ (interactive)
+ (setq el-search--success nil)
+ (el-search-hl-post-command-fun) ;clear highlighting
+ (switch-to-buffer (marker-buffer el-search--search-origin))
+ (goto-char 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
@@ -1847,6 +1861,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))
@@ -2380,7 +2395,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.
@@ -2463,6 +2479,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)
@@ -2569,6 +2586,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
@@ -2739,6 +2758,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))
@@ -2756,7 +2776,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] scratch/mheerdegen-preview 76163ac 01/35: WIP: [el-search] Fix an infloop, (continued)
- [elpa] scratch/mheerdegen-preview 76163ac 01/35: WIP: [el-search] Fix an infloop, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview ee441a0 03/35: WIP: Add diverse "sloppy" pattern types, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 9805060 02/35: WIP: [el-search] Fix nested match issues in *El Occur*, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 220f349 04/35: WIP: Add package "sscell", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview bef717d 06/35: WIP: New :key arg for "filename" and new pattern types "file" and "dir", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview d2faca2 09/35: WIP: New command 'el-search-repository', Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 2f72331 08/35: WIP: New file el-search/el-search-pp.el, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f2ec15d 13/35: WIP [el-search] Fix more "redundant _ pattern" cases, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f025458 12/35: WIP [el-search] Add quick help command, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f23fe5e 17/35: WIP: Optimize caching, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview b4b94b0 11/35: WIP [el-search] Implement 'el-search-keyboard-quit',
Michael Heerdegen <=
- [elpa] scratch/mheerdegen-preview 44715aa 05/35: WIP: New package "gnus-article-notes", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 5057b57 14/35: WIP [el-search] Discourage using symbols as LPATS in `append' and `l', Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 5e2aea1 20/35: WIP [el-search] Adjust prev/next match commands for search and occur, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 38def8b 25/35: WIP: Test: Make mouse clicks not abort the search, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview feede7d 23/35: WIP: [el-search] Fine tune separator for splicing replace, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 82abecf 16/35: WIP: Additions to "Mb hints", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview df2132a 21/35: WIP: Improvements for change and changed, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 2ec7a9e 22/35: WIP: More colorful match count, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 91f5bd3 18/35: WIP [el-search] Fix C-j with numeric arg in error case, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 237c2c6 33/35: WIP: [el-search] Enhance doc of el-search-occur-mode, Michael Heerdegen, 2018/10/29