emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/isearch-mb a67f51b723: Define scroll up/down commands


From: ELPA Syncer
Subject: [elpa] externals/isearch-mb a67f51b723: Define scroll up/down commands
Date: Wed, 16 Mar 2022 16:57:39 -0400 (EDT)

branch: externals/isearch-mb
commit a67f51b723f25716036de75b0c8943900e5d8fe8
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Define scroll up/down commands
    
    In this way, we don't need to handle isearch-motion symbol properties
    specially in isearch-mb--with-buffer.  Moreover,
    isearch-beginning/end-of-buffer are more useful than the
    isearch-motion forms because they accept prefix arguments.
---
 README.org    | 18 +++++++++---------
 isearch-mb.el | 45 ++++++++++++++++++++++++++-------------------
 2 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/README.org b/README.org
index e5c0150fae..62255295b8 100644
--- a/README.org
+++ b/README.org
@@ -18,15 +18,15 @@ isearch-mb-mode RET=.
 During a search, =isearch-mb-minibuffer-map= is active. By default, it
 includes the following commands:
 
-- =C-s=, =↓=: =isearch-repeat-forward=
-- =C-r=, =↑=: =isearch-repeat-backward=
-- =M-<=: =beginning-of-buffer= (in the search buffer)
-- =M->=: =end-of-buffer= (in the search buffer)
-- =M-v=, =<prior>=: =scroll-down-command= (in the search buffer)
-- =C-v=, =<next>=: =scroll-up-command= (in the search buffer)
-- =M-%=: =isearch-query-replace=
-- =C-M-%=: =isearch-query-replace-regexp=
-- =M-s= prefix: similar to standard isearch
+- =C-s=, =↓=: Repeat search forwards.
+- =C-r=, =↑=: Repeat search backwards.
+- =M-<=: Go to first match (or /n/-th match with numeric argument).
+- =M->=: Go to last match (or /n/-th last match with numeric argument).
+- =C-v=, =<next>=: Search forward from the bottom of the window.
+- =M-v=, =<prior>=: Search backward from the top of the window.
+- =M-%=: Replace occurrences of the search string.
+- =C-M-%=: Replace occurrences of the search string (regexp mode).
+- =M-s= prefix: similar to standard isearch.
 
 Everything else works as in a plain minibuffer. For instance, =RET=
 ends the search normally and =C-g= cancels it.
diff --git a/isearch-mb.el b/isearch-mb.el
index 5ad71a3769..530550beb0 100644
--- a/isearch-mb.el
+++ b/isearch-mb.el
@@ -43,10 +43,8 @@
   :group 'isearch)
 
 (defvar isearch-mb--with-buffer
-  '(beginning-of-buffer
-    end-of-buffer
-    scroll-up-command
-    scroll-down-command
+  '(isearch-beginning-of-buffer
+    isearch-end-of-buffer
     isearch-occur
     isearch-repeat-backward
     isearch-repeat-forward
@@ -77,7 +75,10 @@
   (let ((map (make-composed-keymap nil minibuffer-local-map)))
     (define-key map [remap next-line-or-history-element] 
#'isearch-repeat-forward)
     (define-key map [remap previous-line-or-history-element] 
#'isearch-repeat-backward)
-    (define-key map [remap minibuffer-beginning-of-buffer] 
#'beginning-of-buffer)
+    (define-key map [remap minibuffer-beginning-of-buffer] 
#'isearch-beginning-of-buffer)
+    (define-key map [remap end-of-buffer] #'isearch-end-of-buffer)
+    (define-key map [remap scroll-up-command] 'isearch-mb-scroll-up-command)
+    (define-key map [remap scroll-down-command] 
'isearch-mb-scroll-down-command)
     (define-key map [remap query-replace] #'isearch-query-replace)
     (define-key map [remap query-replace-regexp] 
#'isearch-query-replace-regexp)
     (define-key map "\C-j" #'newline)
@@ -182,22 +183,28 @@ Intended as an advice for isearch commands."
       (let ((enable-recursive-minibuffers t)
             (inhibit-redisplay t))
         (with-minibuffer-selected-window
-          (if-let ((motion (and (symbolp this-command)
-                                (get this-command 'isearch-motion)))
-                   (direction (cdr motion))
-                   (current-direction (if isearch-forward 'forward 'backward)))
-              (progn ;; Handle special motion commands, as in 
`isearch-pre-command-hook'.
-                (funcall (car motion))
-                (setq isearch-just-started t)
-                (let ((isearch-repeat-on-direction-change nil))
-                  (isearch-repeat direction)
-                  (when (and isearch-success
-                             (not isearch-motion-changes-direction)
-                             (not (eq direction current-direction)))
-                    (isearch-repeat current-direction))))
-            (apply args))))
+          (apply args)))
     (apply args)))
 
+;; Special motion commands normally handled in `isearch-pre-command-hook'.
+(dolist (symbol '(scroll-up-command scroll-down-command))
+  (defalias (intern (concat "isearch-mb-" (symbol-name symbol)))
+    (let ((fun (pcase (get symbol 'isearch-motion)
+                 (`(,motion . ,direction)
+                  (lambda ()
+                    (let ((current-direction (if isearch-forward 'forward 
'backward)))
+                      (funcall motion)
+                      (setq isearch-just-started t)
+                      (let ((isearch-repeat-on-direction-change nil))
+                        (isearch-repeat direction)
+                        (when (and isearch-success
+                                   (not isearch-motion-changes-direction)
+                                   (not (eq direction current-direction)))
+                          (isearch-repeat current-direction))))))
+                 (_ symbol)))) ;; Emacs < 28
+      (lambda () (interactive) (isearch-mb--with-buffer fun)))
+    (format "Perform motion of `%s' in the search buffer." symbol)))
+
 (defun isearch-mb--after-exit (&rest args)
   "Evaluate ARGS after quitting isearch-mb.
 Intended as an advice for commands that quit isearch and use the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]