stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] [PATCH] contrib/mpd.lisp sort artists and genres during browsing


From: Vitaly Mayatskikh
Subject: [STUMP] [PATCH] contrib/mpd.lisp sort artists and genres during browsing
Date: Mon, 23 Feb 2009 09:47:04 +0100
User-agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/22.3 Mule/5.0 (SAKAKI)

This patch applies on recent Morgan's patches for database browsing
and sorts artists and genres lists.

diff -up stumpwm/contrib/mpd.lisp.orig stumpwm/contrib/mpd.lisp
--- stumpwm/contrib/mpd.lisp.orig       2009-02-23 09:39:36.000000000 +0100
+++ stumpwm/contrib/mpd.lisp    2009-02-21 13:56:54.000000000 +0100
@@ -468,13 +468,19 @@ Volume
           (define-key m (kbd "RET") (mpd-menu-action :mpd-playlist-play))
           m)))
 
+(defun mpd-uniq-and-sort-list (list criteria &optional do-sort)
+  (let ((lst (mapcar #'cadr (remove-if (lambda (item)
+                                        (not (equal criteria
+                                                    (first item))))
+                                      list))))
+    (if do-sort
+       (sort lst #'string<)
+       lst)))
+
 (defcommand mpd-browse-playlist (&optional current-song) ()
   (let* ((status (mpd-send-command "status"))
          (response (mpd-send-command "playlistinfo"))
-         (options (mapcar #'cadr (remove-if (lambda (item)
-                                              (not (equal :file
-                                                          (first item))))
-                                            response))))
+         (options (mpd-uniq-and-sort-list response :file)))
     (multiple-value-bind (action choice)
         (mpd-menu "Current playlist" options *mpd-playlist-menu-map*
                   (if current-song
@@ -532,10 +538,7 @@ Volume
                     (if genre
                         (format nil "list artist genre \"~a\"" genre)
                           "list artist")))
-         (options (mapcar #'cadr (remove-if (lambda (item)
-                                             (not (equal :artist
-                                                         (first item))))
-                                           response))))
+         (options (mpd-uniq-and-sort-list response :artist t)))
         (multiple-value-bind (action choice)
             (mpd-menu "Select artist" options *mpd-browse-menu-map*)
           (case action
@@ -552,10 +555,7 @@ Volume
 
 (defcommand mpd-browse-genres () ()
     (let* ((response (mpd-send-command "list genre"))
-           (options (mapcar #'cadr (remove-if (lambda (item)
-                                               (not (equal :genre
-                                                           (first item))))
-                                             response))))
+           (options (mpd-uniq-and-sort-list response :genre t)))
         (multiple-value-bind (action choice)
             (mpd-menu "Select genre" options *mpd-browse-menu-map*)
           (case action
@@ -572,9 +572,7 @@ Volume
                       (if artist
                           (format nil "list album artist \"~a\"" artist)
                           "list album")))
-           (options (mapcar #'cadr (remove-if (lambda (item)
-                                              (not (equal :album (first 
item))))
-                                             response))))
+           (options (mpd-uniq-and-sort-list response :album)))
         (multiple-value-bind (action choice)
             (mpd-menu "Select album" options *mpd-browse-menu-map*)
           (case action
@@ -592,9 +590,7 @@ Volume
 (defcommand mpd-browse-tracks (album &optional artist) ((:string "Album: "))
     (let* ((response (mpd-send-command
                           (format nil "list title album \"~a\"" album)))
-           (options (mapcar #'cadr (remove-if (lambda (item)
-                                              (not (equal :title (first 
item))))
-                                             response))))
+           (options (mpd-uniq-and-sort-list response :title)))
         (multiple-value-bind (action choice)
             (mpd-menu "Select track" options *mpd-browse-menu-map*)
           (case action

-- 
wbr, Vitaly




reply via email to

[Prev in Thread] Current Thread [Next in Thread]