From aa9c184f2e41d831bed2c209112f4299ce27f58a Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sun, 30 Jul 2006 22:02:00 +0000 Subject: emms-streams: Don't prompt for fd. Determine it automatically instead. darcs-hash:20060730220232-1bfb2-788a8edc59ad10890149cadd420b2ec7cf87defc.gz --- emms-streams.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/emms-streams.el b/emms-streams.el index 4c61e07..0d97006 100644 --- a/emms-streams.el +++ b/emms-streams.el @@ -294,11 +294,13 @@ POPUP-HEIGHT is the height of the new frame, defaulting to (defun emms-stream-display-line (line) (insert (emms-stream-name line)) - (add-text-properties (point-at-bol) (point-at-eol) '(face emms-stream-name-face)) + (add-text-properties (point-at-bol) (point-at-eol) + '(face emms-stream-name-face)) (add-text-properties (point-at-bol) (point-at-eol) `(emms-stream ,line)) (insert "\n ") (insert (emms-stream-url line)) - (add-text-properties (point-at-bol) (point-at-eol) '(face emms-stream-url-face)) + (add-text-properties (point-at-bol) (point-at-eol) + '(face emms-stream-url-face)) (insert "\n")) (defun emms-stream-display () @@ -358,6 +360,16 @@ Positions are counted starting with 0." (goto-char (point-min)) (emms-stream-display))) +(defun emms-stream-determine-fd (name) + "Return a feed descriptor, given NAME. +This is the count of the times NAME appears in the bookmark list, +plus one." + (let ((count 1)) + (dolist (feed emms-stream-list) + (when (string= (emms-stream-name feed) name) + (setq count (1+ count)))) + count)) + (defun emms-stream-add-bookmark (name url fd type) "Creates a new bookmark, and inserts it at point position. @@ -366,10 +378,11 @@ Don't forget to run `emms-stream-save-bookmarks-file' after !" (list (read-string "Name of the bookmark: ") (read-string "URL: ") - (string-to-number (read-string "Feed descriptor (use 1 if unsure): ")) + nil (completing-read "Type (url or streamlist): " (mapcar #'list '("url" "streamlist"))))) + (unless fd (setq fd (emms-stream-determine-fd name))) (let* ((line (emms-line-number-at-pos (point))) (index (+ (/ line 2) 1))) (setq emms-stream-list (emms-stream-insert-at index (list name url fd type) -- cgit v1.2.3