fix(mu4e): cursor offset +1 for mu4e mark indicator at line start

This commit is contained in:
2026-02-24 11:25:19 +01:00
parent 2bead842b6
commit 7888259a5f

View File

@@ -649,16 +649,17 @@ and optional priority indicator [#A]."
("/personal/Archive" . ?a)))
;; Cursor on subject column after j/k navigation
(defun my/mu4e-goto-subject (&rest _)
"Move cursor to the subject column in mu4e headers."
"Move cursor to the subject column in mu4e headers.
Accounts for mu4e's 1-char mark indicator at the start of each line."
(when (derived-mode-p 'mu4e-headers-mode)
(beginning-of-line)
(let ((offset 0))
(let ((offset 1)) ; 1 = mu4e mark indicator (space or *)
(catch 'found
(dolist (field mu4e-headers-fields)
(if (eq (car field) :subject)
(throw 'found nil)
(setq offset (+ offset (or (cdr field) 0) 1)))))
(forward-char offset))))
(forward-char (min offset (- (line-end-position) (point)))))))
(advice-add 'mu4e-headers-next :after #'my/mu4e-goto-subject)
(advice-add 'mu4e-headers-prev :after #'my/mu4e-goto-subject))