Open igorcafe opened 2 weeks ago
after some hours of curiosity I found something that works at least for me
(let* ((song-path (emms-track-name
(emms-playlist-current-selected-track)))
(outline-name (when (string-match ".*/\\(.*\\)\\.m4a" song-path)
(match-string 1 song-path)))
(outline-marker (org-find-exact-headline-in-buffer outline-name)))
(when outline-marker
(goto-char outline-marker)))
this is probably pretty bad code, since i don't know lisp in general nor emacs lisp
Now it only works when I execute it inside music.org buffer.
I'll make some research but that seems to be easy to fix
it works :D
(defun my/org-music-jump-to-current-song ()
(interactive)
(find-file "~/Sync/Org/music.org")
(let* ((song-path (emms-track-name
(emms-playlist-current-selected-track)))
(outline-name (when (string-match ".*/\\(.*\\)\\.m4a" song-path)
(match-string 1 song-path)))
(outline-marker (org-find-exact-headline-in-buffer outline-name)))
(when outline-marker
(goto-char outline-marker))))
any suggestions are very welcome
Nice idea, glad you found a solution! Code looks good. 1 minor modification would be to re-use org-music-file
variable, so the function generalizes better. Something like below:
(defun org-music-jump-to-current-song ()
"Jump to the Org headline of the currently playing song in Emms."
(interactive)
(let ((music-file org-music-file))
(if (file-exists-p music-file)
(progn
(find-file music-file)
(let* ((song-path (emms-track-name
(emms-playlist-current-selected-track)))
(outline-name (when (and song-path
(string-match ".*/\\(.*\\)\\.m4a" song-path))
(match-string 1 song-path)))
(outline-marker (and outline-name
(org-find-exact-headline-in-buffer outline-name))))
(if outline-marker
(goto-char outline-marker)
(message "Song '%s' not found in Org file." outline-name))))
(message "Music file '%s' does not exist." music-file))))
My use case is that I listen to songs randomly, and I would like to add a rating to them as they play.
Currently what I do is check the name of the song and open my music.org, search for it and then rate it.
If it's not too complicated it would be very useful to have that feature!