From dc0f30f3eeb9ece27f60537ad5d0160045308ae5 Mon Sep 17 00:00:00 2001 From: yoni-r Date: Tue, 26 Sep 2006 07:15:00 +0000 Subject: DoTheRightThing with player pausing and emms-bookmarks.el darcs-hash:20060926071538-85c19-18986d89ae4cb5463db57249c4ee0ef5f2360cbc.gz --- emms-bookmarks.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/emms-bookmarks.el b/emms-bookmarks.el index fbd0195..e411abd 100644 --- a/emms-bookmarks.el +++ b/emms-bookmarks.el @@ -120,6 +120,13 @@ FAILURE-MESSAGE should be a string." (emms-playlist-current-selected-track) "No previous bookmark")) +(defmacro emms-bookmarks-with-paused-player (&rest body) + "Eval BODY with player paused." + `(progn + (when (not emms-player-paused-p) (emms-pause)) + ,@body + (when emms-player-paused-p (emms-pause)))) + ;; can't use `interactive' to promt the user here because we want to ;; pause the player before the prompt appears. (defun emms-bookmarks-add () @@ -129,12 +136,11 @@ This function pauses the player while promting the user for a description of the bookmark. The function resumes the player after the prompt." (interactive) - (emms-pause) - (let ((desc (read-string "Description: "))) - (if (emms-playlist-current-selected-track) - (emms-bookmarks-set-current desc) - (error "No current track to bookmark"))) - (emms-pause)) + (emms-bookmarks-with-paused-player + (let ((desc (read-string "Description: "))) + (if (emms-playlist-current-selected-track) + (emms-bookmarks-set-current desc) + (error "No current track to bookmark"))))) (defun emms-bookmarks-clear () "Remove all the bookmarks from the current track." -- cgit v1.2.3