aboutsummaryrefslogtreecommitdiff
path: root/emms-streams.el
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2006-07-30 22:02:00 +0000
committerMichael Olson <mwolson@gnu.org>2006-07-30 22:02:00 +0000
commitaa9c184f2e41d831bed2c209112f4299ce27f58a (patch)
treebd0a490c63970c11cc94c2f75933a1c1a4420463 /emms-streams.el
parentab3184047fd4ff9373bacccd8f583674ba738849 (diff)
emms-streams: Don't prompt for fd. Determine it automatically instead.
darcs-hash:20060730220232-1bfb2-788a8edc59ad10890149cadd420b2ec7cf87defc.gz
Diffstat (limited to 'emms-streams.el')
-rw-r--r--emms-streams.el19
1 files 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)