From db93f123cbe162d30b6a6204cf184ad20ec56a15 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 2 Jun 2022 11:11:43 +0800 Subject: bongo: add the ability to search and insert * bongo.el ("durand-bongo-search-insert"): Search and insert a song in the playlist buffer. I might try to make a multiple-choices version in the future. --- bongo.el | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bongo.el b/bongo.el index fb26bcc..67c96d6 100644 --- a/bongo.el +++ b/bongo.el @@ -1030,3 +1030,39 @@ TIME must be a list of two to four elements." ;;; Bonmark (use-package "bonmark" 'bonmark) + +;;; search and insert + +(defun durand-bongo-search-insert () + "Search a song and insert it in the playlist buffer." + (interactive) + (let* ((songs + (mapcar + (lambda (file) + (cons + (file-name-nondirectory file) + (file-name-directory file))) + (flatten-tree + (mapcar + (lambda (dir) + (directory-files-recursively + dir + (rx-to-string + '(seq "." (or "mp3" "mkv" "webm" "m4a") eos) + t) + nil nil t)) + durand-bongo-music-dir)))) + (choice + (completing-read + "Search and insert: " songs + nil t)) + (choice + (assoc choice songs #'equal)) + (choice + (expand-file-name + (car choice) + (cdr choice)))) + (bongo-insert-file choice))) + +(define-key bongo-playlist-mode-map (vector ?/) + #'durand-bongo-search-insert) -- cgit v1.2.3-18-g5258