From 89dfb1711522d10f8af645caca40663c1f8c6ac8 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sun, 19 Nov 2006 05:22:00 +0000 Subject: 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 --- emms-playlist-mode.el | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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 ;;; -------------------------------------------------------- -- cgit v1.2.3