aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJohnathan Rabkin <yonirabkin@member.fsf.org>2012-09-18 12:28:50 -0400
committerJohnathan Rabkin <yonirabkin@member.fsf.org>2012-09-18 12:28:50 -0400
commitd5666db21b9e2832eedf4d63a35d29f7fea7135b (patch)
treed0254154faee9817b6af42e7e04790e4ef4d71fd /lisp
parent7a5eb54fa0f4a0d91213ec91263bfacc0469bc55 (diff)
Add support for disc-number sorting of FLAC files.
Patch from Christophe Rhodes <csr21@cantab.net>.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emms-browser.el10
-rw-r--r--lisp/emms-info-metaflac.el1
-rw-r--r--lisp/emms-info.el1
-rw-r--r--lisp/emms-playlist-sort.el20
-rw-r--r--lisp/emms-tag-editor.el5
5 files changed, 26 insertions, 11 deletions
diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el
index 6bff443..c52f326 100644
--- a/lisp/emms-browser.el
+++ b/lisp/emms-browser.el
@@ -786,6 +786,15 @@ return an empty string."
(concat "0" tracknum)
tracknum)))))
+(defun emms-browser-disc-number (track)
+ "Return a string representation of a track number.
+The string will end in a space. If no track number is available,
+return an empty string."
+ (let ((discnum (emms-track-get track 'info-discnumber)))
+ (if (or (not (stringp discnum)) (string= discnum "0"))
+ ""
+ discnum)))
+
(defun emms-browser-year-number (track)
"Return a string representation of a track's year.
This will be in the form '(1998) '."
@@ -1700,6 +1709,7 @@ If > album level, most of the track data will not make sense."
("C" . ,(emms-track-get track 'info-composer))
("p" . ,(emms-track-get track 'info-performer))
("t" . ,(emms-track-get track 'info-title))
+ ("D" . ,(emms-browser-disc-number track))
("T" . ,(emms-browser-track-number track))
("d" . ,(emms-browser-track-duration track))
("cS" . ,(emms-browser-get-cover-str path 'small))
diff --git a/lisp/emms-info-metaflac.el b/lisp/emms-info-metaflac.el
index c6188c3..5e50578 100644
--- a/lisp/emms-info-metaflac.el
+++ b/lisp/emms-info-metaflac.el
@@ -64,6 +64,7 @@ external metaflac program"
"--show-tag=NOTE"
"--show-tag=YEAR"
"--show-tag=TRACKNUMBER"
+ "--show-tag=DISCNUMBER"
"--show-tag=GENRE")
"The argument to pass to `emms-info-metaflac-program-name'."
:type '(repeat string)
diff --git a/lisp/emms-info.el b/lisp/emms-info.el
index 2f3b7bc..cfc206b 100644
--- a/lisp/emms-info.el
+++ b/lisp/emms-info.el
@@ -35,6 +35,7 @@
;; info-title - string naming the title of the song
;; info-album - string naming the album
;; info-tracknumber - string(?) naming the track number
+;; info-discnumber - string naming the disc number
;; info-year - string naming the year
;; info-note - string of free-form entry
;; info-genre - string naming the genre
diff --git a/lisp/emms-playlist-sort.el b/lisp/emms-playlist-sort.el
index e35d483..138308e 100644
--- a/lisp/emms-playlist-sort.el
+++ b/lisp/emms-playlist-sort.el
@@ -37,7 +37,7 @@
"Sorting list used by `emms-playlist-sort-by-list'.
Currently it understands the following fields: name info-artist
imfo-composer info-performer info-title info-album info-genre
-info-playing-time info-tracknumber."
+info-playing-time info-tracknumber info-discnumber."
:type 'symbol
:group 'emms-playlist-sort)
@@ -173,15 +173,17 @@ With a prefix argument, decreasingly."
This is the order in which albums where intended to be played.
ie. by album name and then by track number."
(let ((album-a (emms-track-get a 'info-album))
- (album-b (emms-track-get b 'info-album)))
+ (album-b (emms-track-get b 'info-album))
+ (discnum-a (string-to-number (or (emms-track-get a 'info-discnumber) "0")))
+ (discnum-b (string-to-number (or (emms-track-get b 'info-discnumber) "0")))
+ (tracknum-a (string-to-number (or (emms-track-get a 'info-tracknumber) "0")))
+ (tracknum-b (string-to-number (or (emms-track-get b 'info-tracknumber) "0"))))
(or (emms-string< album-a album-b)
- (and album-a
- album-b
+ (and album-a album-b
(string= album-a album-b)
- (< (string-to-number (or (emms-track-get a 'info-tracknumber)
- "0"))
- (string-to-number (or (emms-track-get b 'info-tracknumber)
- "0")))))))
+ (or (< discnum-a discnum-b)
+ (and (= discnum-a discnum-b)
+ (< tracknum-a tracknum-b)))))))
(defun emms-playlist-sort-by-list-p (a b)
(catch 'return
@@ -195,7 +197,7 @@ ie. by album name and then by track number."
(when (< (emms-track-get a info)
(emms-track-get b info))
(throw 'return t)))
- ((info-tracknumber)
+ ((info-tracknumber info-discnumber)
(when (< (string-to-number (or (emms-track-get a info) "0"))
(string-to-number (or (emms-track-get b info) "0")))
(throw 'return t)))))))
diff --git a/lisp/emms-tag-editor.el b/lisp/emms-tag-editor.el
index 3eba673..06041c5 100644
--- a/lisp/emms-tag-editor.el
+++ b/lisp/emms-tag-editor.el
@@ -92,6 +92,7 @@ is the format template. The format specification is like:
t -- Track info-title
l -- Track info-album
n -- Track info-tracknumber
+ D -- Track info-discnumber
y -- Track info-year
g -- Track info-genre
; -- Track info-note
@@ -139,7 +140,7 @@ should be given.
See also `emms-tag-editor-tag-file' and `emms-tag-editor-tag-ogg'.")
(defun emms-tag-editor-tag-flac (track)
- "Commit changes to an OGG file according to TRACK."
+ "Commit changes to an FLAC file according to TRACK."
(require 'emms-info-metaflac)
(with-temp-buffer
(let (need val)
@@ -147,7 +148,7 @@ See also `emms-tag-editor-tag-file' and `emms-tag-editor-tag-ogg'.")
(let ((info-tag (intern (concat "info-" tag))))
(when (> (length (setq val (emms-track-get track info-tag))) 0)
(insert (upcase tag) "=" val "\n"))))
- '("artist" "composer" "performer" "title" "album" "tracknumber" "date" "genre" "note"))
+ '("artist" "composer" "performer" "title" "album" "tracknumber" "discnumber" "date" "genre" "note"))
(when (buffer-string)
(funcall #'call-process-region (point-min) (point-max)
emms-info-metaflac-program-name nil