aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-playlist-limit.el35
1 files changed, 31 insertions, 4 deletions
diff --git a/emms-playlist-limit.el b/emms-playlist-limit.el
index 95816a2..f532ca2 100644
--- a/emms-playlist-limit.el
+++ b/emms-playlist-limit.el
@@ -26,16 +26,43 @@
;;; User Interfacs
-;;;###autoload
+(defvar emms-playlist-limit-enabled-p nil
+ "If non-nil, emms playlist limit is enabled.")
+
(defun emms-playlist-limit (arg)
- "Turn on emms limit if ARG is positive, off otherwise."
+ "Turn on emms playlist limit if ARG is positive, off otherwise."
(interactive "p")
(if (and arg (> arg 0))
- (add-hook 'emms-playlist-source-inserted-hook
- 'emms-playlist-limit-insert)
+ (progn
+ (setq emms-playlist-limit-enabled-p t)
+ (add-hook 'emms-playlist-source-inserted-hook
+ 'emms-playlist-limit-insert))
+ (setq emms-playlist-limit-enabled-p nil)
(remove-hook 'emms-playlist-source-inserted-hook
'emms-playlist-limit-insert)))
+;;;###autoload
+(defun emms-playlist-limit-enable ()
+ "Turn on emms playlist limit."
+ (interactive)
+ (emms-playlist-limit 1)
+ (message "emms playlist limit enabled"))
+
+;;;###autoload
+(defun emms-playlist-limit-disable ()
+ "Turn off emms playlist limit."
+ (interactive)
+ (emms-playlist-limit -1)
+ (message "emms playlist limit disabled"))
+
+;;;###autoload
+(defun emms-playlist-limit-toggle ()
+ "Toggle emms playlist limit."
+ (interactive)
+ (if emms-playlist-limit-enabled-p
+ (emms-playlist-limit-disable)
+ (emms-playlist-limit-enable)))
+
(defmacro define-emms-playlist-limit (attribute)
"Macro for defining emms playlist limit functions."
`(defun ,(intern (format "emms-playlist-limit-to-%s" attribute)) (regexp)