From afa5c8cc95dc940386fd4e2065b8dac19b72d587 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 9 Aug 2008 13:23:28 -0700 Subject: emms-lastfm: Complete artist names from cache. * doc/emms.texinfo: Update copyright years. (Last.fm radio): Update names of functions. * lisp/emms-lastfm.el (emms-lastfm-read-artist): New function that reads an artist from the user, doing completions from the EMMS track cache if present. (emms-play-lastfm-similar-artists): Rename from emms-lastfm-radio-similar-artists. Use completion. Thanks to Thierry Volpiatto for the initial implementation (emms-play-lastfm-global-tag): Rename from emms-lastfm-radio-global-tag. (emms-play-lastfm-artist-fan): Rename from emms-lastfm-radio-artist-fan. Use completion. --- lisp/emms-lastfm.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lisp/emms-lastfm.el') diff --git a/lisp/emms-lastfm.el b/lisp/emms-lastfm.el index 11804c8..a3b3adb 100644 --- a/lisp/emms-lastfm.el +++ b/lisp/emms-lastfm.el @@ -58,8 +58,8 @@ ;; There are some functions for conveniently playing the Similar Artists and ;; the Global Tag Radio. Here you only need to enter the band's name or the tag ;; respectively. -;; `M-x emms-lastfm-radio-similar-artists RET Britney Spears' -;; `M-x emms-lastfm-radio-global-tag RET pop' +;; `M-x emms-play-lastfm-similar-artists RET Britney Spears' +;; `M-x emms-play-lastfm-global-tag RET pop' ;; When you're listening to a Last.fm radio station you have the possibility to ;; give feedback to them. If you like the current song, type @@ -578,21 +578,35 @@ inserting it." (t (message msg)))))) (list insertp (current-buffer) callback))) -(defun emms-lastfm-radio-similar-artists (artist) +(defun emms-lastfm-read-artist () + "Read an artist name from the user." + (let ((artists nil)) + (when (boundp 'emms-cache-db) + (maphash + #'(lambda (file track) + (let ((artist (emms-track-get track 'info-artist))) + (when artist + (add-to-list 'artists artist)))) + emms-cache-db)) + (if artists + (emms-completing-read "Artist: " artists) + (read-string "Artist: ")))) + +(defun emms-play-lastfm-similar-artists (artist) "Plays the similar artist radio of ARTIST." - (interactive "sArtist: ") + (interactive (list (emms-lastfm-read-artist))) (emms-lastfm-radio (concat "lastfm://artist/" artist "/similarartists"))) -(defun emms-lastfm-radio-global-tag (tag) +(defun emms-play-lastfm-global-tag (tag) "Plays the global tag radio of TAG." (interactive "sGlobal Tag: ") (emms-lastfm-radio (concat "lastfm://globaltags/" tag))) -(defun emms-lastfm-radio-artist-fan (artist) +(defun emms-play-lastfm-artist-fan (artist) "Plays the artist fan radio of ARTIST." - (interactive "sArtist: ") + (interactive (list (emms-lastfm-read-artist))) (emms-lastfm-radio (concat "lastfm://artist/" artist "/fans"))) (defun emms-lastfm-radio-love () -- cgit v1.2.3