diff options
author | forcer <forcer> | 2006-06-07 16:10:00 +0000 |
---|---|---|
committer | forcer <mwolson@gnu.org> | 2006-06-07 16:10:00 +0000 |
commit | 84acadce0e7916d1dd95a80aa69e57752ec80615 (patch) | |
tree | 7b7d3fec3a9d94c1f97156de6f4eb71becd08ff9 | |
parent | 06f6648e9a58761edfd5345f04e5ba8bb298bc48 (diff) |
Mark the cache as dirty for each modification.
darcs-hash:20060607161049-2189f-293b55878f4a073640a397e4b2aa563c3bf785d6.gz
-rw-r--r-- | emms-cache.el | 7 | ||||
-rw-r--r-- | emms-info.el | 1 | ||||
-rw-r--r-- | emms-setup.el | 3 | ||||
-rw-r--r-- | emms.el | 16 |
4 files changed, 21 insertions, 6 deletions
diff --git a/emms-cache.el b/emms-cache.el index be6c7ae..2366075 100644 --- a/emms-cache.el +++ b/emms-cache.el @@ -38,6 +38,7 @@ ;; (add-hook 'kill-emacs-hook 'emms-cache-save) ;; (setq emms-cache-get-function 'emms-cache-get) ;; (setq emms-cache-set-function 'emms-cache-set) +;; (setq emms-cache-modified-function 'emms-cache-dirty) ;;; Code: @@ -52,6 +53,10 @@ This is used to cache over emacs sessions.") (defvar emms-cache-dirty nil "True if the cache has been updated since init.") +(defun emms-cache-dirty (&rest ignored) + "Mark the cache as dirty." + (setq emms-cache-dirty t)) + (defun emms-cache-get (type path) "Return a cache element for PATH, or nil." (gethash path emms-cache-db)) @@ -59,7 +64,7 @@ This is used to cache over emacs sessions.") (defun emms-cache-set (type path track) "Set PATH to TRACK in the cache." (puthash path track emms-cache-db) - (setq emms-cache-dirty t)) + (emms-cache-dirty)) (defun emms-cache-save () "Save the track cache to a file." diff --git a/emms-info.el b/emms-info.el index 0edeb85..a1cdaa0 100644 --- a/emms-info.el +++ b/emms-info.el @@ -90,7 +90,6 @@ Return t when the track got changed." (run-hook-with-args 'emms-info-functions track) ;; not set by info functions (emms-track-set track 'info-mtime file-mtime) - (funcall emms-cache-set-function name track) (emms-track-updated track)) (when emms-info-asynchronously diff --git a/emms-setup.el b/emms-setup.el index e520662..b99e237 100644 --- a/emms-setup.el +++ b/emms-setup.el @@ -85,7 +85,8 @@ audio files, and a metadata cache." (add-hook 'after-init-hook 'emms-cache-restore) (add-hook 'kill-emacs-hook 'emms-cache-save) (setq emms-cache-get-function 'emms-cache-get) - (setq emms-cache-set-function 'emms-cache-set)) + (setq emms-cache-set-function 'emms-cache-set) + (setq emms-cache-modified-function 'emms-cache-dirty)) ;;;###autoload (defun emms-all () @@ -224,6 +224,12 @@ This is called with a single argument, the track." :group 'emms :type 'function) +(defcustom emms-cache-modified-function nil + "A function to be called when a track is modified. +The modified track is passed as the argument to this function." + :group 'emms + :type 'function) + (defvar emms-player-playing-p nil "The currently playing EMMS player, or nil.") @@ -469,8 +475,10 @@ whenever possible." (funcall emms-cache-get-function type name)))) (when (not track) (setq track (emms-dictionary '*track*)) - (emms-track-set track 'type type) - (emms-track-set track 'name name) + ;; Prevent the cache from being called for these two sets + (let ((emms-cache-modified-function nil)) + (emms-track-set track 'type type) + (emms-track-set track 'name name)) (when emms-cache-set-function (funcall emms-cache-set-function type name track))) ;; run any hooks regardless of a cache hit, as the entry may be @@ -493,7 +501,9 @@ If there is no value, return DEFAULT (or nil, if not given)." (defun emms-track-set (track name value) "Set the value of NAME for TRACK to VALUE." - (emms-dictionary-set track name value)) + (emms-dictionary-set track name value) + (when emms-cache-modified-function + (funcall emms-cache-modified-function track))) (defun emms-track-description (track) "Return a description of TRACK. |