Function: mpc--faster

mpc--faster is an interactive and byte-compiled function defined in mpc.el.gz.

Signature

(mpc--faster EVENT SPEEDUP STEP)

Documentation

Fast forward.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc--faster (event speedup step)
  "Fast forward."
  (interactive (list last-nonmenu-event))
  (let ((repeat-delay (/ (abs (float step)) speedup)))
    (if (not (memq 'down (event-modifiers event)))
        (let* ((currenttime (float-time))
               (last-time (- currenttime (car mpc-last-seek-time))))
          (if (< last-time (* 0.9 repeat-delay))
              nil ;; Throttle
            (let* ((status (if (< last-time 1.0)
                               mpc-status (mpc-cmd-status)))
                   (songid (cdr (assq 'songid status)))
                   (time (if songid
                             (if (< last-time 1.0)
                                 (cdr mpc-last-seek-time)
                               (string-to-number
                                (cdr (assq 'time status)))))))
              (setq mpc-last-seek-time
                    (cons currenttime (setq time (+ time step))))
              (mpc-proc-cmd (list "seekid" songid time)
                            #'mpc-status-refresh))))
      (let ((status (mpc-cmd-status)))
        (let* ((songid (cdr (assq 'songid status)))
                       (time (if songid (string-to-number
                                         (cdr (assq 'time status))))))
          (let ((timer (run-with-timer
                        t repeat-delay
                        (lambda ()
                          (mpc-proc-cmd (list "seekid" songid
                                              (setq time (+ time step)))
                                        #'mpc-status-refresh)))))
            (while (mouse-movement-p
                    (event-basic-type (setq event (read-event)))))
            (cancel-timer timer)))))))