summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--media/espotify.org32
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)