-(defun emus-render-record (record)
- (insert-text-button
- (concat
- (propertize (format "%-20.20s" (emus-record-artist record))
- 'face 'font-lock-keyword-face)
- (propertize (format "% -20.20s" (emus-record-album record))
- 'face 'font-lock-function-name-face)
- (propertize (format " %s" (emus-record-title record))
- 'face 'font-lock-string-face))
- 'action #'emus-click-record
- 'follow-link t
- 'emus-record record)
- (insert "\n"))
-
-(defun emus-render-records ()
+(defun emus--insert-track (track &optional prev-track first)
+ (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)))
+ (when (or prev-track first)
+ (unless (equal (emus-track-artist prev-track) artist)
+ (insert-text-button
+ (propertize artist 'face 'emus-artist)
+ 'action #'emus--click-track
+ 'follow-link t
+ 'help-echo help-str
+ 'emus-track track)
+ (insert (propertize "\n" 'face 'emus-artist)))
+ (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-set-track-browser-pos track (point))
+ (let ((is-current (equal track emus-current-track)))
+ (insert-text-button
+ (concat
+ (if is-current
+ (propertize
+ (pcase emus-state
+ ('playing "->")
+ ('paused "-)")
+ ('stopped "-]"))
+ 'face 'emus-cursor)
+ (propertize " " 'face 'default))
+ (propertize (format " %s" title)
+ 'face (if is-current
+ 'emus-track-current
+ 'emus-track)))
+ 'action #'emus--click-track
+ 'follow-link t
+ 'help-echo help-str
+ 'emus-track track)
+ (insert (propertize "\n"
+ 'face (if is-current
+ 'emus-track-current
+ 'emus-track))))))
+
+(defun emus--update-track (track)
+ (let ((track-pos (emus-track-browser-pos track)))
+ (when (and (get-buffer "*emus*")
+ (emus-track-browser-pos track))
+ (with-current-buffer "*emus*"
+ (let ((inhibit-read-only t)
+ (old-point (point)))
+ (goto-char track-pos)
+ (search-forward "\n")
+ (delete-region track-pos (point))
+ (goto-char track-pos)
+ (emus--insert-track track)
+ (goto-char old-point))))))
+
+(defun emus--render-tracks ()