branch: externals/mpdired
commit 3164aaa44dcaa032d84dd8605209be78a6e75033
Author: Manuel Giraud <man...@ledu-giraud.fr>
Commit: Manuel Giraud <man...@ledu-giraud.fr>

    go to current song command
---
 mpdired.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mpdired.el b/mpdired.el
index a4196914fe..aa696c7838 100644
--- a/mpdired.el
+++ b/mpdired.el
@@ -108,6 +108,7 @@
   "p"                       #'mpdired-previous-line
   "C-m"                     #'mpdired-enter
   "^"                       #'mpdired-goto-parent
+  "."                       #'mpdired-goto-current-song
   "o"                       #'mpdired-toggle-view
   ;; Actions
   "<remap> <revert-buffer>" #'mpdired-update
@@ -338,6 +339,8 @@
   "Communication buffer associated to this MPDired buffer.")
 (defvar-local mpdired--status nil
   "Local copy of the MPD status.  It will updated regularly.")
+(defvar-local mpdired--current-song nil
+  "Local copy of the current song ID.")
 (defvar-local mpdired--error nil)
 
 ;; I have tried to use markers here but since I often erase the
@@ -522,7 +525,9 @@ used for mark followed by a space."
                   (eol (line-end-position))
                   (x (/ (* elapsed (- eol bol)) duration)))
              (when (> eol (+ bol x))
-               (put-text-property (+ bol x) eol 'face 'mpdired-progress)))))
+               (put-text-property (+ bol x) eol 'face 'mpdired-progress)))
+           ;; Save current song id
+           (setq mpdired--current-song songid)))
        ;; Go to bol no matter what
        (goto-char (mpdired--bol))
        ;; Restore point and memorize stuff
@@ -876,6 +881,13 @@ SEPARATOR string."
           (mpdired-listall-internal parent t))
          (t (message "You are at the toplevel.")))))
 
+(defun mpdired-goto-current-song ()
+  "In the queue view, goes to the line of the currently playing song."
+  (interactive)
+  (when mpdired--current-song
+    (goto-char (point-min))
+    (mpdired--goto-id mpdired--current-song)))
+
 (defun mpdired-toggle-view ()
   "Toggles between the browser and the queue view."
   (interactive)

Reply via email to