~breatheoutbreathein/emacs-simple-mpc-breatheoutbreathein

1331f545d34f2db5245f23fbde1e37031f8d94e6 — Joseph Turner 1 year, 9 months ago bed901a
Use simple-mpc-extract-status to get playlist-position

Replaces simple-mpc-get-current-playlist-position.
2 files changed, 21 insertions(+), 24 deletions(-)

M simple-mpc-current-playlist.el
M simple-mpc-utils.el
M simple-mpc-current-playlist.el => simple-mpc-current-playlist.el +21 -18
@@ 71,24 71,27 @@ IGNORE-AUTO and NOCONFIRM are passed by `revert-buffer'."
        (insert
         (simple-mpc-format-as-table (simple-mpc-call-mpc-string
                                      (append (list "--format" (simple-mpc-get-playlist-format)) '("playlist")))))
        (save-excursion
          (simple-mpc-goto-line (simple-mpc-get-current-playlist-position))
          (put-text-property
           (line-beginning-position) (line-end-position)
           'face 'simple-mpc-current-track-face))
        (if keep-point
            (progn
              (simple-mpc-goto-line original-line)
              (move-to-column original-column)
              (set-window-start nil window-start t)
              (set-window-hscroll nil window-hscroll))
          (simple-mpc-goto-line (simple-mpc-get-current-playlist-position)))
        (switch-to-buffer buf)
        (simple-mpc-mode)
        (simple-mpc-current-playlist-mode)
        (hl-line-mode)
        (when simple-mpc-playlist-auto-refresh
          (simple-mpc-playlist-refresh-timer-start))))))
        (let ((playlist-position 0))
          (when (simple-mpc-extract-status 'playlist-position)
            (setq playlist-position (string-to-number (simple-mpc-extract-status 'playlist-position))))
          (save-excursion
            (simple-mpc-goto-line playlist-position)
            (put-text-property
             (line-beginning-position) (line-end-position)
             'face 'simple-mpc-current-track-face))
          (if keep-point
              (progn
                (simple-mpc-goto-line original-line)
                (move-to-column original-column)
                (set-window-start nil window-start t)
                (set-window-hscroll nil window-hscroll))
            (simple-mpc-goto-line playlist-position))
          (switch-to-buffer buf)
          (simple-mpc-mode)
          (simple-mpc-current-playlist-mode)
          (hl-line-mode)
          (when simple-mpc-playlist-auto-refresh
            (simple-mpc-playlist-refresh-timer-start)))))))

(defun simple-mpc-play-current-line ()
  "Plays the song on the current line."

M simple-mpc-utils.el => simple-mpc-utils.el +0 -6
@@ 100,12 100,6 @@ output as a string."
    (simple-mpc-call-mpc t mpc-args)
    (buffer-string)))

(defun simple-mpc-get-current-playlist-position ()
  "Return the position, as a number, of the current song."
  (with-temp-buffer
    (simple-mpc-call-mpc t '("current" "-f" "%position%"))
    (string-to-number (buffer-string))))

(defun simple-mpc-get-amount-of-songs-in-playlist ()
  "Return the number of songs in the current playlist."
  (with-temp-buffer