branch: externals/emms
commit a01df752e19458c011dc838bc40a4474728f644e
Author: Yoni Rabkin <[email protected]>
Commit: Yoni Rabkin <[email protected]>
Add active playlist lock, browse and send songs from other playlists.
---
emms-metaplaylist-mode.el | 17 +++++++++---
emms-playlist-mode.el | 9 +++++++
emms.el | 68 ++++++++++++++++++++++++++++++-----------------
3 files changed, 65 insertions(+), 29 deletions(-)
diff --git a/emms-metaplaylist-mode.el b/emms-metaplaylist-mode.el
index c221b7d002..802a8464e8 100644
--- a/emms-metaplaylist-mode.el
+++ b/emms-metaplaylist-mode.el
@@ -85,6 +85,7 @@
(define-key map (kbd "C-k") #'emms-metaplaylist-mode-kill-buffer)
(define-key map (kbd "c") #'emms-metaplaylist-mode-center-current)
(define-key map (kbd "q") #'kill-this-buffer)
+ (define-key map (kbd "v") #'emms-metaplaylist-mode-goto)
(define-key map (kbd "?") #'describe-mode)
map)
"Keymap for `emms-metaplaylist-mode'.")
@@ -99,8 +100,16 @@
(let ((buffer (get-buffer
(buffer-substring (line-beginning-position)
(line-end-position)))))
- (emms-playlist-set-playlist-buffer buffer)
- (switch-to-buffer buffer)))
+ (emms-playlist-set-playlist-buffer buffer)
+ (switch-to-buffer buffer)))
+
+(defun emms-metaplaylist-mode-goto ()
+ "Visit the playlist without making it current."
+ (interactive)
+ (let ((buffer (get-buffer
+ (buffer-substring (line-beginning-position)
+ (line-end-position)))))
+ (switch-to-buffer buffer)))
(defun emms-metaplaylist-mode-write (playlists)
"Print the sorted list of PLAYLISTS."
@@ -122,7 +131,7 @@
(defun emms-metaplaylist-mode-sorted-buffer-list ()
"Return a sorted list of playlist buffers."
(sort
- (copy-tree
+ (copy-tree
(emms-playlist-buffer-list))
#'(lambda (a b)
(string< (buffer-name a)
@@ -202,7 +211,7 @@
(defun emms-metaplaylist-mode-set-active ()
"Set the buffer at point to be the active playlist."
(interactive)
- (emms-playlist-set-playlist-buffer
+ (emms-playlist-set-playlist-buffer
(get-buffer (buffer-substring (line-beginning-position)
(line-end-position))))
(emms-metaplaylist-mode-update))
diff --git a/emms-playlist-mode.el b/emms-playlist-mode.el
index ff57030444..cef9fd15df 100644
--- a/emms-playlist-mode.el
+++ b/emms-playlist-mode.el
@@ -147,6 +147,7 @@ This is true for every invocation of
`emms-playlist-mode-go'."
(define-key map (kbd "d") #'emms-playlist-mode-goto-dired-at-point)
(define-key map (kbd "<mouse-2>") #'emms-playlist-mode-play-current-track)
(define-key map (kbd "RET") #'emms-playlist-mode-play-smart)
+ (define-key map (kbd "i") #'emms-playlist-playlist-insert-track)
map)
"Keymap for `emms-playlist-mode'.")
@@ -543,6 +544,14 @@ When NO-NEWLINE is non-nil, do not insert a newline after
the track."
(unless no-newline
(insert "\n"))))
+(defun emms-playlist-playlist-insert-track ()
+ "Insert the track in playlist at point into the active playlist buffer."
+ (interactive)
+ (let ((track (emms-playlist-track-at)))
+ (with-current-emms-playlist
+ (goto-char (point-max))
+ (emms-playlist-insert-track track))))
+
(defun emms-playlist-mode-update-track-function ()
"Update the track display at point."
(emms-playlist-ensure-playlist-buffer)
diff --git a/emms.el b/emms.el
index 5641b2f804..0fd02241ce 100644
--- a/emms.el
+++ b/emms.el
@@ -829,38 +829,56 @@ for that purpose.")
"Non-nil if the current buffer is an EMMS playlist.")
(make-variable-buffer-local 'emms-playlist-buffer-p)
+(defvar emms-queue-lock nil
+ "The playlist name the active playlist queue is locked to, if any.")
+
(defun emms-playlist-ensure-playlist-buffer ()
"Throw an error if we're not in a playlist-buffer."
(when (not emms-playlist-buffer-p)
(error "Not an EMMS playlist buffer")))
+(defun emms-lock-queue ()
+ "Lock the current active playlist."
+ (interactive)
+ (setq emms-queue-lock (buffer-name emms-playlist-buffer))
+ (message (concat "Active queue playlist is locked to " emms-queue-lock)))
+
+(defun emms-unlock-queue ()
+ "Unlock the current active playlist."
+ (interactive)
+ (setq emms-queue-lock nil)
+ (message "Active queue playlist is unlocked."))
+
(defun emms-playlist-set-playlist-buffer (&optional buffer)
- "Set the current playlist buffer."
+ "Set the current playlist buffer if the queue is not locked to it's
playlist."
(interactive
- (list (let* ((buf-list (mapcar #'(lambda (buf)
- (list (buffer-name buf)))
- (emms-playlist-buffer-list)))
- (sorted-buf-list (sort buf-list
- #'(lambda (lbuf rbuf)
- (< (length (car lbuf))
- (length (car rbuf))))))
- (default (or (and emms-playlist-buffer-p
- ;; default to current buffer
- (buffer-name))
- ;; pick shortest buffer name, since it is
- ;; likely to be a shared prefix
- (car sorted-buf-list))))
- (emms-completing-read "Playlist buffer to make current: "
- sorted-buf-list nil t default))))
- (let ((buf (if buffer
- (get-buffer buffer)
- (current-buffer))))
- (with-current-buffer buf
- (emms-playlist-ensure-playlist-buffer))
- (setq emms-playlist-buffer buf)
- (when (called-interactively-p 'interactive)
- (message "Set current EMMS playlist buffer"))
- buf))
+ (if (not emms-queue-lock)
+ (list (let* ((buf-list (mapcar #'(lambda (buf)
+ (list (buffer-name buf)))
+ (emms-playlist-buffer-list)))
+ (sorted-buf-list (sort buf-list
+ #'(lambda (lbuf rbuf)
+ (< (length (car lbuf))
+ (length (car rbuf))))))
+ (default (or (and emms-playlist-buffer-p
+ ;; default to current buffer
+ (buffer-name))
+ ;; pick shortest buffer name, since it is
+ ;; likely to be a shared prefix
+ (car sorted-buf-list))))
+ (emms-completing-read "Playlist buffer to make current: "
+ sorted-buf-list nil t default)))))
+ (if (not emms-queue-lock)
+ (let ((buf (if buffer
+ (get-buffer buffer)
+ (current-buffer))))
+ (with-current-buffer buf
+ (emms-playlist-ensure-playlist-buffer))
+ (setq emms-playlist-buffer buf)
+ (when (called-interactively-p 'interactive)
+ (message "Set current EMMS playlist buffer"))
+ buf)
+ (message (concat "The active playlist queue is locked to "
emms-queue-lock))))
(defun emms-playlist-new (&optional name)
"Create a new playlist buffer.