diff options
author | jao <jao@gnu.org> | 2021-01-12 20:39:13 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2021-01-12 20:39:13 +0000 |
commit | 25d8e0cae97087f881bb7f34080fa017a684a3ca (patch) | |
tree | ec54ffb9f31e6b0bf4269a3f0b1686c9dcee4172 /media | |
parent | 94d3f7e016f5ddcbc053e9258f55c3eb939c6926 (diff) | |
download | elibs-25d8e0cae97087f881bb7f34080fa017a684a3ca.tar.gz elibs-25d8e0cae97087f881bb7f34080fa017a684a3ca.tar.bz2 |
espotify: minad's suggestions
Diffstat (limited to 'media')
-rw-r--r-- | media/espotify.org | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/media/espotify.org b/media/espotify.org index 223d202..5618ab6 100644 --- a/media/espotify.org +++ b/media/espotify.org @@ -275,6 +275,7 @@ Let's start with an umbrella customization group: (defun espotify--search-generator (type filter) (thread-first (consult--async-sink) (consult--async-refresh-timer) + (consult-async--map #'espotify--format-item) (espotify--async-search type filter) (consult--async-throttle) (consult--async-split))) @@ -289,27 +290,24 @@ Let's start with an umbrella customization group: #+begin_src emacs-lisp (defun espotify--async-search (next type filter) - (let (candidates) - (lambda (action) - (pcase action - ((or 'setup 'refresh) (funcall next action)) - ('destroy (setq candidates nil) (funcall next 'destroy)) - ((pred stringp) - (espotify-search-all - (lambda (x) - (setq candidates (mapcar 'espotify--format-item x)) - (funcall next candidates)) - action ;; when we receive a string as the action, - ;; it's the user input - type - filter)) - ('get candidates) - (_ (funcall next action)))))) + (lambda (action) + (pcase action + ((pred stringp) + (espotify-search-all + (lambda (x) + (funcall next 'flush) + (funcall next x)) + action ;; when we receive a string as the action, + ;; it's the user input + type + filter)) + (_ (funcall next action))))) #+end_src When processing the results, we format them as a displayable string, while hiding in a property the URI that will allow us to - play the item: + play the item (and pass the formatter to ~consult-async--map~, in + ~espotify--search-generator~ above): #+begin_src emacs-lisp (defun espotify--format-item (x) |