commit 5d7d2bac8584f451c311e80f49f5eb2c2bbcad78 parent 6bc888611d4c6c19aaf6f46e0f18a608fc5f8778 Author: andsy10 <andsy1016@gmail.com> Date: Fri, 28 Aug 2026 02:23:08 +0800 Add isearch-lazy-count display to mode-line Diffstat:
| M | lisp/init-base.el | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
| M | lisp/init-package.el | | | 6 | ------ |
| M | lisp/init-terminal.el | | | 3 | +++ |
3 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/lisp/init-base.el b/lisp/init-base.el @@ -309,5 +309,52 @@ (setq speedbar-prefer-window t)) (setq speedbar-use-images nil)) +;; isearch +(use-package isearch + :straight nil + :init + ;; move lazy count numbers to mode-line + (setq isearch-lazy-count t + lazy-count-prefix-format nil) + + (defface my-isearch-count + '((t (:inherit font-lock-type-face :weight bold))) + "Face for the isearch match count in the mode-line.") + + (defconst my-isearch-count--mode-line-construct + '(:eval (my-isearch-count-format))) + + (defun my-isearch-count-format () + "Like `isearch-lazy-count-format' but use custom format." + (when (and isearch-mode + isearch-lazy-count + isearch-lazy-count-current + (not isearch-error) + (not isearch-suspended)) + (propertize + (format "(%s/%s) " + (if isearch-lazy-highlight-forward + isearch-lazy-count-current + (if (eq isearch-lazy-count-current 0) + 0 + (- isearch-lazy-count-total + isearch-lazy-count-current + -1))) + (if (and isearch-lazy-count-invisible + lazy-count-invisible-format) + (concat (format "%s" (or isearch-lazy-count-total "?")) + (format lazy-count-invisible-format + isearch-lazy-count-invisible)) + (or isearch-lazy-count-total "?"))) + 'face 'my-isearch-count))) + + (unless (member my-isearch-count--mode-line-construct + (default-value 'mode-line-format)) + (setq-default mode-line-format + (cons my-isearch-count--mode-line-construct + (default-value 'mode-line-format)))) + + (add-hook 'lazy-count-update-hook #'force-mode-line-update)) + (provide 'init-base) ;;; init-base.el ends here diff --git a/lisp/init-package.el b/lisp/init-package.el @@ -7,12 +7,6 @@ ;; keycast (use-package keycast) -;; display match count for isearch -(use-package anzu - :delight - :hook - (after-init . global-anzu-mode)) - ;; ripgrep (use-package rg) diff --git a/lisp/init-terminal.el b/lisp/init-terminal.el @@ -133,6 +133,9 @@ ;; mouse support (xterm-mouse-mode 1) +;; show isearch match numbers +(setq isearch-lazy-count t) + ;; theme (if (>= (display-color-cells) 16777216) (progn