summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/fossil-ui.el11
-rw-r--r--lisp/my-mode-line.el36
2 files changed, 44 insertions, 3 deletions
diff --git a/lisp/fossil-ui.el b/lisp/fossil-ui.el
index 0982e4b..0305d3a 100644
--- a/lisp/fossil-ui.el
+++ b/lisp/fossil-ui.el
@@ -339,10 +339,14 @@ Paths may contain spaces. A dash in either count denotes binary data."
:busy nil
:error nil)))
+(defun fossil-ui--single-line (value)
+ "Return VALUE as a string without native-widget line breaks."
+ (replace-regexp-in-string "[\r\n]+" " " (format "%s" (or value ""))))
+
(defun fossil-ui--fit (value width &optional face)
"Return VALUE truncated or padded to WIDTH, optionally using FACE."
(let* ((width (max 0 width))
- (value (truncate-string-to-width (format "%s" (or value ""))
+ (value (truncate-string-to-width (fossil-ui--single-line value)
width nil nil "..."))
(result (concat value
(make-string (max 0 (- width (string-width value))) ?\s))))
@@ -350,8 +354,9 @@ Paths may contain spaces. A dash in either count denotes binary data."
(defun fossil-ui--item (value &optional face)
"Return a TextUI item for VALUE with optional FACE."
- `(:type item :format "%v"
- :value ,(if face (propertize value 'face face) value)))
+ (let ((value (fossil-ui--single-line value)))
+ `(:type item :format "%v"
+ :value ,(if face (propertize value 'face face) value))))
(defun fossil-ui--icons-p ()
"Return non-nil when dashboard Nerd Font icons should be used."
diff --git a/lisp/my-mode-line.el b/lisp/my-mode-line.el
index 11eb88b..f7cc66a 100644
--- a/lisp/my-mode-line.el
+++ b/lisp/my-mode-line.el
@@ -34,6 +34,10 @@
'((t (:inherit font-lock-builtin-face :weight bold)))
"Face for the IRC activity indicator.")
+(defface my/mode-line-clatter-face
+ '((t (:inherit font-lock-builtin-face :weight bold)))
+ "Face for the Clatter joined-channel indicator.")
+
(defface my/mode-line-mu4e-face
'((t (:inherit warning :weight bold)))
"Face for the unread mail indicator.")
@@ -56,6 +60,9 @@
(defvar-local my/mode-line--buffer-title nil)
+(defconst my/mode-line--missing (make-symbol "missing")
+ "Sentinel used when checking membership in package hash tables.")
+
(defun my/mode-line--update-title-cache ()
"Update the cached #+title for the current buffer."
(setq-local my/mode-line--buffer-title
@@ -153,6 +160,34 @@ of a literal dash."
(length erc-modified-channels-alist))
'face 'my/mode-line-irc-face))))
+(defun my/mode-line-clatter ()
+ "Clatter indicator showing the number of joined channels."
+ (when (featurep 'clatter)
+ (let ((count 0))
+ (dolist (buffer (clatter-all-buffers))
+ (when (with-current-buffer buffer
+ (and (eq clatter--buffer-type 'channel)
+ (hash-table-p clatter--nick-list)
+ (when-let* ((connection
+ (clatter-get-connection clatter--network))
+ ((eq (clatter-connection-state connection)
+ :connected))
+ (nick (clatter-connection-nick connection)))
+ (not (eq (gethash (downcase nick) clatter--nick-list
+ my/mode-line--missing)
+ my/mode-line--missing)))))
+ (setq count (1+ count))))
+ (when (> count 0)
+ (let ((icon (my/mode-line--icon "nf-md-forum_outline"
+ 'my/mode-line-clatter-face "irc")))
+ (propertize (format "%s %d" icon count)
+ 'face 'my/mode-line-clatter-face))))))
+
+(defun my/mode-line-mu4e-formatter (mail-count)
+ "Format MAIL-COUNT for the custom mode line without an extra icon."
+ (unless (zerop mail-count)
+ (number-to-string mail-count)))
+
(defun my/mode-line-mu4e ()
"Unread mail indicator from mu4e-alert, or nil when mu4e is not in use."
(when (bound-and-true-p mu4e-alert-mode-line)
@@ -215,6 +250,7 @@ the bottom mode-line is hidden."
'local-map mode-line-buffer-identification-keymap)) " "
mode-line-position)
'("" (:eval (my/mode-line-irc)) " "
+ (:eval (my/mode-line-clatter)) " "
(:eval (my/mode-line-mu4e)) " "
mode-line-process " "
(:eval (my/mode-line-time)) " "