From 015d2184319039e813bf83c9c4427fdb0f327419 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Wed, 24 Feb 2021 13:33:20 +0100 Subject: [PATCH] Fix wrong handling of EMMS' current playlist buffer during export The macro `with-current-emms-playlist' does not set the current playlist to the current buffer, but instead switches to it. Yes, that's reasonable, but not what I thought it does. Since I need the reverse (make the current buffer to temporarily be the current playlist), we simply bind `emms-playlist-buffer' to the value returned by `current-buffer'. While we are at it, also make info loading synchronous by binding `emms-info-asynchronously' to nil. --- site-lisp/db-music.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/site-lisp/db-music.el b/site-lisp/db-music.el index ea87e4a..0b78d00 100644 --- a/site-lisp/db-music.el +++ b/site-lisp/db-music.el @@ -188,17 +188,18 @@ OVERWRITE is non-nil." (if (not (zerop return-code)) (error "%s" output) (let ((emms-source-playlist-ask-before-overwrite (not overwrite)) - (emms-temp-playlist-buffer (emms-playlist-new " *EMMS Playlist Export*"))) + (emms-temp-playlist-buffer (emms-playlist-new " *EMMS Playlist Export*")) + (emms-info-asynchronously nil)) (with-current-buffer emms-temp-playlist-buffer - (emms-playlist-clear) - (dolist (track (split-string output "[\n\r]+")) - (emms-insert-file track)) - (emms-playlist-sort-by-info-title) - (emms-playlist-sort-by-info-artist) - ;; When writing the playlist, we simulate the current buffer to be - ;; the current playlist, as otherwise `emms-playlist-save' will - ;; ask for confirmation. - (with-current-emms-playlist + (let ((emms-playlist-buffer (current-buffer))) + (emms-playlist-clear) + (dolist (track (split-string output "[\n\r]+")) + (emms-insert-file track)) + (emms-playlist-sort-by-info-title) + (emms-playlist-sort-by-info-artist) + ;; When writing the playlist, we simulate the current buffer to be + ;; the current playlist, as otherwise `emms-playlist-save' will + ;; ask for confirmation. (emms-playlist-save 'm3u file))) (kill-buffer emms-temp-playlist-buffer)))))))