emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emms-help] Loading saved playlists in a new EMMS buffer


From: Michael Olson
Subject: [emms-help] Loading saved playlists in a new EMMS buffer
Date: Wed, 04 Jan 2006 18:36:42 -0500
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

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: pgpdp7u1qDro7.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]