;;; Browser
;;
-(defun emus-insert-record (record &optional pref-record)
- (emus-set-record-browser-pos record (point))
- (let ((current (equal record emus-current-record)))
- (insert-text-button
- (concat
- (if current
- (pcase emus-state
- ('playing (propertize ">" 'face 'bold))
- ('paused (propertize ")" 'face 'bold))
- ('stopped (propertize "]" 'face 'bold)))
- (propertize " " 'face 'default))
- (propertize (format "%-20.20s" (emus-record-artist record))
- 'face 'emus-artist)
- (propertize (format "% -20.20s" (emus-record-album record))
- 'face 'emus-album)
- (propertize (format " %s" (emus-record-title record))
- 'face 'emus-title))
- 'action #'emus-click-record
- 'follow-link t
- 'emus-record record))
+(defun emus-insert-record (record &optional prev-record first)
+ (let ((artist (emus-record-artist record))
+ (album (emus-record-album record))
+ (title (emus-record-title record)))
+ (when (or prev-record first)
+ (unless (equal (emus-record-artist prev-record) artist)
+ (insert-text-button
+ (propertize artist 'face 'emus-artist)
+ 'action #'emus-click-record
+ 'follow-link t
+ 'emus-record record)
+ (insert "\n"))
+ (unless (equal (emus-record-album prev-record) album)
+ (insert-text-button
+ (propertize (concat " " album) 'face 'emus-album)
+ 'action #'emus-click-record
+ 'follow-link t
+ 'emus-record record)
+ (insert "\n")))
+ (emus-set-record-browser-pos record (point))
+ (let ((is-current (equal record emus-current-record)))
+ (insert-text-button
+ (concat
+ (if is-current
+ (pcase emus-state
+ ('playing (propertize ">" 'face 'bold))
+ ('paused (propertize ")" 'face 'bold))
+ ('stopped (propertize "]" 'face 'bold)))
+ (propertize " " 'face 'default))
+ (propertize (format " %s" title)
+ 'face 'emus-title))
+ 'action #'emus-click-record
+ 'follow-link t
+ 'emus-record record)))
(insert "\n"))
(defun emus-update-record (record)
(let ((inhibit-read-only t))
(erase-buffer)
(goto-char (point-min))
- (dolist (record emus-records)
- (emus-insert-record record))))))
+ (let ((prev-record nil))
+ (dolist (record emus-records)
+ (emus-insert-record record prev-record (not prev-record))
+ (setq prev-record record)))))))
(defun emus-click-record (button)
(emus-play-record (button-get button 'emus-record)))