summaryrefslogtreecommitdiff
path: root/bongo.el
diff options
context:
space:
mode:
Diffstat (limited to 'bongo.el')
-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)