elfeed
elfeed copied to clipboard
[FEATURE] Completion for filter parameters w/ Helm/IDO integration
When running elfeed-search-set-filter
and elfeed-search-live-filter
, it'd be useful to be able to, as an example:
- Enter a
+
to signify a tag parameter and some starting letters; - Press TAB;
- Have the tag parameter be auto-completed, similar to completion elsewhere in Emacs.
Completion could draw from, in the tags' case, the pool of all currently defined and set feed tags.
This pattern could also potentially be used for the rest of the filters as well, such as time and/or feed name.
Similarly, integration with Helm/IDO would be a great next step.
I really like the idea for tab completion on tags. I need to think about how to make sure it's comfortably fast. It might be worth storing pre-computed in the database.
How do you see the filter being integrated with Helm/ido? When you're selecting from a set of items (like from the set of all the current tags, or from existing files) that makes sense, but how does that fit when it's free form? I currently use ido but not Helm for the rest of Emacs.
Unless I'm mistaken, Helm has the ability to interface with tab completion to provide a list of completion candidates, which you can then select from with C-n and C-p and then select the desired one with Enter. This is the kind of functionality that I envisioned.
Had a stab at this, and am making decent progress. The Helm completion works like this:
- Run
elfeed-search-set-filter
orelfeed-search-live-filter
- Enter a
+
or-
to signify a tag parameter - Helm window pops up, allowing one to select one or more tags
- Press
RET
in the Helm window - Selected tags are applied with the correct prefix
This allows you to do something like: press s
, type +
, select the emacs
and news
tags, and end up with +emacs +news
, then follow up with -
, select planet
and the final result is +emacs +news -planet
.
Okay, the previous experiment failed miserably in the end, so I'm trying something else:
- Run
elfeed-search-live-filter-helm-include-tags
- Displays a list of tags to include in the search
- Select tags you want
- Hit
RET
- Filter is updated: all previously included tags are removed, and are replaced by the new selection.
Same thing for elfeed-search-live-filter-helm-exclude-tags
.
With these, one could have 's s' bound to elfeed-search-live-filter
, s +
to elfeed-search-live-filter-helm-include-tags
, and s -
to elfeed-search-live-filter-helm-exclude-tags
.
Mind you, the helm experiment is kind of meh. Feels cumbersome to use, tab completion would be far superior, or the ability to select both +/- filters from a single Helm buffer.
I did two other experiments before:
One where I had a Helm buffer with all tags with both + and - prefix, and one could select any combination, which then would replace the current filter.
Another where I had both + and - filters, without the prefixes, but categorized in two sources. This looked much better, but you could only select from one source, which rendered it useless.
Nevertheless, here's some code to do helm-y stuff:
(defvar elfeed-helm-source-tags
(helm-build-sync-source "Elfeed tags"
:candidates #'elfeed-db-get-all-tags
:fuzzy-match t))
(defun elfeed-helm-tag ()
(interactive)
(let ((dummy (helm :sources '(elfeed-helm-source-tags)
:volatile t)))
(mapconcat #'identity (helm-marked-candidates) " ")))
Calling (elfeed-helm-tag)
will pop up a helm buffer where you can select tags, and the function will return the selections themselves. It may be possible to trigger this from the minibuffer, when TAB
is pressed, but I do not know how, so I'll leave that to someone else to figure out. :)
Here is my ivy one:
(defun elfeed-ivy-filter ()
(interactive)
(let ((filtered-tag (ivy-completing-read "Choose Tags: " (elfeed-db-get-all-tags))))
(progn
(setq elfeed-search-filter (concat elfeed-search-filter " +" filtered-tag))
(elfeed-search-update--force)))
)
Kindly add support for Icomplete
as well, while we are at it.