diff options
author | william.xwl <william.xwl> | 2005-12-13 13:15:00 +0000 |
---|---|---|
committer | william.xwl <mwolson@gnu.org> | 2005-12-13 13:15:00 +0000 |
commit | fe75d2aac6312c97b4463b7bf86e459b25228dc4 (patch) | |
tree | 74d4f6a75dab48a0dd0e8b4543444050ffacc6d8 | |
parent | 63d50898c2520d529231e0eda708d75c84d9ca78 (diff) |
Added `emms-playlist-sort-by-score'.
darcs-hash:20051213131558-e8fe6-ee2bc9a6c1d608ede136b8ee814a56a2f21ccb55.gz
-rw-r--r-- | emms-playlist-sort.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/emms-playlist-sort.el b/emms-playlist-sort.el index 6e7288d..ac8258c 100644 --- a/emms-playlist-sort.el +++ b/emms-playlist-sort.el @@ -31,12 +31,14 @@ ;;; Code: +(require 'emms-score) + ;;; sort macro (defmacro define-emms-playlist-sort (attribute) "Macro for defining emms playlist sort functions." `(defun ,(intern (format "emms-playlist-sort-by-%s" attribute)) () - ,(format "Sort emms playlist by %s." attribute) + ,(format "Sort emms playlist by %s, increasingly." attribute) (interactive) (emms-playlist-sort (lambda (a b) @@ -50,6 +52,14 @@ (define-emms-playlist-sort info-year) (define-emms-playlist-sort info-note) +(defun emms-playlist-sort-by-score () + "Sort emms playlist by score, decreasingly." + (interactive) + (emms-playlist-sort + (lambda (a b) + (> (emms-score-get-score (emms-track-get a 'name)) + (emms-score-get-score (emms-track-get b 'name)))))) + ;; FIXME: Should better avoid relying on setting before loading. (defcustom emms-playlist-sort-prefix "S" "*Prefix key sequence for `emms-playlist-sort-map'. @@ -66,9 +76,10 @@ You should set this variable before loading this file." (define-key map (kbd "o") 'emms-playlist-sort-by-info-note) map)) -(define-key emms-playlist-mode-map - emms-playlist-sort-prefix - emms-playlist-sort-map) +(eval-after-load "emms-playlist-sort.el" + (define-key emms-playlist-mode-map + emms-playlist-sort-prefix + emms-playlist-sort-map)) (defun emms-playlist-sort (predicate) "Sort the whole playlist buffer by PREDICATE." @@ -91,7 +102,6 @@ You should set this variable before loading this file." (emms-playlist-select pos) (emms-playlist-first))))))) - (provide 'emms-playlist-sort) ;;; emms-playlist-sort.el ends here |