new-ryuslash.org/posts/20231107-til-i-can-use-elfeed-search-face-alist.org

46 lines
2.3 KiB
Org Mode
Raw Permalink Normal View History

2023-12-08 08:39:59 +01:00
#+title: TIL: I can use elfeed-search-face-alist to highlight certain headlines in Elfeed
#+tags: emacs, elfeed, til
#+comments: on
#+status: publish
#+DATE: Thu, 07 Dec 2023 22:45:51 GMT
#+UPDATE_URL: /admin/modify-post/2023%252f12%252f07%252ftil-i-can-use-elfeed-search-face-alist-to-highlight-certain-headlines-in-elfeed
I rediscovered that I can use =elfeed-search-face-alist= to customize how headlines are displayed in Elfeed. I had read it before [[https://nullprogram.com/blog/2015/12/03/#custom-entry-colors][on Chris Wellons' blog]], but I didn't have a use for it then.
With =elfeed-search-face-alist= I can define a face to be used for an article with a specific tag. I added the [[https://blabbermouth.net/][Blabbermouth]] RSS feed to my feeds.
#+begin_src emacs-lisp
(setq elfeed-feeds '(("https://blabbermouth.net/feed" music)))
#+end_src
And created 2 taggers. One tags reviews, because those always have =/reviews/= in the url. The other has a list of bands that I'm especially interested in.
#+begin_src emacs-lisp
(defvar oni-elfeed-blabbermouth-review-tagger
(elfeed-make-tagger :feed-url (rx "blabbermouth.net")
:entry-link (rx "/reviews/")
:add 'review)
"Tagger that marks any reviews from Blabbermouth.")
(defvar oni-elfeed-blabbermouth-favourite-tagger
(elfeed-make-tagger :feed-url (rx "blabbermouth.net")
:entry-title (rx (or "SLIPKNOT"
(seq "DREAM" whitespace "THEATER")
;; And so on...
))
:add 'favourite)
"Tagger that highlights specific bands from Blabbermouth.")
(add-hook 'elfeed-new-entry-hook oni-elfeed-blabbermouth-favourite-tagger)
(add-hook 'elfeed-new-entry-hook oni-elfeed-blabbermouth-review-tagger)
#+end_src
And then I can just set up the feeds:
#+begin_src emacs-lisp
(add-to-list 'elfeed-search-face-alist '(review :slant italic) t)
(add-to-list 'elfeed-search-face-alist '(favourite :foreground "#f17272") t)
#+end_src
As long as the face definitions don't conflict a headline's face would be the combination of all that apply. For example, by default unread headlines are bold, so unread favourite messages would be bold and somewhat reddish.