]> git.eshelyaron.com Git - emacs.git/commitdiff
New command mpc-goto-playing-song
authorStefan Kangas <stefan@marxist.se>
Wed, 29 Sep 2021 23:17:24 +0000 (01:17 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 29 Sep 2021 23:17:53 +0000 (01:17 +0200)
* lisp/mpc.el (mpc-goto-playing-song): New command to go to the
currently playing song.
(mpc-mode-map): Bind it to "o".

etc/NEWS
lisp/mpc.el

index 0c5a1004e7fe243238c3c15baff1360499b0da1f..25164d536422b4b50ca2e327b3f67252ce729156 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3025,6 +3025,11 @@ See 'rcirc-reconnect-attempts'.
 
 ** MPC
 
+---
+*** New command 'mpc-goto-playing-song'.
+This command, bound to 'o' in any 'mpc-mode' buffer, moves point to
+the currently playing song in the "*Songs*" buffer.
+
 ---
 *** New user option 'mpc-cover-image-re'.
 If non-nil, it is a regexp that should match a valid cover image.
index c7ae08baee1219a0d793d54251cdcbcf4e6deb05..913146415e81f05f7247db748b98c1b327e755c3 100644 (file)
@@ -1150,6 +1150,7 @@ If PLAYLIST is t or nil or missing, use the main playlist."
     (define-key map ">" #'mpc-next)
     (define-key map "<" #'mpc-prev)
     (define-key map "g" #'mpc-seek-current)
+    (define-key map "o" #'mpc-goto-playing-song)
     map))
 
 (easy-menu-define mpc-mode-menu mpc-mode-map
@@ -2670,6 +2671,18 @@ If stopped, start playback."
   (mpc-select event)
   (mpc-play))
 
+(defun mpc-goto-playing-song ()
+  "Move point to the currently playing song in the \"*Songs*\" buffer."
+  (interactive)
+  (let* ((buf (mpc-proc-buffer (mpc-proc) 'songs))
+         (win (get-buffer-window buf)))
+    (when (and (buffer-live-p buf) win)
+      (select-window win)
+      (with-current-buffer buf
+        (when (and overlay-arrow-position
+                   (eq (marker-buffer overlay-arrow-position) buf))
+          (goto-char (marker-position overlay-arrow-position)))))))
+
 ;; (defun mpc-play-tagval ()
 ;;   "Play all the songs of the tag at point."
 ;;   (interactive)