diff options
-rw-r--r-- | durand-bongo.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/durand-bongo.el b/durand-bongo.el index 6eded4b..632a79e 100644 --- a/durand-bongo.el +++ b/durand-bongo.el @@ -105,6 +105,24 @@ (setq-default bongo-next-action #'durand-bongo-play-next-or-first) +(defun durand-bongo-next-or-first (&optional n) + "Make the next track current in the nearest playlist buffer. +If there is no next track, go to the first track. +With prefix argument N, skip that many tracks." + (interactive "P") + (if (bongo-playing-p) + (durand-bongo-play-next-or-first n) + (with-bongo-playlist-buffer + (let ((line-move-ignore-invisible nil)) + (save-excursion + (goto-char (or (bongo-point-at-current-track-line) + (bongo-point-at-first-track-line) + (user-error "No tracks in playlist"))) + (dotimes (_dummy (prefix-numeric-value n)) + (goto-char (or (bongo-point-at-next-track-line) + (bongo-point-at-first-track-line)))) + (bongo-set-current-track-position)))))) + (defun durand-bongo-play-next-or-first (&optional n) "Start playing the next track in the nearest Bongo playlist buffer. If there is no next track to play, signal an error. @@ -132,6 +150,24 @@ insert an action track at point." (durand-bongo-next-or-first n) (bongo-start))))) +(defun durand-bongo-previous-or-last (&optional n) + "Make the previous track current in the nearest playlist buffer. +If there is no previous track, go to the last track. +With prefix argument N, skip that many tracks." + (interactive "p") + (if (bongo-playing-p) + (durand-bongo-play-previous-or-last n) + (with-bongo-playlist-buffer + (let ((line-move-ignore-invisible nil)) + (save-excursion + (goto-char (or (bongo-point-at-current-track-line) + (bongo-point-at-last-track-line) + (user-error "No tracks in playlist"))) + (dotimes (_dummy (prefix-numeric-value n)) + (goto-char (or (bongo-point-at-previous-track-line) + (bongo-point-at-last-track-line)))) + (bongo-set-current-track-position)))))) + (defun durand-bongo-play-previous-or-last (&optional n) "Start playing the previous track in the nearest playlist buffer. If there is no previous track to play, play the last track. |