emms-patches
[Top][All Lists]
Advanced

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

[Emms-patches] darcs patch: Make handling of multiple playlist buffers l


From: Michael Olson
Subject: [Emms-patches] darcs patch: Make handling of multiple playlist buffers less error-...
Date: Wed, 31 May 2006 23:02:08 -0400

Wed May 31 16:38:10 EDT 2006  Michael Olson <address@hidden>
  * Make handling of multiple playlist buffers less error-prone.
New patches:

[Make handling of multiple playlist buffers less error-prone.
Michael Olson <address@hidden>**20060531203810] {
hunk ./emms-playlist-mode.el 443
-    (switch-to-buffer (setq emms-playlist-buffer (emms-playlist-new)))
+    (switch-to-buffer
+     (emms-playlist-set-playlist-buffer (emms-playlist-new)))
hunk ./emms-streams.el 86
-(defvar emms-stream-owns-buffer nil
-  "Indicate whether the current EMMS playlist buffer is owned by
-emms-streams.")
-(make-variable-buffer-local 'emms-stream-owns-buffer)
+(defvar emms-stream-playlist-buffer nil
+  "The EMMS playlist buffer associated with emms-streams.")
hunk ./emms-streams.el 175
-    (save-excursion
-      (with-current-buffer (setq emms-playlist-buffer (emms-playlist-new))
-        (setq emms-stream-owns-buffer t))))
+    (emms-stream-create-playlist))
hunk ./emms-streams.el 197
+(defun emms-stream-create-playlist ()
+  "Create a new EMMS playlist and associate it with emms-streams.
+This is used when `emms-stream-default-action' is \"play\"."
+  (save-excursion
+    (setq emms-stream-playlist-buffer
+          (emms-playlist-set-playlist-buffer (emms-playlist-new)))))
+
+(defun emms-stream-kill-playlist ()
+  "Delete the EMMS playlist associated with emms-streams, if one exists."
+  (when (buffer-live-p emms-stream-playlist-buffer)
+    (save-excursion
+      (if (eq emms-stream-playlist-buffer emms-playlist-buffer)
+          (emms-playlist-current-kill)
+        (kill-buffer emms-stream-playlist-buffer)))
+    (setq emms-stream-playlist-buffer nil)))
+
hunk ./emms-streams.el 511
-  (save-excursion
-    (when (and (buffer-live-p emms-playlist-buffer)
-               (with-current-emms-playlist emms-stream-owns-buffer))
-      (emms-stop)
-      (emms-playlist-current-kill)))
+  (emms-stream-kill-playlist)
hunk ./emms-streams.el 519
+        (emms-stream-kill-playlist)
hunk ./emms-streams.el 522
+    (emms-stream-create-playlist)
hunk ./emms.el 428
+(defun emms-delete-if (predicate seq)
+  "Remove all items satisfying PREDICATE in SEQ.
+This is a destructive function: it reuses the storage of SEQ
+whenever possible."
+  ;; remove from car
+  (while (when (funcall predicate (car seq))
+           (setq seq (cdr seq))))
+  ;; remove from cdr
+  (let ((ptr seq)
+        (next (cdr seq)))
+    (while next
+      (when (funcall predicate (car next))
+        (setcdr ptr (if (consp next)
+                        (cdr next)
+                      nil)))
+      (setq ptr (cdr ptr))
+      (setq next (cdr ptr))))
+  seq)
+
hunk ./emms.el 510
+(defvar emms-playlist-buffers nil
+  "The list of EMMS playlist buffers.
+You should use the `emms-playlist-buffer-list' function to
+retrieve a current list of EMMS buffers.  Never use this variable
+for that purpose.")
+
hunk ./emms.el 566
+    (add-to-list 'emms-playlist-buffers buf)
hunk ./emms.el 573
-The first element will be the most recently-created playlist, and
-so on."
-  (let ((lis nil))
-    (mapc (lambda (buf)
-           (with-current-buffer buf
-             (when emms-playlist-buffer-p
-               (setq lis (cons buf lis)))))
-         (buffer-list))
-    (nreverse lis)))
+The first element is guaranteed to be the current EMMS playlist
+buffer, if it exists, otherwise the slot will be used for the
+other EMMS buffers.  The list will be in newest-first order."
+  ;; prune dead buffers
+  (setq emms-playlist-buffers (emms-delete-if (lambda (buf)
+                                                (not (buffer-live-p buf)))
+                                              emms-playlist-buffers))
+  ;; add new buffers
+  (mapc (lambda (buf)
+          (when (buffer-live-p buf)
+            (with-current-buffer buf
+              (when (and emms-playlist-buffer-p
+                         (not (memq buf emms-playlist-buffers)))
+                (setq emms-playlist-buffers
+                      (cons buf emms-playlist-buffers))))))
+        (buffer-list))
+  ;; force current playlist buffer to head position
+  (when (and (buffer-live-p emms-playlist-buffer)
+             (not (eq (car emms-playlist-buffers) emms-playlist-buffer)))
+    (setq emms-playlist-buffers (cons emms-playlist-buffer
+                                      (delete emms-playlist-buffer
+                                              emms-playlist-buffers))))
+  emms-playlist-buffers)
hunk ./emms.el 600
-  (let ((new (cadr (emms-playlist-buffer-list))))
-    (if (buffer-live-p new)
-        (progn
-          (when (buffer-live-p emms-playlist-buffer)
-            (kill-buffer emms-playlist-buffer))
-          (setq emms-playlist-buffer new)
-          (switch-to-buffer emms-playlist-buffer))
-      (with-current-buffer emms-playlist-buffer
-        (bury-buffer)))))
+  (when (buffer-live-p emms-playlist-buffer)
+    (let ((new (cadr (emms-playlist-buffer-list))))
+      (if new
+          (let ((old emms-playlist-buffer))
+            (setq emms-playlist-buffer new
+                  emms-playlist-buffers (cdr emms-playlist-buffers))
+            (kill-buffer old)
+            (switch-to-buffer emms-playlist-buffer))
+        (with-current-buffer emms-playlist-buffer
+          (bury-buffer))))))
}

