From f982f37d69871612e2fba1e61cf24d1cb72193bb Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Wed, 24 Feb 2021 13:58:43 +0100 Subject: [PATCH] Use relative file names when updating playlist This is the documented behavior, the previous usage of absolute file names was a mistake. --- site-lisp/db-music.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/site-lisp/db-music.el b/site-lisp/db-music.el index 397189d..2adabf9 100644 --- a/site-lisp/db-music.el +++ b/site-lisp/db-music.el @@ -201,7 +201,18 @@ OVERWRITE is non-nil." ;; the current playlist, as otherwise `emms-playlist-save' will ;; ask for confirmation. (emms-playlist-save 'm3u file))) - (kill-buffer emms-temp-playlist-buffer))))))) + (kill-buffer emms-temp-playlist-buffer) + + ;; Convert absolute file names to relative file names + (with-current-buffer (or (find-buffer-visiting file) + (find-file-noselect file)) + ;; Make sure the current buffer is up to date with the file on + ;; disk, in case it had been visited before + (revert-buffer 'ignore-auto 'noconfirm) + (goto-char (point-min)) + (while (re-search-forward "^.+$" nil 'noerror) + (replace-match (file-relative-name (match-string 0)))) + (save-buffer)))))))) (defun db/update-playlist-files () "Update personal playlist files."