Skip to content

Commit

Permalink
tracking: allow customizing faces for queries and non-highlighted cha…
Browse files Browse the repository at this point in the history
…nnels

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 `tracking-channel-face` and `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.

    (set-face-attribute 'tracking-channel-face nil :foreground my/white)
    (set-face-attribute 'tracking-query-face nil :foreground my/blue)
  • Loading branch information
FrostyX committed Jan 12, 2021
1 parent 265f36c commit 6d07fda
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tracking.el
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ If set to nil, all buffers will be shown."
(integer :tag "Maximum"))
:group 'tracking)

(defface tracking-channel-face
nil
"The face used by circe-tracking to show channels with activity in modeline."
:group 'circe)

(defface tracking-query-face
nil
"The face used by circe-tracking to show query buffers with activity in
modeline."
:group 'circe)

;;; Internal variables
(defvar tracking-buffers nil
"The list of currently tracked buffers.")
Expand Down Expand Up @@ -361,7 +372,7 @@ only return that many entries, ending with '+n'."
(while buffer-names
(push `(:propertize
,(car shortened-names)
face ,(get-text-property 0 'face (car buffer-names))
face ,(tracking-get-face (car buffer-names))
keymap ,(let ((map (make-sparse-keymap)))
(define-key map [mode-line down-mouse-1]
`(lambda ()
Expand Down Expand Up @@ -446,5 +457,19 @@ This returns STRING with the new face."
(propertize string 'face candidate))))
string)))

(defun tracking-get-face (buffer)
"Return face for a given buffer. If the buffer has already some face
specified, use it. This covers channels where our name was mentioned. Otherwise
decide whether the buffer is for a channel, query or else and use a face based
on this"
(with-current-buffer buffer
(cond ((get-text-property 0 'face buffer)
(get-text-property 0 'face buffer))
((eq major-mode 'circe-channel-mode)
'tracking-channel-face)
((eq major-mode 'circe-query-mode)
'tracking-query-face)
(t nil))))

(provide 'tracking)
;;; tracking.el ends here

0 comments on commit 6d07fda

Please # to comment.