[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 146ea5d: [el-search] Add some key bindings
[elpa] master 146ea5d: [el-search] Add some key bindings
Sat, 1 Sep 2018 12:50:55 -0400 (EDT)
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
[el-search] Add some key bindings
This commit adds key bindings for the recently added scroll commands.
It also provides a way to officially cancel a search or query-replace
session by hitting RET.
Update comments in header and bump version to 1.7.7.
(el-search-keep-transient-map-commands): Add 'el-search-scroll-down'
(el-search-pause-search): New command.
(el-search-basic-transient-map): New keymap that is always enabled
when a search is active. Bind RET to 'el-search-pause-search'.
(el-search-prefix-key-transient-map): Add binding for
'el-search-scroll-down' and 'el-search-scroll-up'. Set parent keymap
'el-search-prefix-key-transient-map' or only the new
'el-search-basic-transient-map' depending on the value of
(el-search-install-shift-bindings): Add bindings for
'el-search-scroll-down' and 'el-search-scroll-up'.
(el-search--search-and-replace-pattern): Let RET terminate
packages/el-search/NEWS | 33 ++++++++++++++++--------
packages/el-search/el-search.el | 57 +++++++++++++++++++++++++++++++++++------
2 files changed, 72 insertions(+), 18 deletions(-)
diff --git a/packages/el-search/NEWS b/packages/el-search/NEWS
index 2e44c8e..af00d2f 100644
@@ -1,22 +1,35 @@
Some of the user visible news were:
+ The new scroll commands `el-search-scroll-down' and
+ `el-search-scroll-up', bound to C-S-next and C-S-prior, or v and V
+ respectively, perform by-match scrolling: `el-search-scroll-down'
+ scrolls the next matches after `window-end' into view, i.e. it
+ selects the first match after `window-end'. Likewise,
+ `el-search-scroll-up' selects the last match before `window-start'.
+ You can now explicitly terminate (pause) search and query-replace
+ sessions by hitting RET.
-The meaning of the prefix argument of `el-search-jump-to-search-head'
-(C-J or M-s e j with the default bindings) has been extended: A
-numeric prefix N jumps to the Nth match after `window-start', while a
-negative prefix -N jumps to the Nth match before `window-end'. Prefix
-0 jumps to the match following point, which is also useful to resume
-the current search from any buffer position.
-A former search can now be made current with a plain C-u prefix arg.
+ The meaning of the prefix argument of
+ `el-search-jump-to-search-head' (C-J or M-s e j with the default
+ bindings) has been extended: A numeric prefix N jumps to the Nth
+ match after `window-start', while a negative prefix -N jumps to the
+ Nth match before `window-end'. Prefix 0 jumps to the match
+ following point, which is also useful to resume the current search
+ from any buffer position. A former search can now be made current
+ with a plain C-u prefix arg.
-Match highlighting faces have been improved to look better on text
-terminals. Matches in *El Occur* buffers are now highlighted with a
+ Match highlighting faces have been improved to look better on text
+ terminals. Matches in *El Occur* buffers are now highlighted with a
+ separate face.
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index 43c43c9..6cd83d8 100644
@@ -7,7 +7,7 @@
;; Created: 29 Jul 2015
;; Keywords: lisp
;; Compatibility: GNU Emacs 25
-;; Version: 1.7.6
+;; Version: 1.7.7
;; Package-Requires: ((emacs "25") (stream "2.2.4") (cl-print "1.0"))
@@ -76,6 +76,12 @@
;; C-S, M-s e s (el-search-pattern)
;; Start a search in the current buffer/go to the next match.
+;; While searching, the searched buffer is current (not the
+;; 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.
;; C-R, M-s e r (el-search-pattern-backward)
;; Search backward.
@@ -125,6 +131,12 @@
;; With a plain C-u prefix arg, prompt for a former search to
+;; C-S-next, v when search is active (el-search-scroll-down)
+;; C-S-prior, V when search is active (el-search-scroll-up)
+;; Scrolling by matches: Select the first match after
+;; `window-end', or select the first match before `window-start',
;; C-H, M-s e h (el-search-this-sexp)
;; Grab the symbol or sexp under point and initiate an el-search
;; for other occurrences.
@@ -553,6 +565,8 @@ The default value is ask-multi."
"List of commands that don't end repeatability of el-search commands.
@@ -1680,6 +1694,21 @@ in, in order, when called with no arguments."
(keybind ibuffer-mode-map ?s #'el-search-ibuffer-marked-buffers))))
+(defun el-search-pause-search ()
+ "Exit el-search normally.
+You also can invoke any other non-search command to exit an el-search
+normally - the state of the current search is automatically saved in
+ (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)
(let ((transient-map (make-sparse-keymap)))
@@ -1694,6 +1723,13 @@ in, in order, when called with no arguments."
(define-key transient-map (vector key) command))))
+ ;; v and V are analogue to Ediff - FIXME: this doesn't fit into the
+ ;; `el-search-loop-over-bindings' abstraction
+ (define-key transient-map [?v] #'el-search-scroll-down)
+ (define-key transient-map [?V] #'el-search-scroll-up)
+ (set-keymap-parent transient-map el-search-basic-transient-map)
(defun el-search-keep-session-command-p (command)
@@ -1705,10 +1741,12 @@ in, in order, when called with no arguments."
(get command 'scroll-command))))
(defun el-search-prefix-key-maybe-set-transient-map ()
- (when el-search-use-transient-map
- (set-transient-map el-search-prefix-key-transient-map
- (lambda () (or (memq this-command
+ (if el-search-use-transient-map
+ (lambda () (or (memq this-command el-search-keep-transient-map-commands)
+ (el-search-keep-session-command-p this-command)))))
(defun el-search-shift-bindings-bind-function (map key command)
(define-key map `[(control ,@(if (<= ?a key ?z) `(shift ,key) `(,key)))]
@@ -1716,7 +1754,9 @@ in, in order, when called with no arguments."
(defun el-search-install-shift-bindings ()
- (el-search-loop-over-bindings #'el-search-shift-bindings-bind-function))
+ (el-search-loop-over-bindings #'el-search-shift-bindings-bind-function)
+ (define-key el-search-basic-transient-map [C-S-next]
+ (define-key el-search-basic-transient-map [C-S-prior] #'el-search-scroll-up))
(defun el-search-bind-under-prefix-key-function (prefix)
(lambda (map key command)
@@ -3627,7 +3667,8 @@ exactly you did? Thanks!"))))
Toggle splicing mode (\\[describe-function] el-search-query-replace for
'(?o "show" "Show replacement in a
- '(?q "quit"))))))))
+ '(?q "quit")
+ '(?\r "quit"))))))))
(while (not (pcase (funcall query)
@@ -3685,7 +3726,7 @@ Replace all matches in all buffers"))))
- ((or ?q ?\C-g) (signal 'quit t))))))
+ ((or ?q ?\C-g ?\r) (signal 'quit
|[Prev in Thread]
||[Next in Thread]|
- [elpa] master 146ea5d: [el-search] Add some key bindings,
Michael Heerdegen <=