I want to evaluate some elisp with batch mode, but it only works in a certain (type-of) buffer. Specifically

emacsclient --eval "(emms-playlist-mode-play-smart)"

This command only works on an emms-playlist-mode buffer, so I'd like it to locate one in the current emacs server and execute there.

  • emacsclient --eval "(with-current-buffer \"your buffer name\" (emms-playlist-mode-play-smart))" should work. Maybe, you need (get-buffer-create \"...\") instead of \"your buffer name\".
    – Tobias
    May 23 '16 at 9:22
  • This was helpful, as it prompted me to find a way to bring the playlist "to the front" before calling functions on it. In this case it was emacsclient --eval "(emms-browser)" --eval "(emms-browse-by-album)" --eval "(emms-browser-goto-random)" --eval "(emms-browser-add-tracks-and-play)". Now EMMS works with my macbook's media buttons! May 23 '16 at 16:37
  • Nice to read that you solved your problem. You should add your solution and accept it. This marks the question as solved. Thanks.
    – Tobias
    May 23 '16 at 16:48
  • I will, but I'll wait and see if anyone wants to post a more general solution and get free internet points for it :) May 23 '16 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.