From 2eb4f321a46888dad9fb35996e5d081db1a71517 Mon Sep 17 00:00:00 2001 From: forcer Date: Tue, 13 Sep 2005 02:06:00 +0000 Subject: Keep the selected song correct for shuffling and sorting darcs-hash:20050913020638-2189f-293bdbd2dd6e836d9348adac36e4f67b2a5c751b.gz --- emms.el | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'emms.el') diff --git a/emms.el b/emms.el index f19756e..60595e7 100644 --- a/emms.el +++ b/emms.el @@ -307,8 +307,19 @@ This uses `emms-shuffle-function'." This is a suitable value for `emms-shuffle-function'." (interactive) (with-current-emms-playlist - (emms-playlist-shuffle (point-min) - (point-max)))) + (let ((current nil)) + (when emms-player-playing-p + (setq current (emms-playlist-selected-track)) + (goto-char emms-playlist-selected-marker) + (emms-playlist-kill-track)) + (emms-playlist-shuffle (point-min) + (point-max)) + (if emms-player-playing-p + (progn + (goto-char (point-min)) + (emms-playlist-insert-track current)) + (emms-playlist-first))) + (goto-char (point-max)))) (defun emms-sort () "Sort the current playlist. @@ -321,8 +332,16 @@ This uses `emms-shuffle-function'." This is a suitable value for `emms-sort-function'." (interactive) (with-current-emms-playlist - (emms-playlist-sort (point-min) - (point-max)))) + (let ((current (emms-playlist-selected-track))) + (emms-playlist-sort (point-min) + (point-max)) + (let ((pos (text-property-any (point-min) + (point-max) + 'emms-track current))) + (if pos + (emms-playlist-select pos) + (emms-playlist-first)))) + (goto-char (point-max)))) (defun emms-toggle-repeat-playlist () "Toggle whether emms repeats the playlist after it is done. -- cgit v1.2.3