Function: doom-modeline-segment--mu4e

doom-modeline-segment--mu4e is a natively compiled function defined in doom-modeline-segments.el.

Signature

(doom-modeline-segment--mu4e)

Documentation

Show notifications of any unread emails in mu4e.

Source Code

;; Defined in /nix/store/1lcicrdd2r4b8rkc91nnn74ymk1jl6yd-emacs-packages-deps/share/emacs/site-lisp/elpa/doom-modeline-20260928.1632/doom-modeline-segments.el
;;
;; `mu4e' notifications
;;

(doom-modeline-def-segment mu4e
  "Show notifications of any unread emails in `mu4e'."
  (when (and doom-modeline-mu4e
             (doom-modeline--segment-visible 'mu4e))
    (when-let* ((sep (doom-modeline-spc))
                (vsep (doom-modeline-vspc))
                (icon (doom-modeline-icon 'mdicon "nf-md-email" "📧" "#"
                                          :face 'doom-modeline-notification))
                (values (cond ((and (bound-and-true-p mu4e-alert-mode-line)
                                    (numberp mu4e-alert-mode-line))
                               `(,mu4e-alert-mode-line ,#'mu4e-alert-view-unread-mails))
                              ((and (bound-and-true-p mu4e-modeline-mode)
                                    (fboundp 'mu4e-bookmark-favorite))
                               `(,(plist-get (mu4e-bookmark-favorite) :unread)
                                 ,(lambda ()
                                    (interactive)
                                    (mu4e-search (plist-get (mu4e-bookmark-favorite) :query)))))))
                (unread-count (nth 0 values))
                (open-fun (nth 1 values)))
      (when (> unread-count 0)
        (concat
         sep
         (propertize
          (concat
           icon
           vsep
           (propertize
            (if (> unread-count doom-modeline-number-limit)
                (format "%d+" doom-modeline-number-limit)
              (number-to-string unread-count))
            'face '(:inherit
                    (doom-modeline-unread-number doom-modeline-notification))))
          'mouse-face 'doom-modeline-highlight
          'keymap `(mode-line keymap
                              (mouse-1 . ,open-fun)
                              (mouse-2 . ,open-fun)
                              (mouse-3 . ,open-fun))
          'help-echo (concat (if (= unread-count 1)
                                 "You have an unread email"
                               (format "You have %s unread emails" unread-count))
                             "\nClick here to view "
                             (if (= unread-count 1) "it" "them")))
         sep)))))