emms-help
[Top][All Lists]
Advanced

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

[emms-help] Sorting by natural order


From: Matthew Kennedy
Subject: [emms-help] Sorting by natural order
Date: Thu, 13 Apr 2006 23:38:38 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Natural track order is the order in which you were meant to hear the
tracks on a CD.  This means sort by album name *and then* by track
number.

I didn't find a way to do this built into Emms (from darcs).  At first
I thought emms-playlist-sort-by-name was the solution, however that
seems to go off the filename which doesn't always represent the
natural order.

Here's what I implemented to achieve a natural order sort.  It might
be nice to include something like it in Emms though...

(defun emms-string> (a b)
  (not (or (string< a b)
           (string= a b))))

(defun emms-sort-natural-order-less-p (a b)
  "Sort two tracks by natural order.
This is the order in which albums where intended to be played.
ie. by album name and then by track number."
  (or (emms-string> (emms-track-get a 'info-album)
                    (emms-track-get b 'info-album))
      (and (string= (emms-track-get a 'info-album)
                    (emms-track-get b 'info-album))
           (< (string-to-number (emms-track-get a 'info-tracknumber))
              (string-to-number (emms-track-get b 'info-tracknumber))))))

(defun emms-playlist-sort-by-natural-order ()
  "Sort emms playlist by natural order.
See `emms-sort-natural-order-less-p'."
  (interactive)
  (emms-playlist-sort 'emms-sort-natural-order-less-p))

(define-key emms-playlist-sort-map (kbd "N") 
'emms-playlist-sort-by-natural-order)


Best regards,

-- 
Matthew Kennedy
Gentoo Linux Developer (Public Key 0x401903E0)




reply via email to

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