aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorYoni Rabkin <yoni@rabkins.net>2017-09-01 16:27:37 -0400
committerYoni Rabkin <yoni@rabkins.net>2017-09-01 16:27:37 -0400
commit93b4340e6fd2b34f50aec2fa129e3d4122f6a5f6 (patch)
tree9ed87c2490aa1db82629b9bd196da8357218eb8c /lisp
parente790730a4e258440184bc8ce5d3015efe09f8984 (diff)
* lisp/emms-playlist-sort.el: new function
Sort playlist by file mtime.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emms-playlist-sort.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/emms-playlist-sort.el b/lisp/emms-playlist-sort.el
index 0c3b466..d9fc519 100644
--- a/lisp/emms-playlist-sort.el
+++ b/lisp/emms-playlist-sort.el
@@ -118,6 +118,20 @@ With a prefix argument, decreasingly."
(file-name-extension (emms-track-get a 'name))
(file-name-extension (emms-track-get b 'name))))))
+(defun emms-playlist-sort-by-file-mtime ()
+ "Sort emms playlist by file mtime, newest first.
+With a prefix argument, oldest first."
+ (interactive)
+ (emms-playlist-sort
+ '(lambda (a b)
+ (funcall
+ (if current-prefix-arg
+ 'time-less-p
+ (lambda (t1 t2) (not (time-less-p t1 t2))))
+ (emms-info-track-file-mtime a)
+ (emms-info-track-file-mtime b)))))
+
+
(defvar emms-playlist-sort-map nil)
(defun emms-playlist-sort-map-setup ()
@@ -138,6 +152,7 @@ With a prefix argument, decreasingly."
(define-key map (kbd "C") 'emms-playlist-sort-by-info-composer)
(define-key map (kbd "L") 'emms-playlist-sort-by-list)
(define-key map (kbd "N") 'emms-playlist-sort-by-name)
+ (define-key map (kbd "T") 'emms-playlist-sort-by-file-mtime)
map))
(define-key emms-playlist-mode-map