Hello EMMS developers,

I have written a function to jump to the currently playing EMMS song but
I have noticed that the callback is not always called when syncing from
MPD. Here is my code:

(defun cae-emms-jump-to-currently-playing-track (&rest args)
  (let ((track (emms-track-get
                (emms-playlist-current-selected-track) 'name)))
    (if (and track args)
        (dired-jump nil track)
      (message "No song is currently selected.")
      (transient-setup 'cae-emms-quick-access))))

;; TODO PR something so that the callback always runs to EMMS even when tracks 
is nil.
(defadvice! cae-emms-handle-jump-to-playing-track-a (closure tracks)
  :after #'emms-player-mpd-sync-from-mpd-1
  (when (and (not tracks)
             (eq (cadr closure) #'cae-emms-jump-to-currently-playing-track))
    (funcall (cadr closure))))

;;;###autoload (autoload 'cae-emms-quick-access 
"cae/misc-applications/autoload/emms" nil t)
(transient-define-prefix cae-emms-quick-access ()
  "Jump to EMMS music directories."
  ["Quick Access"
   [("v" "VGM"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "VGM" cae-misc-applications-music-dir))))
    ("y" "Youtube Music"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "Youtube Music" 
cae-misc-applications-music-dir))))
    ("p" "Playlists"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "Playlists" cae-misc-applications-music-dir))))
    ("a" "Anime Music"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "Anime Music" 
cae-misc-applications-music-dir))))
    ("r" "Artists"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "Artists" emms-source-file-default-directory))))
    ("l" "Longplays"
     (lambda () (interactive)
       (require 'emms)
       (dired (expand-file-name "Longplays" 
emms-source-file-default-directory))))
    ("j" "Currently playing"
     (lambda () (interactive)
       (require 'emms)
       (if (executable-find "mpd")
           (emms-player-mpd-sync-from-mpd nil 
#'cae-emms-jump-to-currently-playing-track)
         (funcall #'cae-emms-jump-to-currently-playing-track))))]])

Could we make it so that emms-player-mpd-sync-from-mpd-1 calls the
callback even if tracks is nil? I think this would be a good change.

Sincerely,
StrawberryTea

Reply via email to