skeeto / elfeed

An Emacs web feeds client
The Unlicense
1.49k stars 116 forks source link

[FEATURE] Completion for filter parameters w/ Helm/IDO integration #82

Open jinnovation opened 9 years ago

jinnovation commented 9 years ago

When running elfeed-search-set-filter and elfeed-search-live-filter, it'd be useful to be able to, as an example:

  1. Enter a + to signify a tag parameter and some starting letters;
  2. Press TAB;
  3. 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.

skeeto commented 9 years ago

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.

jinnovation commented 9 years ago

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.

algernon commented 8 years ago

Had a stab at this, and am making decent progress. The Helm completion works like this:

  1. Run elfeed-search-set-filter or elfeed-search-live-filter
  2. Enter a + or - to signify a tag parameter
  3. Helm window pops up, allowing one to select one or more tags
  4. Press RET in the Helm window
  5. 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.

algernon commented 8 years ago

Okay, the previous experiment failed miserably in the end, so I'm trying something else:

  1. Run elfeed-search-live-filter-helm-include-tags
  2. Displays a list of tags to include in the search
  3. Select tags you want
  4. Hit RET
  5. 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.

algernon commented 8 years ago

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. :)

Jesse-Millwood commented 5 years ago

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)))
  )
codingquark commented 3 years ago

Kindly add support for Icomplete as well, while we are at it.

aadi58002 commented 1 week ago

any example for completion in vertico ?