aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-browser.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/emms-browser.el b/emms-browser.el
index 05c17f1..c32d49c 100644
--- a/emms-browser.el
+++ b/emms-browser.el
@@ -110,6 +110,10 @@
;; (emms-browser-make-filter
;; "80s" (emms-browser-filter-only-dir "~/Mp3s/80s"))
+;; ;; show all tracks played in the last month
+;; (emms-browser-make-filter
+;; "last-month" (emms-browser-filter-only-recent 30))
+
;; After executing the above commands, you can use M-x
;; emms-browser-show-all, emms-browser-show-80s, etc to toggle
;; between different collections. Alternatively you can use '<' and
@@ -1581,5 +1585,17 @@ If the track is not of TYPE, return t."
`(lambda (track)
(not (eq (quote ,type) (emms-track-get track 'type)))))
+;; seconds in a day (* 60 60 24) = 86400
+(defun emms-browser-filter-only-recent (days)
+ "Show only tracks played within the last number of DAYS."
+ `(lambda (track)
+ (let ((min-date (time-subtract
+ (current-time)
+ (seconds-to-time (* ,days 86400))))
+ last-played)
+ (not (and (setq last-played
+ (emms-track-get track 'last-played nil))
+ (time-less-p min-date last-played))))))
+
(provide 'emms-browser)
;;; emms-browser.el ends here