From 2b44cb9166714d523d781eae439061b02a5b5ee0 Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 20 Jan 2021 00:25:00 +0000 Subject: espotify: little cleanups --- media/espotify.org | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'media') diff --git a/media/espotify.org b/media/espotify.org index 1548c71..02abf65 100644 --- a/media/espotify.org +++ b/media/espotify.org @@ -135,11 +135,13 @@ Let's start with an umbrella customization group: to a given query, specified as a triple of term, types and filter: #+begin_src emacs-lisp - (defun espotify-search (callback term types &optional filter) - (let ((query-url (espotify--make-search-url term types filter))) - (espotify--with-auth-token + (defun espotify-get (callback url) + (espotify--with-auth-token (lambda (token) - (espotify--with-query-results token query-url callback))))) + (espotify--with-query-results token url callback)))) + + (defun espotify-search (callback term types &optional filter) + (espotify-get callback (espotify--make-search-url term types filter))) #+end_src For instance: @@ -302,15 +304,15 @@ Let's start with an umbrella customization group: (lambda (action) (pcase action ((pred stringp) - (if (string-suffix-p espotify-search-suffix action) - (espotify-search-all - (lambda (x) - (funcall next 'flush) - (funcall next x)) - (substring action 0 (- (length action) - (length espotify-search-suffix))) - type - filter))) + (when (string-suffix-p espotify-search-suffix action) + (espotify-search-all + (lambda (x) + (funcall next 'flush) + (funcall next x)) + (substring action 0 (- (length action) + (length espotify-search-suffix))) + type + filter))) (_ (funcall next action))))) #+end_src -- cgit v1.2.3