Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow customizing faces for queries and non-highlighted channels #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions circe.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ See the {topic-diff} parameter to `circe-format-server-topic'."
See `circe-fool-list'."
:group 'circe)

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

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

;;;;;;;;;;;;;;;;;;;
;;;; Variables ;;;;
;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -1556,6 +1567,19 @@ PATTERNS should be the list of regular expressions."
(throw 'return t)))
nil)))

(defun circe-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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems redundant to specify buffer when buffer is current. Especially if the tracking-get-face call exploits that fact.

((eq major-mode 'circe-channel-mode)
'circe-tracking-channel-face)
((eq major-mode 'circe-query-mode)
'circe-tracking-query-face)
(t (tracking-get-face buffer)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Nick Highlighting ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
15 changes: 14 additions & 1 deletion tracking.el
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ If set to nil, all buffers will be shown."
(integer :tag "Maximum"))
:group 'tracking)

(defcustom tracking-get-face-function #'tracking-get-face
"Function that returns face for a given buffer. It defaults to
`tracking-get-face' which simply returns any face that is stored in
`tracking-buffers'. Circe users may set this variable to
`circe-tracking-get-face' instead."
:type 'function
:group 'tracking)

;;; Internal variables
(defvar tracking-buffers nil
"The list of currently tracked buffers.")
Expand Down Expand Up @@ -361,7 +369,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 ,(funcall tracking-get-face-function (car buffer-names))
keymap ,(let ((map (make-sparse-keymap)))
(define-key map [mode-line down-mouse-1]
`(lambda ()
Expand Down Expand Up @@ -447,5 +455,10 @@ 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. Otherwise, return `nil'."
(get-text-property 0 'face buffer))

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