aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-18 16:00:11 -0500
committerCraig Jennings <c@cjennings.net>2026-07-18 16:00:11 -0500
commitd2742cead6539aa343fe2564fd8753ce2671345f (patch)
tree0f546a6f2a634b139d2cc53808d2326de32242a1
parent18dbd316ef55bed3418bd94407426f18ef1b01a0 (diff)
downloaddotemacs-d2742cead6539aa343fe2564fd8753ce2671345f.tar.gz
dotemacs-d2742cead6539aa343fe2564fd8753ce2671345f.zip
fix(music): unstick arrows and number placement at the playlist top
The playlist header is a multi-line overlay string anchored at buffer position 1. With point on the top row, next-line's visual motion stepped through the header's screen lines. Those all map back to position 1, so arrows never moved point. The buffer now moves by logical lines (each row is one), which skips the header display entirely. The same shared anchor put row 1's number above the header instead of beside its track: both overlay strings sit at position 1 and the number rendered first. Number overlays now outrank the header's priority, so the number lands next to its own row.
-rw-r--r--modules/music-config.el13
-rw-r--r--tests/test-music-config--renumber-rows.el27
2 files changed, 39 insertions, 1 deletions
diff --git a/modules/music-config.el b/modules/music-config.el
index e9f7c2bb..10aa1019 100644
--- a/modules/music-config.el
+++ b/modules/music-config.el
@@ -394,6 +394,11 @@ debounce timer can outlive the playlist buffer."
(let ((ov (make-overlay (line-beginning-position)
(1+ (line-beginning-position)))))
(overlay-put ov 'cj-music-row-number t)
+ ;; Outrank the header overlay (priority 100): both anchor
+ ;; strings at position 1 on row 1, and without this the
+ ;; row's number renders above the header block instead of
+ ;; beside its own track.
+ (overlay-put ov 'priority 200)
;; The cursor property makes redisplay draw the cursor ON
;; the number when point sits at the row start; without it
;; the cursor lands after the before-string, on the
@@ -460,7 +465,13 @@ inserts or kills into one renumber pass."
;; album art (pairs with the row-number prefixes).
(hl-line-mode 1)
;; Gutter cursor: point lives at the row start (the number column).
- (add-hook 'post-command-hook #'cj/music--pin-point-to-bol nil t))
+ (add-hook 'post-command-hook #'cj/music--pin-point-to-bol nil t)
+ ;; Logical-line motion: the multi-line header overlay string at
+ ;; position 1 otherwise absorbs next-line from the top row (vertical
+ ;; motion walks the header's screen lines, which all map back to the
+ ;; same buffer position, so arrows look dead). Rows are one logical
+ ;; line each; visual movement buys nothing here.
+ (setq-local line-move-visual nil))
(cj/music--renumber-rows buffer)
;; Set this as the current EMMS playlist buffer
(setq emms-playlist-buffer buffer)
diff --git a/tests/test-music-config--renumber-rows.el b/tests/test-music-config--renumber-rows.el
index 656bbfc9..a5304606 100644
--- a/tests/test-music-config--renumber-rows.el
+++ b/tests/test-music-config--renumber-rows.el
@@ -83,6 +83,33 @@ can fire after the playlist buffer is gone)."
(kill-buffer buf)
(should-not (cj/music--renumber-rows buf))))
+(ert-deftest test-music-renumber-rows-number-outranks-header-overlay ()
+ "Normal: number overlays carry a priority above the header overlay's 100.
+The header block is a same-position overlay string at the buffer start;
+without the higher priority, row 1's number renders above the header
+instead of next to its own track."
+ (with-temp-buffer
+ (insert "track one\n")
+ (cj/music--renumber-rows (current-buffer))
+ (let ((ov (car (seq-filter (lambda (o) (overlay-get o 'cj-music-row-number))
+ (overlays-in (point-min) (point-max))))))
+ (should (> (or (overlay-get ov 'priority) 0) 100)))))
+
+(ert-deftest test-music-ensure-playlist-buffer-logical-line-motion ()
+ "Normal: the playlist moves by logical lines, not screen lines. The
+multi-line header overlay string at position 1 otherwise absorbs every
+next-line from the top row -- vertical motion steps through the header's
+display and maps back to the same buffer position, so arrows look dead."
+ (let (created)
+ (cl-letf (((symbol-function 'emms-playlist-mode) #'ignore))
+ (unwind-protect
+ (progn
+ (setq created (cj/music--ensure-playlist-buffer))
+ (with-current-buffer created
+ (should (local-variable-p 'line-move-visual))
+ (should-not line-move-visual)))
+ (when (buffer-live-p created) (kill-buffer created))))))
+
;;; Current-row indicator
(ert-deftest test-music-highlight-current-number-marks-current-row ()