Here's some code that I've been using that allows me to select a
playlist from an EMMS buffer, load it into a new buffer when I hit
"l", and switch back to the previous EMMS buffer when I hit "q".

I thought code was committed that could create and keep track of
multiple EMMS buffers, but I can't seem to find it.

(defvar my-emms-playlist-stack nil)

;; Load the playlist into a new EMMS buffer, saving the old one
(defun my-emms-playlist-load-playlist ()
  (interactive)
  (let* ((track (emms-playlist-track-at))
         (name (emms-track-get track 'name))
         (type (emms-track-get track 'type)))
    (emms-playlist-select (point))
    (sit-for 0)
    (run-hooks 'emms-player-stopped-hook)
    (when (or (eq type 'playlist)
              (string-match "\\.\\(m3u\\|pls\\)\\'" name))
      (setq my-emms-playlist-stack (cons emms-playlist-buffer
                                         my-emms-playlist-stack))
      (switch-to-buffer (setq emms-playlist-buffer (emms-playlist-new)))
      (emms-add-m3u-playlist name))))

;; Remove the current EMMS playlist and set the old one as current
(defun my-emms-playlist-destroy-playlist ()
  (interactive)
  (when (buffer-live-p emms-playlist-buffer)
    (with-current-buffer emms-playlist-buffer
      (emms-playlist-clear)))
  (let ((old emms-playlist-buffer)
        (new (car my-emms-playlist-stack)))
    (setq my-emms-playlist-stack (cdr my-emms-playlist-stack))
    (if (buffer-live-p new)
        (progn
          (setq emms-playlist-buffer new)
          (switch-to-buffer emms-playlist-buffer)
          (kill-buffer old))
      (bury-buffer))))

(define-key emms-playlist-mode-map "l" 'my-emms-playlist-load-playlist)
(define-key emms-playlist-mode-map "q" 'my-emms-playlist-destroy-playlist)

-- 
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: manga, Debian, XHTML, wiki, Emacs Lisp
  /` |\ | | | IRC: mwolson on freenode.net: #hcoop, #muse, #PurdueLUG
 |_] | \| |_| Jabber: mwolson_at_hcoop.net

Attachment: pgpSM7WGNpwmd.pgp
Description: PGP signature

_______________________________________________
Emms-help mailing list
Emms-help@gnu.org
http://lists.gnu.org/mailman/listinfo/emms-help

Reply via email to