summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-06-02 11:11:43 +0800
committerJSDurand <mmemmew@gmail.com>2022-06-02 11:11:43 +0800
commitdb93f123cbe162d30b6a6204cf184ad20ec56a15 (patch)
tree9954040d93e6f11e3a35668c698d28f00c2e723e
parentb6af39c85308452d1debca91d076a19e12fbf706 (diff)
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.
-rw-r--r--bongo.el36
1 files changed, 36 insertions, 0 deletions
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)