diff options
author | Michael Olson <mwolson@gnu.org> | 2007-04-08 20:50:00 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2007-04-08 20:50:00 +0000 |
commit | 7c05231415f877a3902f4f247b512c5373a08407 (patch) | |
tree | d7f70a62406c1ffc8aa3c55515013b29535e41eb /emms-lastfm.el | |
parent | 2bb38ee60a4f6de5ca6ac74a007bd27ec59f8c07 (diff) |
emms-player-mpd: Integrate with emms-lastfm to show track
* emms-lastfm (emms-lastfm-np): Expand to take optional callback
argument. Rename `arg' to `insertp' for clarity.
* emms-player-mpd (emms-player-mpd-show-1): Detect if emms-lastfm is
activated, and if the current track is a LastFM URL. If so, call
emms-lastfm-np rather than continuing on.
(emms-player-mpd-show): Docfix.
darcs-hash:20070408205000-1bfb2-6207ca703571a4602c7b1510f62be33df9722a8d.gz
Diffstat (limited to 'emms-lastfm.el')
-rw-r--r-- | emms-lastfm.el | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/emms-lastfm.el b/emms-lastfm.el index ced9a0b..ffb1e20 100644 --- a/emms-lastfm.el +++ b/emms-lastfm.el @@ -435,11 +435,18 @@ high. (But then streaming a 128KHz mp3 won't be fun anyway.)" (message "EMMS: Playing Last.fm stream")) (message "EMMS: Bad response from Last.fm")))) -(defun emms-lastfm-np (&optional arg) - "Show the currently-playing lastfm radio tune." +(defun emms-lastfm-np (&optional insertp callback) + "Show the currently-playing lastfm radio tune. + +If INSERTP is non-nil, insert the description into the current +buffer instead. + +If CALLBACK is a function, call it with the current buffer and +description as arguments instead of displaying the description or +inserting it." (interactive "P") (emms-lastfm-radio-request-metadata - (lambda (status arg buffer) + (lambda (status insertp buffer callback) (let (artist title) (save-excursion (set-buffer emms-lastfm-buffer) @@ -449,11 +456,13 @@ high. (But then streaming a 128KHz mp3 won't be fun anyway.)" (let ((msg (if title (format emms-show-format (format "%s - %s" artist title)) "Nothing playing right now"))) - (if (and arg title) - (with-current-buffer buffer - (insert msg)) - (message msg))))) - (list arg (current-buffer)))) + (cond ((functionp callback) + (funcall callback buffer msg)) + ((and insertp title) + (with-current-buffer buffer + (insert msg))) + (t (message msg)))))) + (list insertp (current-buffer) callback))) (defun emms-lastfm-radio-similar-artists (artist) "Plays the similar artist radio of ARTIST." |