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)))
|
("/personal/Archive" . ?a)))
|
||||||
;; Cursor on subject column after j/k navigation
|
;; Cursor on subject column after j/k navigation
|
||||||
(defun my/mu4e-goto-subject (&rest _)
|
(defun my/mu4e-goto-subject (&rest _)
|
||||||
"Move cursor to the subject column in mu4e headers.
|
"Move cursor to the start of the subject text in a mu4e headers line.
|
||||||
Accounts for mu4e's 1-char mark indicator at the start of each 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)
|
(when (derived-mode-p 'mu4e-headers-mode)
|
||||||
(beginning-of-line)
|
(let* ((msg (mu4e-message-at-point t))
|
||||||
(let ((offset 1)) ; 1 = mu4e mark indicator (space or *)
|
(subject (when msg (mu4e-message-field msg :subject))))
|
||||||
(catch 'found
|
(when (and subject (> (length subject) 0))
|
||||||
(dolist (field mu4e-headers-fields)
|
(beginning-of-line)
|
||||||
(if (eq (car field) :subject)
|
;; Search for up to the first 10 chars of the subject on this line.
|
||||||
(throw 'found nil)
|
;; Avoids false matches while tolerating mu4e truncation.
|
||||||
(setq offset (+ offset (or (cdr field) 0) 1)))))
|
(let ((needle (substring subject 0 (min 10 (length subject)))))
|
||||||
(forward-char (min offset (- (line-end-position) (point)))))))
|
(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-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
|
(after! mu4e
|
||||||
(setq sendmail-program "msmtp"
|
(setq sendmail-program "msmtp"
|
||||||
|
|||||||
Reference in New Issue
Block a user