diff options
author | Michael Olson <mwolson@gnu.org> | 2007-07-23 02:34:00 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2007-07-23 02:34:00 +0000 |
commit | f6a376a5382ab46ab47db17e7b2bfdd6af792bf8 (patch) | |
tree | 1d1f88752047d5e7969af3abe9f65a8abb5285fb | |
parent | bda55f5f49480c19c080a66a51c4686d2ab5cfbf (diff) |
emms-playlist-limit: Use standard enable/disable/toggle interface
darcs-hash:20070723023452-1bfb2-b892d6467fb456079587713fa4d188b4d061f3d1.gz
-rw-r--r-- | emms-playlist-limit.el | 35 |
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) |