mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Merge pull request #100 from seanfarley/smf/mu4e
mu4e: add new segment that shows unread emails
This commit is contained in:
commit
ec3588a407
3 changed files with 53 additions and 4 deletions
|
@ -119,6 +119,9 @@ The icons may not be showed correctly in terminal and on Windows.")
|
|||
(defvar doom-modeline-version t
|
||||
"Whether display environment version or not.")
|
||||
|
||||
(defvar doom-modeline-mu4e t
|
||||
"Whether display mu4e notifications or not. Requires `mu4e-alert' package.")
|
||||
|
||||
|
||||
;;
|
||||
;; Custom faces
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
(defvar text-scale-mode-amount)
|
||||
(defvar winum-auto-setup-mode-line)
|
||||
(defvar xah-fly-insert-state-q)
|
||||
(defvar mu4e-alert-mode-line)
|
||||
|
||||
(declare-function anzu--reset-status 'anzu)
|
||||
(declare-function anzu--where-is-here 'anzu)
|
||||
|
@ -1493,6 +1494,32 @@ mouse-1: Toggle Debug on Quit"
|
|||
(eval `(pdf-view-current-page))
|
||||
(pdf-cache-number-of-pages))))
|
||||
|
||||
|
||||
;;
|
||||
;; mu4e-alert notifications
|
||||
;;
|
||||
|
||||
(defun doom-modeline-mu4e-formatter (mail-count)
|
||||
"Doom mode-line's `mu4e-alert' formatter.
|
||||
MAIL-COUNT is the count of mails for which the string is to displayed"
|
||||
(when (not (zerop mail-count))
|
||||
(concat
|
||||
(propertize
|
||||
(format "%s" mail-count)
|
||||
'display '(raise 0.09)
|
||||
'face '(:height 0.85)
|
||||
'help-echo (if (= mail-count 1)
|
||||
"You have an unread email"
|
||||
(format "You have %s unread emails" mail-count)))
|
||||
|
||||
;; add a little space for padding
|
||||
(propertize " " 'display '(space-width 0.6)))))
|
||||
|
||||
(doom-modeline-def-segment mu4e
|
||||
(when doom-modeline-mu4e
|
||||
;; this is the result of the mu4e formatter
|
||||
mu4e-alert-mode-line))
|
||||
|
||||
(provide 'doom-modeline-segments)
|
||||
|
||||
;;; doom-modeline-segments.el ends here
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
|
||||
(doom-modeline-def-modeline 'main
|
||||
'(bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info)
|
||||
'(misc-info persp-name lsp github debug minor-modes input-method buffer-encoding major-mode process vcs checker))
|
||||
'(misc-info persp-name lsp mu4e github debug minor-modes input-method buffer-encoding major-mode process vcs checker))
|
||||
|
||||
(doom-modeline-def-modeline 'minimal
|
||||
'(bar matches " " buffer-info)
|
||||
|
@ -95,7 +95,7 @@
|
|||
|
||||
(doom-modeline-def-modeline 'project
|
||||
'(bar " " buffer-default-directory)
|
||||
'(misc-info github debug " " major-mode " "))
|
||||
'(misc-info mu4e github debug " " major-mode " "))
|
||||
|
||||
(doom-modeline-def-modeline 'media
|
||||
'(bar window-number buffer-size buffer-info)
|
||||
|
@ -147,12 +147,23 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
"Set pdf mode-line."
|
||||
(doom-modeline-set-modeline 'pdf))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-modeline--remove-mu4e-alert-string ()
|
||||
"Remove the default `mu4e-alert' string.
|
||||
|
||||
The string will conflict with our custom segment."
|
||||
(setq global-mode-string (delete '(:eval mu4e-alert-mode-line)
|
||||
global-mode-string)))
|
||||
|
||||
|
||||
;;
|
||||
;; Mode
|
||||
;;
|
||||
|
||||
(defvar doom-modeline--default-mode-line mode-line-format)
|
||||
(defvar mu4e-alert-modeline-formatter)
|
||||
(declare-function mu4e-alert-default-mode-line-formatter 'mu4e-alert)
|
||||
(declare-function mu4e-alert-enable-mode-line-display 'mu4e-alert)
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode doom-modeline-mode
|
||||
|
@ -174,7 +185,10 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
(add-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline)
|
||||
(add-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
||||
(add-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
||||
(add-hook 'pdf-tools-enabled-hook #'doom-modeline-set-pdf-modeline))
|
||||
(add-hook 'pdf-tools-enabled-hook #'doom-modeline-set-pdf-modeline)
|
||||
(setq mu4e-alert-modeline-formatter #'doom-modeline-mu4e-formatter)
|
||||
(advice-add #'mu4e-alert-enable-mode-line-display
|
||||
:after #'doom-modeline--remove-mu4e-alert-string))
|
||||
(progn
|
||||
;; Restore mode-line
|
||||
(setq-default mode-line-format doom-modeline--default-mode-line)
|
||||
|
@ -182,7 +196,12 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
(remove-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline)
|
||||
(remove-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
||||
(remove-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
||||
(remove-hook 'pdf-tools-enabled-hook #'doom-modeline-set-pdf-modeline))))
|
||||
(remove-hook 'pdf-tools-enabled-hook #'doom-modeline-set-pdf-modeline)
|
||||
;; no harm in always restoring the defaults
|
||||
(setq mu4e-alert-modeline-formatter
|
||||
#'mu4e-alert-default-mode-line-formatter)
|
||||
(advice-remove #'mu4e-alert-enable-mode-line-display
|
||||
#'doom-modeline--remove-mu4e-alert-string))))
|
||||
|
||||
(provide 'doom-modeline)
|
||||
|
||||
|
|
Loading…
Reference in a new issue