diff options
Diffstat (limited to 'bongo.el')
-rw-r--r-- | bongo.el | 59 |
1 files changed, 39 insertions, 20 deletions
@@ -186,26 +186,7 @@ Adapted from Protesilaos' dotemacs by Durand." (playlist (directory-files path t dotless))) (with-bongo-playlist-buffer (bongo-insert-playlist-contents - (completing-read "Select playlist: " playlist nil t path)) - ;; (ivy-read "Choose a playlist file: " playlist - ;; :require-match t - ;; :caller 'durand-bongo-insert-delete-playlist - ;; :action '(1 - ;; ("i" bongo-insert-playlist-contents "insert playlist") - ;; ("d" (lambda (file) - ;; (delete-file file) - ;; (setf (ivy-state-collection ivy-last) - ;; (directory-files - ;; (file-name-as-directory - ;; (expand-file-name - ;; "playlists" - ;; bongo-default-directory)) - ;; t directory-files-no-dot-files-regexp)) - ;; (ivy--reset-state ivy-last)) - ;; "delete playlist") - ;; ("e" find-file "edit"))) - ;; (prot/bongo-play-random) - ))) + (completing-read "Select playlist: " playlist nil t path))))) ;;;###autoload ;; (defun durand-bongo-dired-ivy-find-to-add () @@ -714,6 +695,44 @@ Afterwards just stop the annoying timer." 'mpv)) (durand-bongo-seek-start-timer bongo-player))))) +;;; replace names in playlist files + +(defun durand-bongo-replace-name-in-playlist-files (old new) + "Replace names in the playlist files containing OLD by the name in \ +NEW subdirectory. +If one moves songs containing the string NAME to the subdirectory +NAME in its original directory, where NAME is the name of the +singer, then running this function with parameters both equal to NAME +will do the right renaming." + (interactive "sOld name: \nsNew name: ") + (let ((files (directory-files + (expand-file-name + "playlists" bongo-default-directory) + nil "m3u$" t))) + (mapc + (lambda (file) + (with-temp-buffer + (insert-file-contents file) + (goto-char (point-min)) + (cond + ((save-excursion (re-search-forward old nil t)) + (while (re-search-forward old nil t) + (let* ((file-name + (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + (expanded + (expand-file-name + (file-name-nondirectory file-name) + (expand-file-name + new (file-name-directory file-name)))) + (po (line-beginning-position))) + (delete-region (line-beginning-position) (line-end-position)) + (goto-char po) + (insert expanded) + (goto-char (+ po (length expanded))))) + (write-region nil nil file))))) + files))) + ;; Normally we should do this, but I override the function by my ;; custom function, so I can just call this function there. |