From c118f22184dbf6370b37d76dd0b8de243686b1bb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 13 May 2017 11:40:01 +0200 Subject: [PATCH] ui/doom-modeline: refactor eldoc segment --- TODO.org | 4 ++-- modules/ui/doom-modeline/config.el | 37 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/TODO.org b/TODO.org index 51b9fd58f..5c10091f5 100644 --- a/TODO.org +++ b/TODO.org @@ -100,9 +100,9 @@ + [ ] tools/upload: add ~+upload/open-remote-file~ command to open current file on the remote (with TRAMP) + [ ] Generalize ~doom-visual-bell~ by basing its background off a face -** 2.0.2 [64/66] +** 2.0.2 [65/66] + [ ] Update screenshots -+ [ ] Fix ~0/0~ displaying in modeline (caused by leftover anzu state) ++ [X] ui/doom-modeline: fix ~0/0~ display in modeline (leftover anzu state) + [X] send-to-REPL workflow: does it still work? (see ~:repl~ & ~+eval/repl-send-region~) + [X] completion/ivy: restore ag searching (for compressed files) Now ~:ag~, ~:rg~, ~:agcwd~ and ~:rgcwd~ diff --git a/modules/ui/doom-modeline/config.el b/modules/ui/doom-modeline/config.el index 960c1b142..82c974d73 100644 --- a/modules/ui/doom-modeline/config.el +++ b/modules/ui/doom-modeline/config.el @@ -40,16 +40,19 @@ anzu-minimum-input-length 1 anzu-search-threshold 250) - (make-variable-buffer-local 'anzu--state) + ;; 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)) + (defun +doom-modeline|reset-anzu () - (setq anzu--state nil)) + (anzu--reset-status)) ;; Ensure anzu state is cleared when searches & iedit are done - (add-hook! '(kill-buffer-hook find-file-hook) #'+doom-modeline|reset-anzu) - (after! evil - (add-hook '+evil-esc-hook #'+doom-modeline|reset-anzu t) - (advice-add #'evil-ex-search-abort :after #'+doom-modeline|reset-anzu) - (after! evil-multiedit - (add-hook 'iedit-mode-end-hook #'+doom-modeline|reset-anzu)))) + (add-hook! :append '(kill-buffer isearch-mode-end +evil-esc-hook) + #'+doom-modeline|reset-anzu) + (after! iedit + (add-hook 'iedit-mode-end-hook #'+doom-modeline|reset-anzu))) ;;; Flash the mode-line on error @@ -456,10 +459,14 @@ lines are selected, or the NxM dimensions of a block selection." (propertize (let ((here anzu--current-position) (total anzu--total-matched)) - (pcase anzu--state - ('replace-query (format " %d replace " total)) - ('replace (format " %d/%d " here total)) - (_ (format " %s/%d%s " here total (if anzu--overflow-p "+" ""))))) + (cond ((eq anzu--state 'replace-query) + (format " %d replace " total)) + ((eq anzu--state 'replace) + (format " %d/%d " here total)) + (anzu--overflow-p + (format " %s+ " total)) + (t + (format " %s/%d " here total)))) 'face (if (active) 'doom-modeline-panel)))) (defsubst +doom-modeline--evil-substitute () @@ -517,9 +524,9 @@ with `evil-ex-substitute', and/or 4. The number of active `iedit' regions." ;; (def-modeline-segment! eldoc - "Used with `eldoc-eval' to show the eldoc string in the modeline, while using -`eval-expression'." - (and (boundp 'str) str)) + "Display eldoc documentation in the mode-line while using the minibuffer (e.g. +`eval-expression')." + (bound-and-true-p str)) ;; These bars regulate the height of the mode-line in GUI Emacs. (def-modeline-segment! bar