Open Ambrevar opened 6 years ago
mpv defun: highly appreciated!
I like the idea of this in principle, but for truncated articles, I don't see the difference between "Visit with external function if link entry matches 'elfeed-visit-patterns'", and "visit otherwise" in your proposal. The behavior of this function either opens in eww with readability mode or opens in eww (or your browser of choice), without readability mode. Wouldn't it make more sense to open in eww with readability or to show the feed?
Yes, I think it would but it's been a long time since I wrote this quick & dirty snippet. Let me have a second look and fix it (it was quite badly written).
Now I remember: I originally took a conservative approach and I did not
want to replace elfeed-search-show-entry
(RET
by default). I
bound my proposal to S-RET
in my init.el
.
In the search view:
RET
to show the entry. (Original elfeed behaviour.)S-RET
to open in eww readable mode if matching a pattern.S-RET
to open with browse-url if not matching a pattern.In the show view (same thing):
S-RET
to open in eww readable mode if matching a pattern.S-RET
to open with browse-url if not matching a pattern.I don't think it's the right approach though: we should try to
minimize the effort on the user end so that they don't have to remember
whether they should press RET
or S-RET
.
So here is an update to my proposal, in the line of what @benjaminwd suggested:
In the search view:
RET
to open in eww readable if matching a pattern.RET
to show the entry if not matching a pattern.S-RET
to force-show the entry. This is useful if the entry matches
a pattern but we still want to see the elfeed "show" buffer.In the show view:
S-RET
to open with browse-url.What do you think?
Updated function:
(defun elfeed-visit-maybe-externally ()
"Visit with external function if entry link matches `elfeed-visit-patterns',
show normally otherwise."
(interactive)
(let ((entry (if (eq major-mode 'elfeed-show-mode)
elfeed-show-entry
(elfeed-search-selected :single)))
(patterns elfeed-visit-patterns))
(while (and patterns (not (string-match (caar patterns) (elfeed-entry-link entry))))
(setq patterns (cdr patterns)))
(cond
(patterns
(funcall (cdar patterns)))
((eq major-mode 'elfeed-search-mode)
(elfeed-search-show-entry))
(t (elfeed-show-visit)))))
Note that if the above function is called from the "show" buffer, it will either use eww-readable if matching or browse-url otherwise.
Leaving S-RET
to elfeed-show-visit
enables us to open matched entries with browse-url
.
I did try switching to elfeed-search-show-entry
as you show, but that is not getting the correct arguments. I don't know elfeed well yet, so I hesitate to speculate, but I suspect elfeed-search-show-entry is looking for something other than the link url.
Sorry, elfeed-search-show-entry
must be called intereactively. Fixed code:
(defun elfeed-visit-maybe-externally ()
"Visit with external function if entry link matches `elfeed-visit-patterns',
show normally otherwise."
(interactive)
(let ((entry (if (eq major-mode 'elfeed-show-mode)
elfeed-show-entry
(elfeed-search-selected :single)))
(patterns elfeed-visit-patterns))
(while (and patterns (not (string-match (caar patterns) (elfeed-entry-link entry))))
(setq patterns (cdr patterns)))
(cond
(patterns
(funcall (cdar patterns)))
((eq major-mode 'elfeed-search-mode)
(call-interactively 'elfeed-search-show-entry))
(t (elfeed-show-visit)))))
@skeeto: Ping?
Many feeds cannot be visited within elfeed. Two of the most common examples:
Possible solutions:
mpv
(ifyoutube-dl
is installed).eww
and calleww-readable
right after load. In many cases this effectively loads the whole article.Implementation suggestion:
elfeed-visit-maybe-externally
can then be used in lieu ofelfeed-search-show-entry
.A more streamlined way to do this would be to assign a "visit function" to each feed in
elfeed-feeds
. Then elfeed could provideelfeed-play-with-mpv
andelfeed-open-with-eww
as example functions.What do you think?