Skip to content

Commit a02e49e

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 265f36c commit a02e49e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

circe.el

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

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

1503+
(defun circe-tracking-get-face (buffer)
1504+
"Return face for a given buffer. If the buffer has already some face
1505+
specified, use it. This covers channels where our name was mentioned. Otherwise
1506+
decide whether the buffer is for a channel, query or else and use a face based
1507+
on this."
1508+
(with-current-buffer buffer
1509+
(cond ((get-text-property 0 'face buffer))
1510+
((eq major-mode 'circe-channel-mode)
1511+
'circe-tracking-channel-face)
1512+
((eq major-mode 'circe-query-mode)
1513+
'circe-tracking-query-face)
1514+
(tracking-get-face nil))))
1515+
14921516
;;;;;;;;;;;;;;;;;;;;;;;;;;;
14931517
;;;; Nick Highlighting ;;;;
14941518
;;;;;;;;;;;;;;;;;;;;;;;;;;;

tracking.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ 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"
152+
:type 'function
153+
:group 'tracking)
154+
150155
;;; Internal variables
151156
(defvar tracking-buffers nil
152157
"The list of currently tracked buffers.")
@@ -361,7 +366,7 @@ only return that many entries, ending with '+n'."
361366
(while buffer-names
362367
(push `(:propertize
363368
,(car shortened-names)
364-
face ,(get-text-property 0 'face (car buffer-names))
369+
face ,(funcall tracking-get-face-function (car buffer-names))
365370
keymap ,(let ((map (make-sparse-keymap)))
366371
(define-key map [mode-line down-mouse-1]
367372
`(lambda ()
@@ -446,5 +451,10 @@ This returns STRING with the new face."
446451
(propertize string 'face candidate))))
447452
string)))
448453

454+
(defun tracking-get-face (buffer)
455+
"Return face for a given buffer. If the buffer has already some face
456+
specified, use it. Otherwise, return `nil'."
457+
(get-text-property 0 'face buffer))
458+
449459
(provide 'tracking)
450460
;;; tracking.el ends here

0 commit comments

Comments
 (0)