branch: externals/listen
commit e797d95b86f22c05e7f8e4ba9095d1de37dfb951
Author: Adam Porter <a...@alphapapa.net>
Commit: Adam Porter <a...@alphapapa.net>

    Add: (listen-complete-files) And use in listen-queue-add-files
---
 README.org      |  1 +
 docs/README.org |  1 +
 listen-queue.el | 24 +++++++++++++++++-------
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index 3b2cd74a8c..89f1a062b3 100644
--- a/README.org
+++ b/README.org
@@ -227,6 +227,7 @@ The ~listen-mode~ minor mode runs a timer which plays the 
next track in the curr
 
 *Additions*
 - [[https://mpv.io/][MPV]] support.
+- Command ~listen-queue-add-tracks~, when used in a Dired buffer, uses the 
marked files or the one at point.
 - Option ~listen-backend~, which sets the backend to use: MPV or VLC.  (The 
default is to auto-detect which is available at load time, with MPV being 
preferred due to more robust IPC support.)
 - Faces for parts of mode line lighter.
 
diff --git a/docs/README.org b/docs/README.org
index 8e91e78aca..fbb983b7d7 100644
--- a/docs/README.org
+++ b/docs/README.org
@@ -239,6 +239,7 @@ The ~listen-mode~ minor mode runs a timer which plays the 
next track in the curr
 
 *Additions*
 + [[https://mpv.io/][MPV]] support.
++ Command ~listen-queue-add-tracks~, when used in a Dired buffer, uses the 
marked files or the one at point.
 + Option ~listen-backend~, which sets the backend to use: MPV or VLC.  (The 
default is to auto-detect which is available at load time, with MPV being 
preferred due to more robust IPC support.)
 + Faces for parts of mode line lighter.
 
diff --git a/listen-queue.el b/listen-queue.el
index 6d225c1799..4c1e49b6a9 100644
--- a/listen-queue.el
+++ b/listen-queue.el
@@ -438,16 +438,26 @@ which see."
   (interactive (list (listen-queue-complete :prompt "Discard queue: ")))
   (cl-callf2 delete queue listen-queues))
 
+(defun listen-complete-files ()
+  ;; FIXME: Use this function in more places as appropriate.
+  "Return files selected with completion.
+In a Dired buffer, use `dired-get-marked-files'."
+  (declare-function dired-get-marked-files "dired")
+  (cl-case major-mode
+    (dired-mode (dired-get-marked-files))
+    (otherwise (let ((path (expand-file-name (read-file-name "Enqueue 
file/directory: "
+                                                             listen-directory 
nil t))))
+                 (if (file-directory-p path)
+                     (directory-files-recursively path ".")
+                   (list path))))))
+
 ;;;###autoload
 (cl-defun listen-queue-add-files (files queue)
-  "Add FILES to QUEUE."
+  "Add FILES to QUEUE.
+Completes files with `listen-complete-files', which see."
   (interactive
-   (let ((queue (listen-queue-complete :allow-new-p t))
-         (path (expand-file-name (read-file-name "Enqueue file/directory: " 
listen-directory nil t))))
-     (list (if (file-directory-p path)
-               (directory-files-recursively path ".")
-             (list path))
-           queue)))
+   (let ((queue (listen-queue-complete :allow-new-p t)))
+     (list (listen-complete-files) queue)))
   (cl-callf append (listen-queue-tracks queue) (listen-queue-tracks-for files))
   (listen-queue queue)
   queue)

Reply via email to