Skip to content

Commit 97f30ff

Browse files
committed
Allow customizing faces for queries and non-highlighted channels
At this point, we have a possibility to customize the color of a channel (in the tracking segment of a modeline) where somebody mentioned our name. We use the same face as for printing our name in the message itself (`circe-highlight-nick-face`). This is IMHO not sufficient because new personal messages are as important as mentions in a channel and they can be easily missed when shown in the default (for me gray) color. I am adding a support for this. While I am at it, I am adding a possibility to customize a color of a channel, that doesn't mention our name but has some new activity in it. I understand that `tracking-add-buffer` allows adding buffers to `tracking-buffers` with face and we may utilize this feature. I believe it makes sense for what whatever it is currently used but I would prefer to have a possibility to apply faces when rendering (in opposite to assigning a face when some activity happens), hence `tracking-get-face`. By default, I am setting the `circe-tracking-channel-face` and `circe-tracking-query-face` to `nil` and therefore they are not going to be customized and a backward-compatibility is going to be kept for everybody who doesn't care about this feature. Personally, I am putting the following lines to my config. (setq tracking-get-face-function #'circe-tracking-get-face) (set-face-attribute 'circe-tracking-channel-face nil :foreground my/white) (set-face-attribute 'circe-tracking-query-face nil :foreground my/blue)
1 parent 57fe189 commit 97f30ff

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

circe.el

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ See the {topic-diff} parameter to `circe-format-server-topic'."
110110
See `circe-fool-list'."
111111
:group 'circe)
112112

113+
(defface circe-tracking-channel-face
114+
nil
115+
"The face used by circe-tracking to show channels with activity in modeline."
116+
:group 'circe)
117+
118+
(defface circe-tracking-query-face
119+
nil
120+
"The face used by circe-tracking to show query buffers with activity in
121+
modeline."
122+
:group 'circe)
123+
113124
;;;;;;;;;;;;;;;;;;;
114125
;;;; Variables ;;;;
115126
;;;;;;;;;;;;;;;;;;;
@@ -1543,6 +1554,19 @@ PATTERNS should be the list of regular expressions."
15431554
(throw 'return t)))
15441555
nil)))
15451556

1557+
(defun circe-tracking-get-face (buffer)
1558+
"Return face for a given buffer. If the buffer has already some face
1559+
specified, use it. This covers channels where our name was mentioned. Otherwise
1560+
decide whether the buffer is for a channel, query or else and use a face based
1561+
on this."
1562+
(with-current-buffer buffer
1563+
(cond ((get-text-property 0 'face buffer))
1564+
((eq major-mode 'circe-channel-mode)
1565+
'circe-tracking-channel-face)
1566+
((eq major-mode 'circe-query-mode)
1567+
'circe-tracking-query-face)
1568+
(t (tracking-get-face buffer)))))
1569+
15461570
;;;;;;;;;;;;;;;;;;;;;;;;;;;
15471571
;;;; Nick Highlighting ;;;;
15481572
;;;;;;;;;;;;;;;;;;;;;;;;;;;

tracking.el

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ If set to nil, all buffers will be shown."
147147
(integer :tag "Maximum"))
148148
:group 'tracking)
149149

150+
(defcustom tracking-get-face-function #'tracking-get-face
151+
"Function that returns face for a given buffer. It defaults to
152+
`tracking-get-face' which simply returns any face that is stored in
153+
`tracking-buffers'. Circe users may set this variable to
154+
`circe-tracking-get-face' instead."
155+
:type 'function
156+
:group 'tracking)
157+
150158
;;; Internal variables
151159
(defvar tracking-buffers nil
152160
"The list of currently tracked buffers.")
@@ -361,7 +369,7 @@ only return that many entries, ending with '+n'."
361369
(while buffer-names
362370
(push `(:propertize
363371
,(car shortened-names)
364-
face ,(get-text-property 0 'face (car buffer-names))
372+
face ,(funcall tracking-get-face-function (car buffer-names))
365373
keymap ,(let ((map (make-sparse-keymap)))
366374
(define-key map [mode-line down-mouse-1]
367375
`(lambda ()
@@ -447,5 +455,10 @@ This returns STRING with the new face."
447455
(propertize string 'face candidate))))
448456
string)))
449457

458+
(defun tracking-get-face (buffer)
459+
"Return face for a given buffer. If the buffer has already some face
460+
specified, use it. Otherwise, return `nil'."
461+
(get-text-property 0 'face buffer))
462+
450463
(provide 'tracking)
451464
;;; tracking.el ends here

0 commit comments

Comments
 (0)