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

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

[elpa] isearch-mb ffd65df 5/7: Update Readme


From: Stefan Monnier
Subject: [elpa] isearch-mb ffd65df 5/7: Update Readme
Date: Mon, 17 May 2021 12:18:41 -0400 (EDT)

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

    Update Readme
---
 README.md | 67 +++++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index d682160..e07490a 100644
--- a/README.md
+++ b/README.md
@@ -19,8 +19,8 @@ Keybindings
 During a search, `isearch-mb-minibuffer-map` is active.  By default,
 it includes the following commands:
 
-- <kbd>C-s</kbd>: `isearch-repeat-forward`
-- <kbd>C-r</kbd>: `isearch-repeat-backward`
+- <kbd>C-s</kbd>, <kbd>↓</kbd>: `isearch-repeat-forward`
+- <kbd>C-r</kbd>, <kbd>↑</kbd>: `isearch-repeat-backward`
 - <kbd>M-<</kbd>: `isearch-beginning-of-buffer`
 - <kbd>M-></kbd>: `isearch-end-of-buffer`
 - <kbd>M-%</kbd>: `isearch-query-replace`
@@ -71,37 +71,62 @@ strict whitespace matching with <kbd>M-s SPC</kbd> during a 
search.
 Interaction with other Isearch extensions
 -----------------------------------------
 
-Some third-party Isearch extensions need to be patched to work with
-Isearch-Mb.  There are three cases to consider:
+Some third-party Isearch extensions require a bit of configuration in
+order to work with Isearch-Mb.  There are three cases to consider:
 
 - **Commands that start a search** shouldn't require extra
   configuration.
-  
-- **Commands that operate during a search session** require the
-  `isearch-mb--with-buffer` advice.  Examples of this case are
-  [`loccur-isearch`][loccur] and [`consult-isearch`][consult]:
-  
+
+- **Commands that operate during a search session** should be added to
+  the list `isearch-mb--with-buffer`.  Examples of this case are
+  [`loccur-isearch`][loccur] and [`consult-isearch`][consult].
+
+  ``` elisp
+  (add-to-list 'isearch-mb--with-buffer #'loccur-isearch)
+  (define-key isearch-mb-minibuffer-map (kbd "C-o") #'loccur-isearch)
+
+  (add-to-list 'isearch-mb--with-buffer #'consult-isearch)
+  (define-key isearch-mb-minibuffer-map (kbd "M-r") #'consult-isearch)
+  ```
+
+  Most Isearch commands that are not made available by default in
+  Isearch-Mb can also be used in this fashion:
+
   ``` elisp
-  (advice-add 'loccur-isearch :around 'isearch-mb--with-buffer)
-  (define-key isearch-mb-minibuffer-map (kbd "C-o") 'loccur-isearch)
-  
-  (advice-add 'consult-isearch :around 'isearch-mb--with-buffer)
-  (define-key isearch-mb-minibuffer-map (kbd "M-r") 'consult-isearch)
+  (add-to-list 'isearch-mb--with-buffer #'isearch-yank-word)
+  (define-key isearch-mb-minibuffer-map (kbd "M-s C-w") #'isearch-yank-word)
   ```
-  
-- **Commands that end the Isearch session** require the
-  `isearch-mb--after-exit` advice.  Examples of this case are
-  [`anzu-isearch-query-replace`][anzu] and
-  [`consult-line`][consult]:
+
+- **Commands that end the Isearch session** should be added to the
+  list `isearch-mb--after-exit`.  Examples of this case are
+  [`anzu-isearch-query-replace`][anzu] and [`consult-line`][consult]:
 
   ``` elisp
-  (advice-add 'anzu-isearch-query-replace :around 'isearch-mb--after-exit)
+  (add-to-list 'isearch-mb--after-exit #'anzu-isearch-query-replace)
   (define-key isearch-mb-minibuffer-map (kbd "M-%") 
'anzu-isearch-query-replace)
 
-  (advice-add 'consult-line :around 'isearch-mb--after-exit)
+  (add-to-list 'isearch-mb--after-exit #'consult-line)
   (define-key isearch-mb-minibuffer-map (kbd "M-s l") 'consult-line)
   ```
 
+  Making motion commands quit the search as in standard Isearch is out
+  of the scope of this package, but can achieved with a bit of work.
+  Here is one possibility:
+
+  ```elisp
+  (defun move-end-of-line-maybe-ending-isearch (arg)
+  "End search and move to end of line, but only if already at the end of the 
minibuffer."
+    (interactive "p")
+    (if (eobp)
+        (isearch-mb--after-exit
+         (lambda ()
+           (move-end-of-line arg)
+           (isearch-done)))
+      (move-end-of-line arg)))
+
+  (define-key isearch-mb-minibuffer-map (kbd "C-e") 
'move-end-of-line-maybe-ending-isearch)
+  ```
+
 [consult]: https://github.com/minad/consult
 [loccur]: https://github.com/fourier/loccur#isearch-integration
 [anzu]: https://github.com/emacsorphanage/anzu



reply via email to

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