aboutsummaryrefslogtreecommitdiff
path: root/lisp/emms-playlist-sort.el
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2009-08-01 01:12:36 +0800
committerWilliam Xu <william.xwl@gmail.com>2009-08-01 01:12:36 +0800
commit0f88ab3db42dd78f73ae12da933f3b39fbd90411 (patch)
tree81b17e4c3ce100ab0e1d660a7ed415e6e282453f /lisp/emms-playlist-sort.el
parent8176350744ebefe066478bfc3de9a00e34261b77 (diff)
emms-playlist-sort.el: Refactor sort functions.
(emms-playlist-sort-by-file-extension): New func.
Diffstat (limited to 'lisp/emms-playlist-sort.el')
-rw-r--r--lisp/emms-playlist-sort.el42
1 files changed, 25 insertions, 17 deletions
diff --git a/lisp/emms-playlist-sort.el b/lisp/emms-playlist-sort.el
index 1b0c875..b08725e 100644
--- a/lisp/emms-playlist-sort.el
+++ b/lisp/emms-playlist-sort.el
@@ -57,12 +57,11 @@ Remember to call `emms-playlist-sort-map-setup' if you modify it."
With a prefix argument, decreasingly." attribute)
(interactive)
(emms-playlist-sort
- (lambda (a b)
- (if current-prefix-arg
- (emms-string> (emms-track-get a (quote ,attribute))
- (emms-track-get b (quote ,attribute)))
- (emms-string< (emms-track-get a (quote ,attribute))
- (emms-track-get b (quote ,attribute))))))))
+ '(lambda (a b)
+ (funcall
+ (if current-prefix-arg 'emms-string> 'emms-string<)
+ (emms-track-get a (quote ,attribute))
+ (emms-track-get b (quote ,attribute)))))))
(define-emms-playlist-sort name)
(define-emms-playlist-sort info-artist)
@@ -91,12 +90,11 @@ With a prefix argument, decreasingly."
(interactive)
(emms-playlist-sort
'(lambda (a b)
- (let ((ret (time-less-p
- (or (emms-track-get a 'last-played) '(0 0 0))
- (or (emms-track-get b 'last-played) '(0 0 0)))))
- (if current-prefix-arg
- (not ret)
- ret)))))
+ (funcall
+ (if current-prefix-arg 'not 'identity)
+ (time-less-p
+ (or (emms-track-get a 'last-played) '(0 0 0))
+ (or (emms-track-get b 'last-played) '(0 0 0)))))))
(defun emms-playlist-sort-by-play-count ()
"Sort emms playlist by play-count, increasingly.
@@ -104,11 +102,21 @@ With a prefix argument, decreasingly."
(interactive)
(emms-playlist-sort
'(lambda (a b)
- (let ((ret (< (or (emms-track-get a 'play-count) 0)
- (or (emms-track-get b 'play-count) 0))))
- (if current-prefix-arg
- (not ret)
- ret)))))
+ (funcall
+ (if current-prefix-arg 'not 'identity)
+ (< (or (emms-track-get a 'play-count) 0)
+ (or (emms-track-get b 'play-count) 0))))))
+
+(defun emms-playlist-sort-by-file-extension ()
+ "Sort emms playlist by file extension, increasingly.
+With a prefix argument, decreasingly."
+ (interactive)
+ (emms-playlist-sort
+ '(lambda (a b)
+ (funcall
+ (if current-prefix-arg 'emms-string> 'emms-string<)
+ (file-name-extension (emms-track-get a 'name))
+ (file-name-extension (emms-track-get b 'name))))))
(defvar emms-playlist-sort-map nil)