emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7587534: New command mpc-goto-playing-song


From: Stefan Kangas
Subject: master 7587534: New command mpc-goto-playing-song
Date: Wed, 29 Sep 2021 19:18:51 -0400 (EDT)

branch: master
commit 758753431af51f7ac79a55d426b915443e66a077
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    New command mpc-goto-playing-song
    
    * 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    |  5 +++++
 lisp/mpc.el | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 0c5a100..25164d5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3026,6 +3026,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.
 
diff --git a/lisp/mpc.el b/lisp/mpc.el
index c7ae08b..9131464 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]