new-ryuslash.org/posts/20231107-til-i-can-use-elfeed-search-face-alist.org
2023-12-07 23:39:59 -08:00

2.3 KiB

TIL: 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 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 Blabbermouth RSS feed to my feeds.

  (setq elfeed-feeds '(("https://blabbermouth.net/feed" music)))

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.

  (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)

And then I can just set up the feeds:

  (add-to-list 'elfeed-search-face-alist '(review :slant italic) t)
  (add-to-list 'elfeed-search-face-alist '(favourite :foreground "#f17272") t)

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.