aboutsummaryrefslogtreecommitdiff
path: root/emms-playlist-sort.el
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2007-03-08 11:55:00 +0000
committerWilliam Xu <william.xwl@gmail.com>2007-03-08 11:55:00 +0000
commitdfd7b747366c5cd18d62766151f938100e08e1b2 (patch)
tree88c5c61610014372da62e25d09f3446ae2dc4e24 /emms-playlist-sort.el
parent454ab8e97c30508f958b9417d81005bc79c638cd (diff)
emms-playlist-sort.el: Add `emms-string<', making string sort case
insensitive. (This makes more sense in cases like sorting according to artist, etc) darcs-hash:20070308115507-cfa61-7caf3b20e7c4c1ba53ba732fbb799e68da52c8c4.gz
Diffstat (limited to 'emms-playlist-sort.el')
-rw-r--r--emms-playlist-sort.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/emms-playlist-sort.el b/emms-playlist-sort.el
index 816b774..0a702b6 100644
--- a/emms-playlist-sort.el
+++ b/emms-playlist-sort.el
@@ -1,6 +1,6 @@
;;; emms-playlist-sort.el --- sort emms playlist
-;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: William Xu <william.xwl@gmail.com>
@@ -69,8 +69,8 @@ info-tracknumber."
(interactive)
(emms-playlist-sort
(lambda (a b)
- (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)))))))
(define-emms-playlist-sort name)
(define-emms-playlist-sort info-artist)
@@ -145,7 +145,7 @@ If START and END are not provided, the whole buffer will be sorted."
(emms-playlist-first))))))))
(defun emms-string> (a b)
- (not (or (string< a b)
+ (not (or (emms-string< a b)
(string= a b))))
(defun emms-sort-natural-order-less-p (a b)
@@ -166,7 +166,7 @@ ie. by album name and then by track number."
(dolist (info emms-playlist-sort-list)
(case info
((name info-artist info-title info-album info-genre)
- (when (string< (emms-track-get a info)
+ (when (emms-string< (emms-track-get a info)
(emms-track-get b info))
(throw 'return t)))
((info-playing-time)
@@ -178,6 +178,10 @@ ie. by album name and then by track number."
(string-to-number (or (emms-track-get b info) "0")))
(throw 'return t)))))))
+(defun emms-string< (s1 s2)
+ "Same as `string<' except this is case insensitive."
+ (string< (downcase s1) (downcase s2)))
+
(provide 'emms-playlist-sort)
;;; emms-playlist-sort.el ends here