emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/listen 2ac2eed1fd 082/103: Add: (listen-queue-shell-com


From: ELPA Syncer
Subject: [elpa] externals/listen 2ac2eed1fd 082/103: Add: (listen-queue-shell-command)
Date: Mon, 26 Feb 2024 12:59:32 -0500 (EST)

branch: externals/listen
commit 2ac2eed1fd1f78f7dbc37bd6846d3e1146c6090e
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: (listen-queue-shell-command)
---
 README.org      |  1 +
 listen-queue.el | 39 ++++++++++++++++++++++++++++++++++++++-
 listen.info     |  6 ++++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index 210730f08b..52a109fe9b 100644
--- a/README.org
+++ b/README.org
@@ -53,6 +53,7 @@ Use the command ~listen~ to show the Transient menu.  From 
there, it is--hopeful
 
 *Additions*
 + Command ~listen-queue-jump~ jumps to the currently playing track in the 
queue.
++ Command ~listen-queue-shell-command~ runs a shell command on the tracks 
selected in the queue.
 
 *Fixes*
 + The queue could sometimes skip tracks when playing.
diff --git a/listen-queue.el b/listen-queue.el
index 22a95dc562..9875f30a99 100644
--- a/listen-queue.el
+++ b/listen-queue.el
@@ -129,7 +129,8 @@
                           "RET" (lambda (track) (listen-queue-play queue 
track))
                           "SPC" (lambda (_) (call-interactively 
#'listen-pause))
                           "o" (lambda (_) (call-interactively 
#'listen-queue-order-by))
-                          "s" (lambda (_) (listen-queue-shuffle 
listen-queue)))))
+                          "s" (lambda (_) (listen-queue-shuffle listen-queue))
+                          "!" (lambda (_) (call-interactively 
#'listen-queue-shell-command)))))
         (goto-char (point-min))
         (listen-queue--highlight-current)
         (hl-line-mode 1)))
@@ -340,6 +341,29 @@ PROMPT is passed to `format-prompt', which see."
   (seq-elt (listen-queue-tracks queue)
            (1+ (seq-position (listen-queue-tracks queue)
                              (listen-queue-current queue)))))
+(declare-function listen-shell-command "listen")
+(defun listen-queue-shell-command (command filenames)
+  "Run COMMAND on FILENAMES.
+Interactively, read COMMAND and use tracks at point in current
+queue buffer."
+  (interactive
+   (let* ((filenames (mapcar #'listen-track-filename (listen-queue-selected)))
+          (command (read-shell-command (format "Run command on %S: " 
filenames))))
+     (list command filenames)))
+  (listen-shell-command command filenames)
+  ;; NOTE: This code below would be great but for using async shell
+  ;; command in `listen-shell-command'.  Also, if the files end up
+  ;; renamed, they'll not be found, but that's up to the user.
+  ;; (seq-do (lambda (filename)
+  ;;           (setf (seq-elt (listen-queue-tracks listen-queue)
+  ;;                          (seq-position (listen-queue-tracks listen-queue) 
filename
+  ;;                                        (lambda (track)
+  ;;                                          (equal filename 
(listen-track-filename track)))))
+  ;;                 (listen-queue-track filename)))
+  ;;         filenames)
+  ;; (listen-queue-revert)
+  )
+
 
 (defun listen-queue-order-by ()
   "Order the queue by the column at point.
@@ -358,6 +382,19 @@ tracks in the queue unchanged)."
                    do (forward-line 1))))
   (vtable-revert-command))
 
+(defun listen-queue-selected ()
+  "Return tracks selected in current queue buffer."
+  (cl-assert listen-queue)
+  (if (not (region-active-p))
+      (vtable-current-object)
+    (let ((beg (region-beginning))
+          (end (region-end)))
+      (save-excursion
+        (goto-char beg)
+        (cl-loop collect (vtable-current-object)
+                 do (forward-line 1)
+                 while (<= (point) end))))))
+
 ;;;;; Bookmark support
 
 (require 'bookmark)
diff --git a/listen.info b/listen.info
index 4bdc8ca4f7..b9ab917ba0 100644
--- a/listen.info
+++ b/listen.info
@@ -115,6 +115,8 @@ File: README.info,  Node: v02-pre,  Next: v01,  Up: 
Changelog
 *Additions*
    • Command ‘listen-queue-jump’ jumps to the currently playing track in
      the queue.
+   • Command ‘listen-queue-shell-command’ runs a shell command on the
+     tracks selected in the queue.
 
    *Fixes*
    • The queue could sometimes skip tracks when playing.
@@ -149,8 +151,8 @@ Node: Configuration2537
 Node: Usage2876
 Node: Changelog3147
 Node: v02-pre3299
-Node: v013570
-Node: Development3672
+Node: v013681
+Node: Development3783
 
 End Tag Table
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]