Fix for evil-anzu.

This commit is contained in:
Vincent Zhang 2018-06-19 19:01:56 +08:00
parent 96d6fda059
commit 55269e7288

View file

@ -204,27 +204,29 @@ If STRICT-P, return nil if no project was found, otherwise return
;; anzu and evil-anzu expose current/total state that can be displayed in the ;; anzu and evil-anzu expose current/total state that can be displayed in the
;; mode-line. ;; mode-line.
(setq anzu-cons-mode-line-p nil (when (feature 'evil-anzu)
(setq anzu-cons-mode-line-p nil
anzu-minimum-input-length 1 anzu-minimum-input-length 1
anzu-search-threshold 250) anzu-search-threshold 250)
(defun doom-modeline-fix-anzu-count (positions here) (defun doom-modeline-fix-anzu-count (positions here)
(cl-loop for (start . end) in positions (cl-loop for (start . end) in positions
collect t into before collect t into before
when (and (>= here start) (<= here end)) when (and (>= here start) (<= here end))
return (length before) return (length before)
finally return 0)) finally return 0))
(advice-add #'anzu--where-is-here :override #'doom-modeline-fix-anzu-count) (advice-add #'anzu--where-is-here :override #'doom-modeline-fix-anzu-count)
;; Avoid anzu conflicts across buffers ;; Avoid anzu conflicts across buffers
;; (mapc #'make-variable-buffer-local (mapc #'make-variable-buffer-local
;; '(anzu--total-matched anzu--current-position anzu--state '(anzu--total-matched anzu--current-position anzu--state
;; anzu--cached-count anzu--cached-positions anzu--last-command anzu--cached-count anzu--cached-positions anzu--last-command
;; anzu--last-isearch-string anzu--overflow-p)) anzu--last-isearch-string anzu--overflow-p))
;; Ensure anzu state is cleared when searches & iedit are done ;; Ensure anzu state is cleared when searches & iedit are done
(add-hook 'isearch-mode-end-hook #'anzu--reset-status t) (add-hook 'isearch-mode-end-hook #'anzu--reset-status t)
(add-hook 'iedit-mode-end-hook #'anzu--reset-status) ;; (add-hook '+evil-esc-hook #'anzu--reset-status t)
(add-hook 'iedit-mode-end-hook #'anzu--reset-status))
;; Keep `doom-modeline-current-window' up-to-date ;; Keep `doom-modeline-current-window' up-to-date