[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ampc bb5ba9b2bb 068/111: * ampc.el: Add ampc-mini, a co
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ampc bb5ba9b2bb 068/111: * ampc.el: Add ampc-mini, a command to select the song to play via |
Date: |
Tue, 20 Feb 2024 18:16:41 -0500 (EST) |
branch: externals/ampc
commit bb5ba9b2bbb2e689ef0fe2cafa36efa0d33b1f24
Author: Christopher Schmidt <christopher@ch.ristopher.com>
Commit: Christopher Schmidt <christopher@ch.ristopher.com>
* ampc.el: Add ampc-mini, a command to select the song to play via
completing-read.
(ampc-mode-map): Bind ampc-mini.
(ampc-send-next-command): For hyphen-seperated commands, only send the last
part
of the command.
(ampc-mini-impl): New function.
(ampc-handle-command): Handle mini-playlistinfo.
(ampc-play-this): Take optional prefix arg to select song to play by index.
(ampc-mini): New command.
---
ampc.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 59 insertions(+), 15 deletions(-)
diff --git a/ampc.el b/ampc.el
index 66d66eabea..04d0c73703 100644
--- a/ampc.el
+++ b/ampc.el
@@ -171,6 +171,7 @@
;;
;; `P' (ampc-goto-current-song): Select the current playlist window and move
;; point to the current song.
+;; `G' (ampc-mini): Select song to play via `completing-read'.
;;
;; `T' (ampc-trigger-update): Trigger a database update.
;; `Z' (ampc-suspend): Suspend ampc.
@@ -385,6 +386,7 @@ all the time!"
(define-key map (kbd "r") 'ampc-toggle-random)
(define-key map (kbd "f") 'ampc-toggle-consume)
(define-key map (kbd "P") 'ampc-goto-current-song)
+ (define-key map (kbd "G") 'ampc-mini)
(define-key map (kbd "q") 'ampc-quit)
(define-key map (kbd "z") 'ampc-suspend)
(define-key map (kbd "T") 'ampc-trigger-update)
@@ -969,13 +971,13 @@ all the time!"
(defun ampc-send-next-command ()
(unless ampc-outstanding-commands
(ampc-send-command 'idle))
- (ampc-send-command-impl (concat (symbol-name (caar
ampc-outstanding-commands))
- (loop for a in
- (cdar ampc-outstanding-commands)
- concat " "
- concat (cond ((integerp a)
- (number-to-string a))
- (t a))))))
+ (ampc-send-command-impl
+ (concat (replace-regexp-in-string
+ "^.*-" "" (symbol-name (caar ampc-outstanding-commands)))
+ (loop for a in (cdar ampc-outstanding-commands)
+ concat " "
+ concat (cond ((integerp a) (number-to-string a))
+ (t a))))))
(defun ampc-tree< (a b)
(string< (car a) (car b)))
@@ -1139,14 +1141,43 @@ all the time!"
`(("outputid" . ,outputid)
("outputenabled" . ,outputenabled))))))))))
+(defun* ampc-mini-impl (&aux songs)
+ (loop with next
+ while (or (when next (goto-char next) t)
+ (search-forward-regexp "^file: " nil t))
+ for entry = (save-restriction
+ (setf next (ampc-narrow-entry))
+ `(,(concat (ampc-extract "Title") " - "
+ (ampc-extract "Artist"))
+ . ,(string-to-number (ampc-extract "Pos"))))
+ do (loop with mentry = `(,(car entry) . ,(cdr entry))
+ for index from 2
+ while (assoc (car mentry) songs)
+ do (setf (car mentry) (concat (car entry)
+ " (" (int-to-string index) ")"))
+ finally do (push mentry songs)))
+ (unless songs
+ (message "No song in the playlist")
+ (return-from ampc-mini-impl))
+ (let ((song (assoc (let ((inhibit-quit t))
+ (prog1
+ (with-local-quit
+ (completing-read "Song to play: " songs nil t))
+ (setf quit-flag nil)))
+ songs)))
+ (when song
+ (ampc-play-this (cdr song)))))
+
(defun* ampc-fill-current-playlist (&aux properties)
(ampc-fill-skeleton 'current-playlist
(setf properties (plist-get (cdr ampc-type) :properties))
(with-current-buffer data-buffer
(loop
- while (search-forward-regexp "^file: " nil t)
+ with next
+ while (or (when next (goto-char next) t)
+ (search-forward-regexp "^file: " nil t))
do (save-restriction
- (ampc-narrow-entry)
+ (setf next (ampc-narrow-entry))
(let ((file (ampc-extract "file"))
(pos (ampc-extract "Pos")))
(ampc-with-buffer 'current-playlist
@@ -1352,6 +1383,8 @@ all the time!"
(ampc-fill-playlists))
(playlistinfo
(ampc-fill-current-playlist))
+ (mini-playlistinfo
+ (ampc-mini-impl))
(listallinfo
(ampc-fill-internal-db nil))
(outputs
@@ -1693,12 +1726,17 @@ otherwise disable it."
(interactive "P")
(ampc-toggle-state 'random arg))
-(defun ampc-play-this ()
- "Play selected song."
- (interactive)
- (assert (ampc-in-ampc-p))
- (unless (eobp)
- (ampc-send-command 'play nil (1- (line-number-at-pos)))
+(defun ampc-play-this (&optional arg)
+ "Play selected song.
+With prefix argument ARG, play the ARG'th song located at the
+zero-indexed position of the current playlist."
+ (interactive "P")
+ (assert (and (ampc-on-p) (or arg (ampc-in-ampc-p))))
+ (if (not arg)
+ (unless (eobp)
+ (ampc-send-command 'play nil (1- (line-number-at-pos)))
+ (ampc-send-command 'pause nil 0))
+ (ampc-send-command 'play nil arg)
(ampc-send-command 'pause nil 0)))
(defun* ampc-toggle-play
@@ -1945,6 +1983,12 @@ This means subsequent startups of ampc will be faster."
(when run-hook
(run-hooks 'ampc-suspend-hook)))
+(defun ampc-mini ()
+ "Select song to play via `completing-read'."
+ (interactive)
+ (assert (ampc-on-p))
+ (ampc-send-command 'mini-playlistinfo t))
+
(defun ampc-quit (&optional arg)
"Quit ampc.
If called with a prefix argument ARG, kill the mpd instance that
- [elpa] externals/ampc 11be30d5c1 096/111: * ampc.el (ampc-send-command): Allow all other keys in PROPS. Store PROPS in, (continued)
- [elpa] externals/ampc 11be30d5c1 096/111: * ampc.el (ampc-send-command): Allow all other keys in PROPS. Store PROPS in, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 26c78cf4a5 108/111: * ampc.el: Fix compilation warnings, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc b89aa28b49 001/111: Initial commit., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc e301604aa0 012/111: Add commentary and code tags., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc ac831c4f29 018/111: Rebuild internal song database if the tag browser change., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 84efcaa16d 044/111: * ampc: Bump version to 0.1.2., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc bdb75f9ab9 051/111: * ampc.el (ampc-mode-map): Add checkboxes to the toggle menu items., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 3c81462de0 058/111: * ampc.el: Add tool-bar., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc c3c36d6a5e 060/111: * ampc.el: Add mouse support., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc f0462f2d8c 061/111: * ampc.el (ampc): Change the name of the internal communication buffer to, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc bb5ba9b2bb 068/111: * ampc.el: Add ampc-mini, a command to select the song to play via,
Stefan Monnier <=
- [elpa] externals/ampc effd06f0d8 072/111: * ampc.el: Add mouse support for playlist commands., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc cd2a3a93a6 074/111: * ampc.el: Doc simplifications., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 0941e8d180 079/111: * ampc.el: Make ampc synchronous., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 2b4cbc7db9 088/111: * ampc.el: Use tab-stop-list for tabulated lists., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 0bf832e424 092/111: * Add tagger. ampc-tagger.cpp: New file., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 5aae56a25d 101/111: * packages/ampc/ampc.el: Add proper file trailer., Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 259d4f6363 103/111: * ampc/ampc.el: Fix up warnings and use cl-lib. Change maintainer, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc e045d5a2fa 102/111: Remove ampc, then re-add, since I cannot find it anywhere else, Stefan Monnier, 2024/02/20
- [elpa] externals/ampc a98412698b 105/111: * ampc/ampc.el (ampc-views): Add "Search view", Stefan Monnier, 2024/02/20
- [elpa] externals/ampc 4a2a2e642f 109/111: ; Prefer HTTPS to HTTP in URLs, Stefan Monnier, 2024/02/20