aboutsummaryrefslogtreecommitdiff
path: root/emms-tag-editor.el
diff options
context:
space:
mode:
authorTassilo Horn <tassilo@member.fsf.org>2007-08-16 07:01:00 +0000
committerTassilo Horn <tassilo@member.fsf.org>2007-08-16 07:01:00 +0000
commitaa2ec7157503b7da1d465d6c52d6fc610d399c86 (patch)
tree9a7cfbd7728a1ccca33114425c363e2a1f32ea77 /emms-tag-editor.el
parente56608e2156199b226ee0f76977dc85e53cc24a5 (diff)
fix-cache-problem-when-renaming-tracks.dpatch
I fixed the problem with the cache I mentioned in my last patch. darcs-hash:20070816070106-c06f4-d82d39fdf633aa7943026628a26b96fe23efbc35.gz
Diffstat (limited to 'emms-tag-editor.el')
-rw-r--r--emms-tag-editor.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/emms-tag-editor.el b/emms-tag-editor.el
index a99e8ec..0bedefc 100644
--- a/emms-tag-editor.el
+++ b/emms-tag-editor.el
@@ -661,23 +661,35 @@ tracks according to the value of
(defun emms-tag-editor-rename-track (track)
"Rename TRACK's file according `emms-tag-editor-rename-format's
value."
- (let* ((file (or (emms-track-get track 'info-file)
- (emms-track-get track 'name)))
- (path (file-name-directory file))
- (suffix (file-name-extension file))
- (new-file (concat
- path
- (format-spec
- emms-tag-editor-rename-format
- (apply 'format-spec-make
- (apply 'append
- (mapcar (lambda (tag)
- (list (string-to-char (cdr tag))
- (or (emms-track-get track (car tag)) "")))
- emms-tag-editor-tags))))
- "." suffix)))
- (rename-file file new-file)
- (message "Renamed \"%s\" to \"%s\"." file new-file)))
+ (if (eq (emms-track-get track 'type) 'file)
+ (let* ((old-file (or (emms-track-get track 'info-file)
+ (emms-track-get track 'name)))
+ (path (file-name-directory old-file))
+ (suffix (file-name-extension old-file))
+ (new-file (concat
+ path
+ (format-spec
+ emms-tag-editor-rename-format
+ (apply 'format-spec-make
+ (apply 'append
+ (mapcar
+ (lambda (tag)
+ (list (string-to-char (cdr tag))
+ (or (emms-track-get track (car tag))
+ "")))
+ emms-tag-editor-tags))))
+ "." suffix)))
+ ;; Rename the file...
+ (rename-file old-file new-file)
+ ;; ... and update the track and the cache (if used) if the renaming
+ ;; worked.
+ (dolist (info '(name info-file))
+ (emms-track-set track info new-file))
+ (when (featurep 'emms-cache)
+ (emms-cache-del old-file) ;; delete the old one and...
+ (emms-cache-set 'file new-file track)) ;; ... insert the new one
+ (message "Renamed \"%s\" to \"%s\"." old-file new-file))
+ (message "Only files can be renamed.")))
(defun emms-tag-editor-rename-marked-tracks ()
"Rename the files corresponding to all marked tracks according