aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorforcer <forcer>2005-09-16 00:33:00 +0000
committerforcer <mwolson@gnu.org>2005-09-16 00:33:00 +0000
commite7854c9b8b16ee118b5c7aca640f482a339d1cec (patch)
tree5d0756655863377af35ccca7cc238b6ffc1844c2
parent079e9b43cb95ff95649a06e8949e35fdef5a7647 (diff)
Fix emms-playlist-new and make emms-playlist-clear use it.
darcs-hash:20050916003331-2189f-e450098f69ebd1acf9605479ea9f760fd17d3caf.gz
-rw-r--r--emms.el35
1 files changed, 19 insertions, 16 deletions
diff --git a/emms.el b/emms.el
index 64881e6..bf0189c 100644
--- a/emms.el
+++ b/emms.el
@@ -410,30 +410,33 @@ Otherwise, return the type and the name with a colon in between."
(setq emms-playlist-buffer (or (get-buffer buffer)
(current-buffer))))
-(defun emms-playlist-new ()
- "Create a new playlist buffer."
+(defun emms-playlist-new (&optional name)
+ "Create a new playlist buffer.
+The buffer is named NAME, but made unique. NAME defaults to
+`emms-playlist-buffer-name'.
+If called interactively, the new buffer is also selected."
(interactive)
- (let ((buf (get-buffer emms-playlist-buffer-name)))
- (when buf
- (with-current-buffer buf
- (rename-buffer (generate-new-buffer-name emms-playlist-buffer-name))))
- (emms-playlist-clear)))
+ (let ((buf (generate-new-buffer (or name
+ emms-playlist-buffer-name))))
+ (with-current-buffer buf
+ (when (not (eq major-mode emms-playlist-default-major-mode))
+ (funcall emms-playlist-default-major-mode))
+ (setq emms-playlist-buffer-p t))
+ (when (called-interactively-p)
+ (switch-to-buffer buf))
+ buf))
(defun emms-playlist-clear ()
"Clear the current playlist.
-If a buffer named `emms-playlist-buffer-name' exists, this is
-used, and the contents removed."
- (let ((buf (get-buffer-create emms-playlist-buffer-name)))
- (with-current-buffer buf
+If no playlist exists, a new one is generated."
+ (if (not emms-playlist-buffer)
+ (setq emms-playlist-buffer (emms-playlist-new))
+ (with-current-buffer emms-playlist-buffer
(let ((inhibit-read-only t))
(widen)
(delete-region (point-min)
(point-max)))
- (when (not (eq major-mode emms-playlist-default-major-mode))
- (funcall emms-playlist-default-major-mode))
- (setq emms-playlist-buffer-p t)
- (run-hooks 'emms-playlist-cleared-hook))
- (setq emms-playlist-buffer buf)))
+ (run-hooks 'emms-playlist-cleared-hook))))
(defmacro with-current-emms-playlist (&rest body)
"Run BODY with the current buffer being the current playlist buffer."