From dfd7b747366c5cd18d62766151f938100e08e1b2 Mon Sep 17 00:00:00 2001 From: William Xu Date: Thu, 8 Mar 2007 11:55:00 +0000 Subject: 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 --- emms-playlist-sort.el | 14 +++++++++----- 1 file 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 @@ -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 -- cgit v1.2.3