Function: mpc-cmd-move

mpc-cmd-move is a byte-compiled function defined in mpc.el.gz.

Signature

(mpc-cmd-move SONG-POSS DEST-POS &optional PLAYLIST)

Source Code

;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc-cmd-move (song-poss dest-pos &optional playlist)
  (let ((i 0))
    (mpc-proc-cmd
     (mpc-proc-cmd-list
      (mapcar (lambda (song-pos)
                (if (>= song-pos dest-pos)
                    ;; positions past dest-pos have been
                    ;; shifted by i.
                    (setq song-pos (+ song-pos i)))
                (prog1 (if (stringp playlist)
                           (list "playlistmove" playlist song-pos dest-pos)
                         (list "move" song-pos dest-pos))
                  (if (< song-pos dest-pos)
                      ;; This move has shifted dest-pos by 1.
                      (decf dest-pos))
                  (incf i)))
              ;; Sort them from last to first, so the renumbering
              ;; caused by the earlier deletions affect
              ;; later ones a bit less.
              (sort (copy-sequence song-poss) #'>))))
    (if (stringp playlist)
        (puthash (cons 'Playlist playlist) nil mpc--find-memoize))))