mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
irc: add new segment to display the unread buffers
This includes a configuration variable that allows the user to customize the display of the name. The segment is only displayed in the 'special modeline due to space. Later, we'll add a irc notification for the 'main modeline.
This commit is contained in:
parent
3d7e46038b
commit
b6b6691ea3
3 changed files with 46 additions and 1 deletions
|
@ -122,6 +122,11 @@ The icons may not be showed correctly in terminal and on Windows.")
|
|||
(defvar doom-modeline-mu4e t
|
||||
"Whether display mu4e notifications or not. Requires `mu4e-alert' package.")
|
||||
|
||||
(defvar doom-modeline-irc t
|
||||
"Whether display irc notifications or not. Requires `circe' package.")
|
||||
|
||||
(defvar doom-modeline-irc-stylize 'identity
|
||||
"Function to stylize the irc buffer names.")
|
||||
|
||||
;;
|
||||
;; Custom faces
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
(defvar winum-auto-setup-mode-line)
|
||||
(defvar xah-fly-insert-state-q)
|
||||
(defvar mu4e-alert-mode-line)
|
||||
(defvar tracking-buffers)
|
||||
|
||||
(declare-function anzu--reset-status 'anzu)
|
||||
(declare-function anzu--where-is-here 'anzu)
|
||||
|
@ -130,6 +131,7 @@
|
|||
(declare-function winum--clear-mode-line 'winum)
|
||||
(declare-function winum--install-mode-line 'winum)
|
||||
(declare-function winum-get-number-string 'winum)
|
||||
(declare-function tracking-shorten 'tracking)
|
||||
|
||||
|
||||
;;
|
||||
|
@ -1519,6 +1521,44 @@ mouse-1: Toggle Debug on Quit"
|
|||
"You have an unread email"
|
||||
(format "You have %s unread emails" mu4e-alert-mode-line)))))
|
||||
|
||||
|
||||
;;
|
||||
;; irc notifications
|
||||
;;
|
||||
|
||||
(defun doom-modeline--shorten-irc (name)
|
||||
"Wrapper for `tracking-shorten' that only takes one NAME.
|
||||
|
||||
One key difference is that when `tracking-shorten' returns nil we
|
||||
will instead return the original value of name. This is necessary
|
||||
in cases where the user has stylized the name to be an icon and
|
||||
we don't want to remove that so we just return the original."
|
||||
(or (car (tracking-shorten (list name)))
|
||||
name))
|
||||
|
||||
(defun doom-modeline--tracking-buffers (buffers)
|
||||
"Logic to convert some irc BUFFERS to their font-awesome icon."
|
||||
(mapconcat
|
||||
(lambda (b)
|
||||
(propertize
|
||||
(doom-modeline--shorten-irc (funcall doom-modeline-irc-stylize b))
|
||||
'face '(:inherit (warning doom-modeline-unread-number))
|
||||
'help-echo b))
|
||||
buffers
|
||||
;; `space-width' only affects the width of the spaces here, so we can tighten
|
||||
;; it to be a bit more compact
|
||||
(propertize " · " 'display '(space-width 0.4))))
|
||||
|
||||
;; create a modeline segment that contains all the irc tracked buffers
|
||||
(doom-modeline-def-segment irc-buffers
|
||||
"The list of shortened, unread irc buffers."
|
||||
(when (and doom-modeline-irc
|
||||
(boundp 'tracking-mode-line-buffers)
|
||||
(doom-modeline--active)
|
||||
(derived-mode-p 'circe-mode))
|
||||
;; add a space at the end to pad against the following segment
|
||||
(concat " " (doom-modeline--tracking-buffers tracking-buffers) " ")))
|
||||
|
||||
(provide 'doom-modeline-segments)
|
||||
|
||||
;;; doom-modeline-segments.el ends here
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
|
||||
(doom-modeline-def-modeline 'special
|
||||
'(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info)
|
||||
'(misc-info lsp debug minor-modes input-method buffer-encoding major-mode process checker))
|
||||
'(misc-info lsp debug minor-modes input-method irc-buffers buffer-encoding major-mode process checker))
|
||||
|
||||
(doom-modeline-def-modeline 'project
|
||||
'(bar " " buffer-default-directory)
|
||||
|
|
Loading…
Reference in a new issue