From 5c5cbe23dbf5cd9302034b774f3cd844c57a33f6 Mon Sep 17 00:00:00 2001 From: Julien Wintz Date: Thu, 3 May 2018 20:12:21 +0200 Subject: [PATCH] Enabled vanilla anzu. --- modules/ui/doom-modeline/config.el | 28 ++++++++++++++++++++++++++++ modules/ui/doom-modeline/packages.el | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/ui/doom-modeline/config.el b/modules/ui/doom-modeline/config.el index f4557afc3..ca91d34d3 100644 --- a/modules/ui/doom-modeline/config.el +++ b/modules/ui/doom-modeline/config.el @@ -2,6 +2,34 @@ ;; anzu and evil-anzu expose current/total state that can be displayed in the ;; mode-line. + +(def-package! anzu + :defer t + :commands 'isearch + :config + (setq anzu-cons-mode-line-p nil + anzu-minimum-input-length 1 + anzu-search-threshold 250) + (global-anzu-mode +1) + + (defun +doom-modeline*fix-anzu-count (positions here) + (cl-loop for (start . end) in positions + collect t into before + when (and (>= here start) (<= here end)) + return (length before) + finally return 0)) + (advice-add #'anzu--where-is-here :override #'+doom-modeline*fix-anzu-count) + + ;; Avoid anzu conflicts across buffers + (mapc #'make-variable-buffer-local + '(anzu--total-matched anzu--current-position anzu--state + anzu--cached-count anzu--cached-positions anzu--last-command + anzu--last-isearch-string anzu--overflow-p)) + ;; Ensure anzu state is cleared when searches & iedit are done + (add-hook 'isearch-mode-end-hook #'anzu--reset-status t) + (add-hook 'doom-escape-hook #'anzu--reset-status t) + (add-hook 'iedit-mode-end-hook #'anzu--reset-status)) + (def-package! evil-anzu :requires evil :init diff --git a/modules/ui/doom-modeline/packages.el b/modules/ui/doom-modeline/packages.el index b5f2ee002..ae47c9eef 100644 --- a/modules/ui/doom-modeline/packages.el +++ b/modules/ui/doom-modeline/packages.el @@ -9,10 +9,11 @@ ;; Optional ;;(require 'flycheck) -;;(require 'anzu) ;;(require 'iedit) ;;(require 'evil-multiedit) +(require 'anzu) + (when (featurep! :feature evil) (package! evil-anzu))