diff options
-rw-r--r-- | emms-streams.el | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/emms-streams.el b/emms-streams.el index a0214d7..8676d64 100644 --- a/emms-streams.el +++ b/emms-streams.el @@ -249,12 +249,21 @@ POPUP-HEIGHT is the height of the new frame, defaulting to (defun emms-stream-save-bookmarks-file () (interactive) - (let ((buffer (find-file-noselect emms-stream-bookmarks-file))) - (set-buffer buffer) - (erase-buffer) - (prin1 emms-stream-list buffer) - (save-buffer) - (kill-buffer buffer))) + (save-excursion + (let ((buffer (find-file-noselect emms-stream-bookmarks-file))) + (set-buffer buffer) + (erase-buffer) + (insert "(") + (let ((firstp t)) + (dolist (stream emms-stream-list) + (if (not firstp) + (insert "\n ") + (setq firstp nil)) + (prin1 stream buffer))) + (insert ")\n") + (save-buffer) + (kill-buffer buffer))) + (set-buffer-modified-p nil)) (defun emms-stream-display-line (line) (insert (emms-stream-name line)) @@ -352,7 +361,16 @@ Don't forget to save your modifications !" (defun emms-stream-play () (interactive) - (let* ((line (get-text-property (point) 'emms-stream)) + (let* ((line (or (get-text-property (point) 'emms-stream) + (progn + (goto-char (or (previous-single-property-change + (point) 'emms-stream) + (point-min))) + (goto-char (or (previous-single-property-change + (point) 'emms-stream) + (point-min))) + (get-text-property (point) 'emms-stream)) + (error "No stream found at point"))) (name (emms-stream-name line)) (url (emms-stream-url line)) (fd (emms-stream-fd line)) @@ -378,11 +396,26 @@ Don't forget to save your modifications !" ;; Navigation (defun emms-stream-next-line () (interactive) - (forward-line 2)) + (when (get-text-property (point) 'emms-stream) + (goto-char (or (next-single-property-change (point) 'emms-stream) + (point-max)))) + (goto-char (or (next-single-property-change (point) 'emms-stream) + (point-max))) + (forward-line 0)) (defun emms-stream-previous-line () (interactive) - (forward-line -2)) + (unless (get-text-property (point) 'emms-stream) + (goto-char (or (previous-single-property-change (point) 'emms-stream) + (point-min))) + (goto-char (or (previous-single-property-change (point) 'emms-stream) + (point-min)))) + (when (get-text-property (point) 'emms-stream) + (goto-char (or (previous-single-property-change (point) 'emms-stream) + (point-min)))) + (goto-char (or (previous-single-property-change (point) 'emms-stream) + (point-min))) + (forward-line 0)) (defun emms-stream-quit () (interactive) |