emms-help
[Top][All Lists]
Advanced

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

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


From: Michael Olson
Subject: [emms-help] Re: Making emms-playlist-mode play nice with emms-browser
Date: Fri, 03 Nov 2006 21:24:44 -0500
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux)

Michael Olson <address@hidden> writes:

> On second thought, instead of making a separate variable to hold the
> accumulation buffer, maybe we should just use emms-playlist-buffer.
> If the buffer we are currently visiting is current, and we hit 'a',
> it would create a new buffer and make it current.  Otherwise it
> would just add tracks to the current buffer.
>
> Then we'd also need some sort of keybinding that sets
> emms-playlist-buffer to the current buuffer, to allow the user to
> select where the added tracks should go.

Here's another version, with those changes, and with valid
keybindings for EMMS.

;; Add files in the playlist at point to the current playlist buffer
(defun my-emms-playlist-add-contents ()
  (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-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)))))))

;; Set the current EMMS playlist buffer
(defun my-emms-set-playlist-buffer ()
  (interactive)
  (if emms-playlist-buffer-p
      (progn
        (setq emms-playlist-buffer (current-buffer))
        (message "Set current EMMS playlist buffer"))
    (message "This is not an EMMS playlist buffer")))

;;; Key customizations

(define-key emms-playlist-mode-map "a" 'my-emms-playlist-add-contents)
(define-key emms-playlist-mode-map "C" 'my-emms-set-playlist-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: pgpyMTajtKgU2.pgp
Description: PGP signature


reply via email to

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