From 9413440d6b2b5bcfdb436b36e18419f6b8180d31 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Tue, 19 Dec 2006 08:54:00 +0000 Subject: warn-if-playing-time-deactivated.dpatch New emms-lastfm-activate warns the user if he disabled emms-playing-time completely and points him to the right docs. darcs-hash:20061219085443-c06f4-68cc025edede1f9a399e0067526f5b519a5e2e69.gz --- emms-lastfm.el | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/emms-lastfm.el b/emms-lastfm.el index a9308a8..3a786c0 100644 --- a/emms-lastfm.el +++ b/emms-lastfm.el @@ -105,15 +105,26 @@ http://www.last.fm, if ARG is positive. If ARG is negative or zero submission of the tracks will be stopped. This applies to the current track, too." (interactive "p") - (if (not (and emms-lastfm-username emms-lastfm-password)) - (message "%s" - (concat "EMMS: In order to activate the last.fm plugin you " - "first have to set both `emms-lastfm-username' and " - "`emms-lastfm-password'.")) - (if (> ARG 0) + (cond + ((not (and emms-lastfm-username emms-lastfm-password)) + (message "%s" + (concat "EMMS: In order to activate the last.fm plugin you " + "first have to set both `emms-lastfm-username' and " + "`emms-lastfm-password'."))) + ((not emms-playing-time-p) + (message "%s" + (concat "EMMS: The last.fm plugin needs the functionality " + "provided by `emms-playing-time'. It seems that you " + "disabled it explicitly in your init file using code " + "like this: `(emms-playing-time -1)'. Delete that " + "line and have a look at `emms-playing-time's doc " + "string."))) + (t + (if (and ARG (> ARG 0)) (progn + ;; Append it. Else the playing time could be started a bit too late. (add-hook 'emms-player-started-hook - 'emms-lastfm-handshake-if-needed) + 'emms-lastfm-handshake-if-needed t) ;; Has to be appended, because it has to run after ;; `emms-playing-time-start' (add-hook 'emms-player-started-hook @@ -131,12 +142,12 @@ the current track, too." 'emms-lastfm-cancel-timer) (remove-hook 'emms-player-paused-hook 'emms-lastfm-pause) - (cancel-timer emms-lastfm-timer) + (when emms-lastfm-timer (cancel-timer emms-lastfm-timer)) (setq emms-lastfm-md5-challenge nil emms-lastfm-submit-url nil emms-lastfm-process nil emms-lastfm-current-track nil) - (message "EMMS Last.fm plugin deactivated.")))) + (message "EMMS Last.fm plugin deactivated."))))) (defun read-line () (buffer-substring-no-properties (line-beginning-position) -- cgit v1.2.3