[Top][All Lists]

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

[emms-help] Making emms-playlist-mode play nice with emms-browser

From: Michael Olson
Subject: [emms-help] Making emms-playlist-mode play nice with emms-browser
Date: Wed, 01 Nov 2006 23:27:22 -0500
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux)

Some of the tracks that I have ripped to my system from CD lack a
track number, due to forgetting to pass one option to oggenc in my CD
ripper of choice.  Since I use emms-browser now, and emms-browser
inevitably lists these tracks out of order in an album, this is a bit

Rather than fix the problem by adding the metadata to all tracks that
it's missing from, I thought about ways of working around the problem.
I came up with the following set of functions and keybindings that
allows me to add these errant albums to an existing emms-browser
playlist by using emms-playlist-mode.  It could stand on its own, as
well, as an easy way of picking albums when you have a playlist file
for each album (which most good CD rippers generate by default).

The idea is to browse an open emms-browser-generated playlist and hit
`C-c m a' to set it as the "accumulation" buffer.  From that point on,
browse to an emms-playlist-mode buffer, hit `a' on a file or playlist,
and it will get added to the end of the designated "accumulation"
buffer.  If the accumulation buffer has not been set, make a new one,
add track or playlist contents to it, and designate it for future

Shall I add this to emms-playlist-mode?

;; Add files in the playlist at point to an accumulation buffer
(defvar my-emms-accumulation-buffer nil)

(defun my-emms-playlist-add-contents ()
    (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)
                                  (string-match "\\.\\(m3u\\|pls\\)\\'"
      (emms-playlist-select (point))
      (unless (and my-emms-accumulation-buffer
                   (buffer-live-p my-emms-accumulation-buffer))
        (setq my-emms-accumulation-buffer
              (emms-playlist-set-playlist-buffer (emms-playlist-new))))
      (setq emms-playlist-buffer my-emms-accumulation-buffer)
        (goto-char (point-max))
        (when playlist-p
          (insert (emms-info-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)))))))

(defun my-emms-set-accumulation-buffer ()
  (setq my-emms-accumulation-buffer (current-buffer))
  (message "Set current buffer for future EMMS track additions"))

(define-key emms-playlist-mode-map "a" 'my-emms-playlist-add-contents)

(global-set-key "\C-cma" 'my-emms-set-accumulation-buffer)

Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: Emacs Lisp, text markup, protocols -- Jabber: mwolson_at_hcoop.net
  /` |\ | | | Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC
 |_] | \| |_| Reclaim your digital rights by eliminating DRM.
      See http://www.defectivebydesign.org/what_is_drm for details.

Attachment: pgpvHt166svbi.pgp
Description: PGP signature

reply via email to

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