[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/isearch-mb d075efe 06/20: Rename minor modes, move a te
From: |
Stefan Monnier |
Subject: |
[elpa] externals/isearch-mb d075efe 06/20: Rename minor modes, move a test to the timer function |
Date: |
Sun, 16 May 2021 17:21:12 -0400 (EDT) |
branch: externals/isearch-mb
commit d075efe095c31b17aaff37178f0e1356ef627dd1
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Rename minor modes, move a test to the timer function
---
isearch-mb.el | 75 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 38 insertions(+), 37 deletions(-)
diff --git a/isearch-mb.el b/isearch-mb.el
index 43b74d9..c1b576f 100644
--- a/isearch-mb.el
+++ b/isearch-mb.el
@@ -83,13 +83,13 @@
(defun isearch-mb--message (message)
"Display a momentary MESSAGE."
- (when isearch-mb-mode
+ (when isearch-mb-local-mode
(message (propertize (concat " [" message "]")
'face 'minibuffer-prompt))))
(defun isearch-mb--prompt (&rest _)
"Update the minibuffer prompt according to search status."
- (prog1 isearch-mb-mode
+ (prog1 isearch-mb-local-mode
(when isearch-mb--prompt-overlay
(overlay-put isearch-mb--prompt-overlay
'before-string
@@ -123,48 +123,49 @@ Intended as an advice for commands that quit Isearch."
(defun isearch-mb--session ()
"Read search string from the minibuffer."
- (when isearch-mode
- (condition-case nil
- (apply
- (catch 'isearch-mb--after-exit
- (let (;; Hack to render `isearch-pre-command-hook' without effect.
- (isearch--saved-overriding-local-map t)
- ;; We need to set `inhibit-redisplay' at certain points to
- ;; avoid flicker. As a side effect, window-start/end in
- ;; `isearch-lazy-highlight-update' will have incorrect values,
- ;; so we need to lazy-highlight the whole buffer.
- (lazy-highlight-buffer (not (null isearch-lazy-highlight))))
- (minibuffer-with-setup-hook
- (lambda ()
- (add-hook 'post-command-hook 'isearch-mb--post-command-hook
nil 'local)
- (setq isearch-mb--prompt-overlay (make-overlay (point-min)
(point-min)
-
(current-buffer) t t))
- (isearch-mb--prompt))
- (read-from-minibuffer
- "I-search: "
- isearch-string
- isearch-mb-minibuffer-map
- nil
- (if isearch-regexp 'regexp-search-ring 'search-ring)
- (when-let (thing (thing-at-point 'symbol))
- (if isearch-regexp (regexp-quote thing) thing))
- t))
- (if isearch-mode '(isearch-done) '(ignore)))))
- (quit (if isearch-mode (isearch-cancel) (signal 'quit nil))))))
+ (condition-case nil
+ (apply
+ (catch 'isearch-mb--after-exit
+ (let (;; We need to set `inhibit-redisplay' at certain points to
+ ;; avoid flicker. As a side effect, window-start/end in
+ ;; `isearch-lazy-highlight-update' will have incorrect values,
+ ;; so we need to lazy-highlight the whole buffer.
+ (lazy-highlight-buffer (not (null isearch-lazy-highlight))))
+ (minibuffer-with-setup-hook
+ (lambda ()
+ (add-hook 'post-command-hook 'isearch-mb--post-command-hook
nil 'local)
+ (setq isearch-mb--prompt-overlay (make-overlay (point-min)
(point-min)
+
(current-buffer) t t))
+ (isearch-mb--prompt))
+ (read-from-minibuffer
+ "I-search: "
+ isearch-string
+ isearch-mb-minibuffer-map
+ nil
+ (if isearch-regexp 'regexp-search-ring 'search-ring)
+ (when-let (thing (thing-at-point 'symbol))
+ (if isearch-regexp (regexp-quote thing) thing))
+ t))
+ (if isearch-mode '(isearch-done) '(ignore)))))
+ (quit (if isearch-mode (isearch-cancel) (signal 'quit nil)))))
(defun isearch-mb--setup ()
"Arrange to start Isearch-Mb after this command, if applicable."
- (when isearch-mb-mode
+ (when isearch-mb-local-mode
(setq overriding-terminal-local-map nil)
- (run-with-idle-timer 0 nil 'isearch-mb--session)))
+ ;; When `with-isearch-suspended' is involved, this hook may run
+ ;; more than once, hence the test for `isearch-mode'.
+ (run-with-idle-timer 0 nil (lambda() (when isearch-mode
(isearch-mb--session))))))
(add-hook 'isearch-mode-hook 'isearch-mb--setup)
(put 'next-history-element 'isearch-mb--no-search t)
(put 'previous-history-element 'isearch-mb--no-search t)
-(advice-add 'isearch-message :before-until 'isearch-mb--prompt)
+(advice-add 'isearch-message :before-until 'isearch-mb--prompt)
(advice-add 'isearch--momentary-message :before-until 'isearch-mb--message)
+(advice-add 'isearch-pre-command-hook :before-until (lambda ()
isearch-mb-local-mode))
+(advice-add 'isearch-post-command-hook :around 'isearch-mb--with-buffer)
(advice-add 'isearch-beginning-of-buffer :around 'isearch-mb--with-buffer)
(advice-add 'isearch-end-of-buffer :around 'isearch-mb--with-buffer)
@@ -185,16 +186,16 @@ Intended as an advice for commands that quit Isearch."
(advice-add 'isearch-highlight-lines-matching-regexp :around
'isearch-mb--after-exit)
;;;###autoload
-(define-minor-mode isearch-mb-mode
+(define-minor-mode isearch-mb-local-mode
"Control Isearch from the minibuffer.
During an Isearch-Mb session, the following keys are available:
\\{isearch-mb-minibuffer-map}")
;;;###autoload
-(define-globalized-minor-mode isearch-mb-global-mode
- isearch-mb-mode
- (lambda () (unless (minibufferp) (isearch-mb-mode))))
+(define-globalized-minor-mode isearch-mb-mode
+ isearch-mb-local-mode
+ (lambda () (unless (minibufferp) (isearch-mb-local-mode))))
(provide 'isearch-mb)
;;; isearch-mb.el ends here
- [elpa] externals/isearch-mb 1c16403 15/20: Keep advices only for the duration of a search session, (continued)
- [elpa] externals/isearch-mb 1c16403 15/20: Keep advices only for the duration of a search session, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb ce41e00 12/20: Add a Readme, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb c6fc566 18/20: Use remapping in minibuffer keymap, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 5d5b0e9 17/20: Replace advices by let-bindings where possible, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb a663c22 16/20: Better place to check if Isearch is still active, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb dc603a9 03/20: Lazily highlight the whole buffer, to avoid missing overlays, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 40add97 01/20: Initial commit, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 8566108 02/20: Many changes, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 223b1b9 04/20: Introduce a buffer-local minor mode, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 5805f13 07/20: Add keybinding for newline, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb d075efe 06/20: Rename minor modes, move a test to the timer function,
Stefan Monnier <=
- [elpa] externals/isearch-mb 9f11fda 05/20: Several improvements, reorganization, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb a8d2a15 10/20: Provide future history, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb fccf1b7 08/20: Fix post-command hook for the failed search case, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 01fdc36 19/20: Update Readme, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb c38032c 09/20: Display error messages occurring at the beginning of search, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 4aa89c1 13/20: Define only a global minor mode., Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb 0b58b14 14/20: Require cl-lib when compiling, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb c491220 11/20: Use after-change-functions, Stefan Monnier, 2021/05/16
- [elpa] externals/isearch-mb c270809 20/20: Pad lazy count so that it only grows, Stefan Monnier, 2021/05/16