Fix miscounting in anzu (search) modeline segment

This commit is contained in:
Henrik Lissner 2018-03-20 03:40:18 -04:00
parent 3777474471
commit 940ba05e6a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -11,6 +11,15 @@
(setq anzu-cons-mode-line-p nil
anzu-minimum-input-length 1
anzu-search-threshold 250)
(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