aboutsummaryrefslogtreecommitdiff
path: root/emms.el
diff options
context:
space:
mode:
Diffstat (limited to 'emms.el')
-rw-r--r--emms.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/emms.el b/emms.el
index 42f5f8f..1070b23 100644
--- a/emms.el
+++ b/emms.el
@@ -223,6 +223,11 @@ seconds the player did seek."
This can be used if the source depends on the current buffer not
being the playlist buffer.")
+(defvar emms-cache-get-function (lambda (path))
+ "A function to retrieve a track entry from the cache.")
+(defvar emms-cache-set-function (lambda (path track))
+ "A function to add/set a track entry from the cache.")
+
;;; User Interface
@@ -453,9 +458,15 @@ whenever possible."
(defun emms-track (type name)
"Create an EMMS track with type TYPE and name NAME."
- (let ((track (emms-dictionary '*track*)))
- (emms-track-set track 'type type)
- (emms-track-set track 'name name)
+ (let (track)
+ ;; we assume that name is unique across types, so type is not used
+ ;; if we find name in the cache
+ (unless (setq track (funcall emms-cache-get-function name))
+ (setq track (emms-dictionary '*track*))
+ (emms-track-set track 'type type)
+ (emms-track-set track 'name name))
+ ;; run any hooks regardless of a cache hit, as the entry may be
+ ;; old
(run-hook-with-args 'emms-track-initialize-functions track)
track))