fix(mu4e): search-based subject cursor + zT thread toggle binding
This commit is contained in:
28
config.el
28
config.el
@@ -649,19 +649,25 @@ 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.
|
||||
Accounts for mu4e's 1-char mark indicator at the start of each line."
|
||||
"Move cursor to the start of the subject text in a mu4e headers line.
|
||||
Uses the actual subject string from the message rather than column arithmetic,
|
||||
which is unreliable with unicode flags and thread-prefix strings."
|
||||
(when (derived-mode-p 'mu4e-headers-mode)
|
||||
(beginning-of-line)
|
||||
(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 (min offset (- (line-end-position) (point)))))))
|
||||
(let* ((msg (mu4e-message-at-point t))
|
||||
(subject (when msg (mu4e-message-field msg :subject))))
|
||||
(when (and subject (> (length subject) 0))
|
||||
(beginning-of-line)
|
||||
;; Search for up to the first 10 chars of the subject on this line.
|
||||
;; Avoids false matches while tolerating mu4e truncation.
|
||||
(let ((needle (substring subject 0 (min 10 (length subject)))))
|
||||
(when (search-forward needle (line-end-position) t)
|
||||
(goto-char (match-beginning 0))))))))
|
||||
(advice-add 'mu4e-headers-next :after #'my/mu4e-goto-subject)
|
||||
(advice-add 'mu4e-headers-prev :after #'my/mu4e-goto-subject))
|
||||
(advice-add 'mu4e-headers-prev :after #'my/mu4e-goto-subject)
|
||||
|
||||
;; zT = toggle thread view on/off (T alone marks thread for bulk action)
|
||||
(evil-define-key 'normal mu4e-headers-mode-map
|
||||
(kbd "zT") #'mu4e-headers-toggle-threading))
|
||||
|
||||
(after! mu4e
|
||||
(setq sendmail-program "msmtp"
|
||||
|
||||
Reference in New Issue
Block a user