From 55269e7288edb7e8c86129a3eb8481a9207f32e1 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 19 Jun 2018 19:01:56 +0800 Subject: [PATCH] Fix for `evil-anzu`. --- doom-modeline.el | 116 ++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 1a17fc0..4745d0d 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -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 ;; mode-line. -(setq anzu-cons-mode-line-p nil - anzu-minimum-input-length 1 - anzu-search-threshold 250) +(when (feature 'evil-anzu) + (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) + (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)) + ;; 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 'iedit-mode-end-hook #'anzu--reset-status) + ;; Ensure anzu state is cleared when searches & iedit are done + (add-hook 'isearch-mode-end-hook #'anzu--reset-status t) + ;; (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 @@ -498,50 +500,50 @@ Example: ;; (doom-modeline-def-segment buffer-default-directory - "Displays `default-directory'. This is for special buffers like the scratch + "Displays `default-directory'. This is for special buffers like the scratch buffer where knowing the current project directory is important." - (let ((face (if (doom-modeline--active) 'doom-modeline-buffer-path))) - (concat (if (display-graphic-p) " ") - (doom-modeline-maybe-icon-octicon - "file-directory" - :face face - :v-adjust -0.05 - :height 1.25) - (propertize (concat " " (abbreviate-file-name default-directory)) - 'face face)))) + (let ((face (if (doom-modeline--active) 'doom-modeline-buffer-path))) + (concat (if (display-graphic-p) " ") + (doom-modeline-maybe-icon-octicon + "file-directory" + :face face + :v-adjust -0.05 + :height 1.25) + (propertize (concat " " (abbreviate-file-name default-directory)) + 'face face)))) ;; (doom-modeline-def-segment buffer-info - "Combined information about the current buffer, including the current working + "Combined information about the current buffer, including the current working directory, the file name, and its state (modified, read-only or non-existent)." - (concat (cond (buffer-read-only - (concat (doom-modeline-maybe-icon-octicon - "lock" - :face 'doom-modeline-warning - :v-adjust -0.05) - " ")) - ((buffer-modified-p) - (concat (doom-modeline-maybe-icon-faicon - "floppy-o" - :face 'doom-modeline-buffer-modified - :v-adjust -0.0575) - " ")) - ((and buffer-file-name - (not (file-exists-p buffer-file-name))) - (concat (doom-modeline-maybe-icon-octicon - "circle-slash" - :face 'doom-modeline-urgent - :v-adjust -0.05) - " ")) - ((buffer-narrowed-p) - (concat (doom-modeline-maybe-icon-octicon - "fold" - :face 'doom-modeline-warning - :v-adjust -0.05) - " "))) - (if buffer-file-name - (doom-modeline-buffer-file-name) - "%b"))) + (concat (cond (buffer-read-only + (concat (doom-modeline-maybe-icon-octicon + "lock" + :face 'doom-modeline-warning + :v-adjust -0.05) + " ")) + ((buffer-modified-p) + (concat (doom-modeline-maybe-icon-faicon + "floppy-o" + :face 'doom-modeline-buffer-modified + :v-adjust -0.0575) + " ")) + ((and buffer-file-name + (not (file-exists-p buffer-file-name))) + (concat (doom-modeline-maybe-icon-octicon + "circle-slash" + :face 'doom-modeline-urgent + :v-adjust -0.05) + " ")) + ((buffer-narrowed-p) + (concat (doom-modeline-maybe-icon-octicon + "fold" + :face 'doom-modeline-warning + :v-adjust -0.05) + " "))) + (if buffer-file-name + (doom-modeline-buffer-file-name) + "%b"))) (doom-modeline-def-segment buffer-info-simple "Display only the current buffer's name, but with fontification."