skeeto / elfeed

An Emacs web feeds client
The Unlicense
1.51k stars 118 forks source link

(elfeed-deref (elfeed-entry-tags entry)) doesn't work #496

Closed danielkrajnik closed 1 year ago

danielkrajnik commented 1 year ago

I've been trying for the past three days to get elfeed to display desktop notifications. It was suggested that 'elfeed-new-entry-hook can be used and it works, but parsing is a huge trial and error.

I added "https://lorem-rss.herokuapp.com/feed?unit=second&interval=10" feed to be able to test it.

This works for example:

(add-hook 'elfeed-new-entry-hook
          (lambda (entry)
            (alert (elfeed-deref (elfeed-entry-content entry))
                   :title (concat
                           (elfeed-deref (elfeed-entry-title entry)) " -_ "
                           (elfeed-deref (elfeed-entry-title entry))
                           )
                   :severity 'high
                   )))

But changing elfeed-entry-title to elfeed-entry-tags or elfeed-entry-feed` makes it fail (no notifications appear anymore).

Does anyone have any idea why?

danielkrajnik commented 1 year ago

Solved it:

(defun elfeed-desktop-notifications (entry)
  "Parse and display new feeds as desktop notifications."
  (alert (elfeed-deref (elfeed-entry-content entry))
         :title (concat
                 (elfeed-feed-title (elfeed-deref (elfeed-entry-feed entry))) "\n"
                 (elfeed-deref (elfeed-entry-title entry))
                 )
         :severity 'high
         ))

(add-hook 'elfeed-new-entry-hook #'elfeed-desktop-notifications)
danielkrajnik commented 1 year ago

On a general note, I wish elisp had some typing system? I get that there are conventions, but developers may not always stick to them (elfeed as shown above did though) and if you are new it might have been easier?

On a tangential note, I wish desktop notifications had a "subtitle".

On a philosophical note, I haven't seen an emacs pacakage yet that had desktop notifications integrated out-of-the-box? I really wonder why? They are useful, no?

sp1ff commented 1 year ago

danielkrajnik @.***> writes:

On a general note, I wish elisp had some typing system? I get that there are conventions, but as you mentioned developers may not always stick to them (elfeed as shown above did though) and if you are new it might have been easier?

But it does? See here: https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Lisp-Data-Types

On a tangential note, I wish desktop notifications had a "subtitle".

On a philosophical note, I haven't seen an emacs pacakage yet that had desktop notifications integrated out-of-the-box? I really wonder why? They are useful, no?

Support for Freedesktop notifications is built-in

https://www.gnu.org/software/emacs/manual/html_node/elisp/Desktop-Notifications.html

and John Wiegly has a package (of course) that I believe is cross-platform:

https://github.com/jwiegley/alert

-- Michael @.***>

danielkrajnik commented 1 year ago

and John Wiegly has a package (of course) that I believe is cross-platform: https://github.com/jwiegley/alert

@sp1ff That's the exact package also used in this example, but AFAIK it doesn't have a "subtitle" property (please see the image below, the second paragraph is just part of the :title property): image