aboutsummaryrefslogtreecommitdiff
path: root/emms-playlist-mode.el
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2006-11-19 05:22:00 +0000
committerMichael Olson <mwolson@gnu.org>2006-11-19 05:22:00 +0000
commit89dfb1711522d10f8af645caca40663c1f8c6ac8 (patch)
treef28e0d6be65f7586ef26f5847a3a90963f6fa9ab /emms-playlist-mode.el
parentb19d65da017e9a95fd018bf1c205f5d18b95ce8f (diff)
emms-playlist-mode: Implement adding the thing at point to the current playlist. If it is a playlist, add its contents instead. Map this to the "a" key.
darcs-hash:20061119052254-1bfb2-46e03e36bd085c65c8ba9704a7c7eca29717b653.gz
Diffstat (limited to 'emms-playlist-mode.el')
-rw-r--r--emms-playlist-mode.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/emms-playlist-mode.el b/emms-playlist-mode.el
index e3ae807..03ed563 100644
--- a/emms-playlist-mode.el
+++ b/emms-playlist-mode.el
@@ -125,6 +125,7 @@ This is true for every invocation of `emms-playlist-mode-go'."
(define-key map (kbd "M-y") 'emms-playlist-mode-yank-pop)
(define-key map (kbd "M-<") 'emms-playlist-mode-first)
(define-key map (kbd "M->") 'emms-playlist-mode-last)
+ (define-key map (kbd "a") 'emms-playlist-mode-add-contents)
(define-key map (kbd "d") 'emms-playlist-mode-kill-entire-track)
(define-key map (kbd "n") 'emms-next)
(define-key map (kbd "p") 'emms-previous)
@@ -255,6 +256,48 @@ function switches back to the remembered buffer."
(emms-with-inhibit-read-only-t
(undo)))
+(defun emms-playlist-mode-add-contents ()
+ "Add files in the playlist at point to the current playlist buffer.
+
+If we are in the current playlist, make a new playlist buffer and
+set it as current."
+ (interactive)
+ (save-excursion
+ (emms-move-beginning-of-line nil)
+ (let* ((track (emms-playlist-track-at))
+ (name (emms-track-get track 'name))
+ (type (emms-track-get track 'type))
+ (playlist-p (or (eq type 'playlist)
+ (and (eq type 'file)
+ (save-match-data
+ (string-match "\\.\\(m3u\\|pls\\)\\'"
+ name))))))
+ (emms-playlist-select (point))
+ (unless (and (buffer-live-p emms-playlist-buffer)
+ (not (eq (current-buffer) emms-playlist-buffer)))
+ (setq emms-playlist-buffer
+ (emms-playlist-set-playlist-buffer (emms-playlist-new))))
+ (with-current-emms-playlist
+ (goto-char (point-max))
+ (when playlist-p
+ (insert (emms-track-description track) "\n"))
+ (let ((beg (point)))
+ (if playlist-p
+ (emms-add-playlist name)
+ (let ((func (intern (concat "emms-add-" (symbol-name type)))))
+ (if (functionp func)
+ (funcall func name)
+ ;; fallback
+ (emms-add-file name))))
+ (when playlist-p
+ (goto-char (point-max))
+ (while (progn
+ (forward-line -1)
+ (>= (point) beg))
+ (insert " ")))
+ (goto-char (point-min))
+ (message "Added %s" (symbol-name type)))))))
+
;;; --------------------------------------------------------
;;; Killing and yanking
;;; --------------------------------------------------------