diff options
author | Michael Olson <mwolson@gnu.org> | 2006-04-12 03:26:00 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2006-04-12 03:26:00 +0000 |
commit | 9bc8c6f54c74e2b37a79358aad28409b0d79a74c (patch) | |
tree | e9b99be05e93f2fa918a6693623350a1cec5293c | |
parent | 4972da8265bd1aaf02fb5296c013d5ca6b35d28d (diff) |
emms-player-mpd: Make emms-player-mpd-show take a callback argument so that it's easy to make a /NP command for Emacs-based IRC clients.
darcs-hash:20060412032655-1bfb2-bdc259d8c5b1210435d72a487e8ac756377d780f.gz
-rw-r--r-- | emms-player-mpd.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/emms-player-mpd.el b/emms-player-mpd.el index ca6c3b4..a15cb02 100644 --- a/emms-player-mpd.el +++ b/emms-player-mpd.el @@ -869,7 +869,8 @@ info from MusicPD." (emms-player-mpd-parse-response response))) (track (emms-dictionary '*track*)) (insertp (car closure)) - (buffer (cdr closure)) + (callback (cadr closure)) + (buffer (cddr closure)) (desc nil) string) (when info @@ -877,23 +878,28 @@ info from MusicPD." (emms-track-set track 'name (cdr (assoc "file" info))) (emms-info-mpd track info) (setq desc (emms-track-description track))) - (setq string (if desc - (format emms-show-format desc) - "Nothing playing right now")) - (if insertp - (with-current-buffer buffer - (insert string)) - (message "%s" string)))) + (if (not desc) + (message "Nothing playing right now") + (setq desc (format emms-show-format desc)) + (cond ((functionp callback) + (funcall callback buffer desc)) + (insertp + (with-current-buffer buffer + (insert desc))) + (t + (message "%s" desc)))))) ;;;###autoload -(defun emms-player-mpd-show (&optional insertp) +(defun emms-player-mpd-show (&optional insertp callback) "Describe the current EMMS track in the minibuffer. 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. This function uses `emms-show-format' to format the current track. It differs from `emms-show' in that it asks MusicPD for the current track, rather than EMMS." (interactive "P") - (emms-player-mpd-send "currentsong" (cons insertp (current-buffer)) + (emms-player-mpd-send "currentsong" + (cons insertp (cons callback (current-buffer))) #'emms-player-mpd-show-1)) (provide 'emms-player-mpd) |