[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/isearch-mb 8566108 02/20: Many changes
From: |
Stefan Monnier |
Subject: |
[elpa] externals/isearch-mb 8566108 02/20: Many changes |
Date: |
Sun, 16 May 2021 17:21:11 -0400 (EDT) |
branch: externals/isearch-mb
commit 8566108bf04e3f62177764c5960302d995513000
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Many changes
---
isearch-mb.el | 155 +++++++++++++++++++++++++---------------------------------
1 file changed, 67 insertions(+), 88 deletions(-)
diff --git a/isearch-mb.el b/isearch-mb.el
index 94bb2c0..6bb39b9 100644
--- a/isearch-mb.el
+++ b/isearch-mb.el
@@ -26,130 +26,109 @@
(eval-when-compile (require 'subr-x))
+(put 'next-history-element 'isearch-mb-no-search t)
+(put 'previous-history-element 'isearch-mb-no-search t)
+
+(defvar isearch-mb--prompt-overlay nil
+ "Overlay for minibuffer prompt updates.")
+
(defun isearch-mb--post-command-hook ()
- (let ((new-string (minibuffer-contents)))
+ (let ((inhibit-redisplay t)
+ (new-string (minibuffer-contents)))
+ ;; We never update isearch-message. If it's not empty, then
+ ;; Isearch itself changed the search string, and we update it.
+ (unless (string-empty-p isearch-message)
+ (setq isearch-message "" new-string isearch-string)
+ (delete-minibuffer-contents)
+ (insert isearch-string))
(unless (string= new-string isearch-string)
(with-minibuffer-selected-window
(setq isearch-string new-string)
- (setq isearch-message new-string)
(isearch-update-from-string-properties new-string)
- (setq isearch-success t) ; Force isearch-search-and-update to try
- (if (memq this-command '(previous-history-element
- next-history-element))
+ (if (get this-command 'isearch-mb-no-search)
(isearch-update)
- (isearch-search-and-update)))))
+ ;; (isearch-fallback nil nil t)
+ (goto-char isearch-barrier)
+ (setq isearch-adjusted t)
+ (setq isearch-success t)
+ (isearch-search-and-update))
+ )))
(set-text-properties (minibuffer-prompt-end) (point-max) nil)
(when-let ((fail-pos (isearch-fail-pos)))
(add-text-properties (+ (minibuffer-prompt-end) fail-pos)
(point-max)
'(face isearch-fail)))
- (cond (nil (message "> ā%sā" isearch-string))
- (isearch-error
+ (cond (isearch-error
(isearch-mb--message isearch-error))
- (isearch-lazy-count-current
- (isearch-mb--message (isearch-lazy-count-format t)))))
+ (isearch-wrapped (isearch-mb--message "Wrapped"))))
(defun isearch-mb--minibuffer-setup ()
- (add-hook 'post-command-hook 'isearch-mb--post-command-hook)
- (add-hook 'minibuffer-exit-hook 'isearch-mb--minibuffer-exit-hook))
-
-(defun isearch-mb--minibuffer-exit-hook ()
- (remove-hook 'post-command-hook 'isearch-mb--post-command-hook)
- (remove-hook 'minibuffer-exit-hook 'isearch-mb--minibuffer-exit-hook))
+ (setq isearch-mb--prompt-overlay (make-overlay (point-min) (point-min)
+ (current-buffer) t t))
+ (isearch-mb--prompt)
+ (add-hook 'post-command-hook 'isearch-mb--post-command-hook nil 'local))
-(defun isearch-mb--message (message)
+(defun isearch-mb--message (message &rest _)
(message (propertize (concat " [" message "]")
'face 'minibuffer-prompt)))
-(defun isearch-mb--movement-command-advice (fn &rest args)
- (when (string-empty-p (minibuffer-contents))
- ;; TODO: Use isearch-cmds if possible
- (setq isearch-string (or (car (if isearch-regexp
- regexp-search-ring
- search-ring))
- (user-error "No previous search string")))
- (insert isearch-string))
- (let ((inhibit-redisplay t))
- (with-minibuffer-selected-window
- (apply fn args))))
+(defun isearch-mb--prompt (&rest _)
+ (when isearch-mb--prompt-overlay
+ (overlay-put isearch-mb--prompt-overlay 'before-string
+ (concat
+ (isearch-lazy-count-format)
+ (capitalize
+ (isearch--describe-regexp-mode isearch-regexp-function))))))
-(defun isearch-mb-toggle-word ()
- (interactive)
- (with-minibuffer-selected-window
- (isearch-toggle-word)))
+(defun isearch-mb--command-advice (fn &rest args)
+ (let ((inhibit-redisplay t))
+ (with-minibuffer-selected-window
+ (apply fn args))))
(defvar isearch-mb-minibuffer-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
(define-key map (kbd "C-s") 'isearch-repeat-forward)
- (define-key map (kbd "C-S-s") 'isearch-repeat-backward)
+ (define-key map (kbd "C-r") 'isearch-repeat-backward)
(define-key map (kbd "<down>") 'isearch-repeat-forward)
(define-key map (kbd "<up>") 'isearch-repeat-backward)
- (define-key map (kbd "C-r") 'consult-history)
- (define-key map (kbd "M-s w") 'isearch-mb-toggle-word)
+ (define-key map (kbd "M-s r") 'isearch-toggle-regexp)
+ (define-key map (kbd "M-s c") 'isearch-toggle-case-fold)
+ (define-key map (kbd "M-s w") 'isearch-toggle-word)
(define-key map (kbd "M-<") 'isearch-beginning-of-buffer)
(define-key map (kbd "M->") 'isearch-end-of-buffer)
map))
-(defun isearch-mb-semiflex-regexp (string &optional lax)
- "Return a regexp which matches the words of STRING."
- (let ((words (split-string-and-unquote string)))
- (mapconcat 'regexp-quote words ".*?")))
-
-(isearch-define-mode-toggle semiflex "f" isearch-mb-semiflex-regexp "\
-Turning on word search turns off regexp mode.")
-
-(defun isearch-mb-regexp-regexp (string &optional lax)
- "Return a regexp which matches the words of STRING."
- string)
-
-(isearch-define-mode-toggle regexp "r" isearch-mb-regexp-regexp "\
-Turning on word search turns off regexp mode.")
-
-(defun isearch-mb-plain-regexp (string &optional lax)
- "Return a regexp which matches the words of STRING."
- (regexp-quote string))
-
-(isearch-define-mode-toggle plain "p" isearch-mb-plain-regexp "\
-Turning on word search turns off regexp mode.")
-
(defun isearch-mb--isearch-mode-advice (fn &rest args)
"Advice to make `isearch-mode' read from the minibuffer."
(interactive)
(let ((isearch-mode-map nil)
- (enable-recursive-minibuffers nil)
- (lazy-highlight-interval nil)
- (lazy-highlight-initial-delay 0)
- (lazy-highlight-buffer-max-at-a-time nil)
- (lazy-count-suffix-format "%s of %s")
- ;; (isearch-message-function 'ignore)
- )
- (when (eq t (nth 1 args))
- (setq args `(,(car args) nil nil nil 'isearch-mb-regexp-regexp)))
- (when (eq t (nth 4 args))
- (setf (nth 4 args) 'word-search-regexp))
- (unwind-protect
- (progn
- ;(setq-local cursor-in-non-selected-windows 'always)
- (setq-local cursor-type 'hollow)
- (apply fn args)
- (minibuffer-with-setup-hook 'isearch-mb--minibuffer-setup
- (read-from-minibuffer "Search: " nil
- isearch-mb-minibuffer-map
- nil
- nil
- (thing-at-point 'symbol)))
- (isearch-exit))
- (when isearch-mode (ignore-error quit (isearch-cancel)))
- (kill-local-variable 'cursor-type))))
+ (history-add-new-input nil))
+ (unwind-protect
+ (progn
+ (apply fn args)
+ (minibuffer-with-setup-hook 'isearch-mb--minibuffer-setup
+ (read-from-minibuffer
+ "I-search: " nil
+ isearch-mb-minibuffer-map nil
+ (if isearch-regexp 'regexp-search-ring 'search-ring)
+ (if-let (thing (thing-at-point 'symbol))
+ (if isearch-regexp (regexp-quote thing) thing))
+ t))
+ (isearch-done))
+ (when isearch-mode (ignore-error quit (isearch-cancel))))))
(defvar isearch-mb--advices
- '((isearch-mode :around isearch-mb--isearch-mode-advice)
- (isearch-message :override ignore)
- (isearch-repeat-forward :around isearch-mb--movement-command-advice)
- (isearch-repeat-backward :around isearch-mb--movement-command-advice)
- (isearch-beginning-of-buffer :around isearch-mb--movement-command-advice)
- (isearch-end-of-buffer :around isearch-mb--movement-command-advice)))
+ '((isearch-mode :around isearch-mb--isearch-mode-advice)
+ (isearch-message :override isearch-mb--prompt)
+ (isearch--momentary-message :override isearch-mb--message)
+ (isearch-toggle-regexp :around isearch-mb--command-advice)
+ (isearch-toggle-case-fold :around isearch-mb--command-advice)
+ (isearch-toggle-word :around isearch-mb--command-advice)
+ (isearch-repeat-forward :around isearch-mb--command-advice)
+ (isearch-repeat-backward :around isearch-mb--command-advice)
+ (isearch-beginning-of-buffer :around isearch-mb--command-advice)
+ (isearch-end-of-buffer :around isearch-mb--command-advice)))
;;;###autoload
(define-minor-mode isearch-mb-mode
- [elpa] branch externals/isearch-mb created (now c270809), Stefan Monnier, 2021/05/16
- [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 <=
- [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, 2021/05/16
- [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