Context:

[AUTHORS: Add Martin Schoenmakers. Welcome! :-)
address@hidden 
[Add emms-volume and emms-volume-amixer.
Martin Schoenmakers <address@hidden>**20060530223500
 
 New files: emms-volume.el provides some general volume changing things,
 including a minor mode to more easily change volume when not in the
 EMMS buffer. emms-volume-amixer.el is a backend using amixer.
 
] 
[emms-streams: Re-add space after prompt and use completion for type.
Michael Olson <address@hidden>**20060530190620] 
[allow nonzero ogginfo exit plus some reindenting
Martin Schoenmakers <address@hidden>**20060530130411
 
 When ogginfo gave a nonzero value on exit, any valid data would get tossed
 if there was any. This prevented emms from showing info for files that are
 tagged but a bit odd.
 
 Also reindented emms-info-ogginfo accordingly, which incidentally removed
 some tabs in favour of spaces.
 
] 
[emms-streams: When the user wants emms-streams to play the selected stream 
instead of add it, create our own playlist buffer.  When quitting, if we own 
the current playlist buffer, kill it.
Michael Olson <address@hidden>**20060530144243] 
[emms-streams: Re-implement yank and kill so that they do the right thing with 
emms-stream-list.
Michael Olson <address@hidden>**20060530045429] 
[emms-streams: Implement kill and yank.
Michael Olson <address@hidden>**20060530040114] 
[emms-streams: Make hitting RET on a URL do the right thing, improve cursor 
movement, and mark the buffer as unmodified after performing a save.
Michael Olson <address@hidden>**20060529030043] 
[emms-player-mpd: Use more robust method of detecting whether we need to 
force-feed MusicPD our playlist.
Michael Olson <address@hidden>**20060525014253] 
[emms-playlist-mode: Make "d" kill the entire line.  This seems to be a good 
compromise of those who use C-k and those who want more standard object-killing 
behavior.
foo**20060524200008] 
[emms-player-mpd: When showing the currently-playing song, prepend the name of 
the radio station, if it exists.
foo**20060524195911] 
[emms-player-mpd: Make seek work correctly.
Michael Olson <address@hidden>**20060525033120] 
[emms-player-mpd: Fix bug that caused unconditional reloading of the entire 
MusicPD playlist whenever the track was changed manually.
Michael Olson <address@hidden>**20060524061655] 
[emms-player-mpd: Overhaul for streamlist support, and fix a few miscellaneous 
issues.
Michael Olson <address@hidden>**20060524055707] 
[emms-player-mpd: Add a few checks to make sure that the given buffer exists 
before trying to do anything with it.
Michael Olson <address@hidden>**20060517035419] 
[emms-source-playlist: Do not expand names of files in playlists, as this can 
cause problems with emms-player-mpd in some configurations.
Michael Olson <address@hidden>**20060516081257] 
[emms-playlist-mode: Implement the option (disabled by default) of opening a 
new EMMS buffer for a playlist, when hitting RET on one.
Michael Olson <address@hidden>**20060510040730] 
[emms-playlist-mode.el: Don't put a period after the mode map. This hangs 21.4 
on display.
address@hidden 
[TAG 2.0
address@hidden 
Patch bundle hash:
83108d1c8d620832c95d5ac032e0daaaef15d55a

reply via email to

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