X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=emus.el;h=7c9071142f94cfc5be1e0bfadf6bf2974b5877f1;hb=8c1e4905386d59218783472327bf549b384c271a;hp=12c57f1d2f3077314b621d63c4bd6807fe92bcb8;hpb=55bcbadba437769330aec82fe1ea4fcb1aacfe28;p=emus.git diff --git a/emus.el b/emus.el index 12c57f1..7c90711 100644 --- a/emus.el +++ b/emus.el @@ -269,7 +269,8 @@ by the filesystem." (setq emus-current-track track) (emus--update-track old-track) (emus--update-track track) - (emus--resume-cp)))) + (emus--resume-cp) + (emus-goto-current)))) (defun emus-select-track (track) "Set TRACK as current, but do not start playing." @@ -280,7 +281,8 @@ by the filesystem." (emus--update-track old-track) (emus--update-track track) (emus-send-cmd "o") - (emus--resume-cp)))) + (emus--resume-cp) + (emus-goto-current)))) (defun emus-stop () "Stop playback of the current track." @@ -431,7 +433,8 @@ and thus requires both artist and album headers." (let* ((artist (emus-track-artist track)) (album (emus-track-album track)) (title (emus-track-title track)) - (help-str (format "mouse-1, RET: Play '%.30s' (%.20s)" title artist))) + (help-str (format "mouse-1, RET: Play '%.30s' (%.20s)" title artist)) + (field (intern album))) ;Allows easy jumping between albums with cursor. (when (or prev-track first) (unless (equal (emus-track-artist prev-track) artist) (insert-text-button @@ -439,16 +442,22 @@ and thus requires both artist and album headers." 'action #'emus--click-track 'follow-link t 'help-echo help-str - 'emus-track track) - (insert (propertize "\n" 'face 'emus-artist))) + 'emus-track track + 'field field) + (insert (propertize "\n" + 'face 'emus-artist + 'field field))) (unless (equal (emus-track-album prev-track) album) (insert-text-button (propertize (concat " " album) 'face 'emus-album) 'action #'emus--click-track 'follow-link t 'help-echo help-str - 'emus-track track) - (insert (propertize "\n" 'face 'emus-album)))) + 'emus-track track + 'field field) + (insert (propertize "\n" + 'face 'emus-album + 'field field)))) (emus-set-track-browser-pos track (point)) (let ((is-current (equal track emus-current-track))) (insert-text-button @@ -468,11 +477,13 @@ and thus requires both artist and album headers." 'action #'emus--click-track 'follow-link t 'help-echo help-str - 'emus-track track) + 'emus-track track + 'field field) (insert (propertize "\n" 'face (if is-current 'emus-track-current - 'emus-track)))))) + 'emus-track) + 'field field))))) (defun emus--update-track (track) "Rerender entry for TRACK in emus browser buffer. @@ -508,22 +519,22 @@ Used to update browser display when `emus-current-track' and/or `emus-state' cha (emus-play-track (button-get button 'emus-track)) (emus-display-status)) -(defun emus-centre-current () - "Centre the current track in the browser buffer, if available." +(defun emus-goto-current () + "Move point to the current track in the browser buffer, if available." (interactive) - (when (get-buffer "*emus*") - (when emus-current-track - (goto-char (emus-track-browser-pos emus-current-track)) - (recenter)))) + (when (and (get-buffer "*emus*") + emus-current-track) + (with-current-buffer "*emus*" + (goto-char (emus-track-browser-pos emus-current-track))))) (defun emus-browse () "Switch to *emus* audio library browser." (interactive) (emus--with-library - (switch-to-buffer "*emus*") + (pop-to-buffer "*emus*") (emus-browser-mode) (emus--render-tracks) - (emus-centre-current))) + (emus-goto-current))) (defun emus-refresh () "Refresh the emus library." @@ -596,10 +607,10 @@ Used to update browser display when `emus-current-track' and/or `emus-state' cha (emus-jump-10s-backward) (emus-display-status)) -(defun emus-centre-current-status () - "Jump 10s backward in current track, then display the emus status in the minibuffer." +(defun emus-goto-current-status () + "Move point to the current track, then display the emus status in the minibuffer." (interactive) - (emus-centre-current) + (emus-goto-current) (emus-display-status)) (defun emus-refresh-status () @@ -625,7 +636,7 @@ Used to update browser display when `emus-current-track' and/or `emus-state' cha (define-key map (kbd "P") 'emus-play-prev-album-status) (define-key map (kbd ",") 'emus-jump-10s-backward-status) (define-key map (kbd ".") 'emus-jump-10s-forward-status) - (define-key map (kbd "c") 'emus-centre-current-status) + (define-key map (kbd "c") 'emus-goto-current-status) (when (fboundp 'evil-define-key*) (evil-define-key* 'motion map (kbd "SPC") 'emus-playpause-status @@ -640,7 +651,7 @@ Used to update browser display when `emus-current-track' and/or `emus-state' cha (kbd "P") 'emus-play-prev-album-status (kbd ",") 'emus-jump-10s-backward-status (kbd ".") 'emus-jump-10s-forward-status - (kbd "c") 'emus-centre-current-status)) + (kbd "c") 'emus-goto-current-status)) map) "Keymap for emus browser.")