From f6a376a5382ab46ab47db17e7b2bfdd6af792bf8 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 23 Jul 2007 02:34:00 +0000 Subject: emms-playlist-limit: Use standard enable/disable/toggle interface darcs-hash:20070723023452-1bfb2-b892d6467fb456079587713fa4d188b4d061f3d1.gz --- emms-playlist-limit.el | 35 +++++++++++++++++++++++++++++++---- 1 file 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) -- cgit v1.2.3