aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2008-08-07 23:17:55 -0700
committerMichael Olson <mwolson@gnu.org>2008-08-07 23:17:55 -0700
commit616f160c7f783dc232f68ea6ab8b40a36f690b18 (patch)
treec5c476778d934efcb2972c38438c02aeeecd0c9f
parent96924d99f35234cf6de2a49574d792d5147423d4 (diff)
Implement filtering of track data after retrieving it.
* lisp/emms.el (emms-track-info-filters): New option that allows the user to specify some functions that filter track data. One example of this is removing cruft like "(Album Version)" from music purchased over Amazon without having to edit every single music file. (emms-track-updated-functions): Update docstring to indicate that this is called after display of the track, not before. (emms-track-updated): Call emms-track-info-filters. * lisp/emms-player-mpd.el (emms-player-mpd-get-tracks-1) (emms-player-mpd-show-1): Call emms-track-info-filters.
-rw-r--r--lisp/emms-player-mpd.el2
-rw-r--r--lisp/emms.el11
2 files changed, 12 insertions, 1 deletions
diff --git a/lisp/emms-player-mpd.el b/lisp/emms-player-mpd.el
index 98d44d0..7efe13f 100644
--- a/lisp/emms-player-mpd.el
+++ b/lisp/emms-player-mpd.el
@@ -430,6 +430,7 @@ The list will be in reverse order."
'file))
(track (emms-track type file)))
(emms-info-mpd track song-info)
+ (run-hook-with-args 'emms-track-info-filters track)
(setq tracks (cons track tracks)))))))
(funcall (car closure) (cdr closure) tracks)))
@@ -1052,6 +1053,7 @@ positive or negative."
(emms-track-set track 'type 'file))
(emms-track-set track 'name file)
(emms-info-mpd track info)
+ (run-hook-with-args 'emms-track-info-filters track)
(setq track-desc (emms-track-description track))
(when (and (stringp track-desc) (not (string= track-desc "")))
(setq desc (if desc
diff --git a/lisp/emms.el b/lisp/emms.el
index 100e9e8..1d8e827 100644
--- a/lisp/emms.el
+++ b/lisp/emms.el
@@ -176,8 +176,16 @@ This can be used to initialize tracks with various info."
:group 'emms
:type 'hook)
+(defcustom emms-track-info-filters nil
+ "*List of functions to call when a track changes data, before updating
+the display.
+These functions are passed the track as an argument."
+ :group 'emms
+ :type 'hook)
+
(defcustom emms-track-updated-functions nil
- "*List of functions to call when a track changes data.
+ "*List of functions to call when a track changes data, after updating
+the display.
These functions are passed the track as an argument."
:group 'emms
:type 'hook)
@@ -588,6 +596,7 @@ a description into a playlist buffer."
(defun emms-track-updated (track)
"Information in TRACK got updated."
+ (run-hook-with-args 'emms-track-info-filters track)
(emms-playlist-track-updated track)
(run-hook-with-args 'emms-track-updated-functions track))