mu4e/thread: only when available

Fixes #2479.
This commit is contained in:
Dirk-Jan C. Binnema
2023-05-04 00:01:30 +03:00
parent c01ea37abf
commit ada6ff6260
3 changed files with 34 additions and 15 deletions

View File

@ -868,8 +868,11 @@ after the end of the search results."
mu4e--search-msgid-target nil) mu4e--search-msgid-target nil)
(when (mu4e~headers-docid-at-point) (when (mu4e~headers-docid-at-point)
(mu4e~headers-highlight (mu4e~headers-docid-at-point))))) (mu4e~headers-highlight (mu4e~headers-docid-at-point)))))
;; run-hooks ;; maybe enable thread folding
(run-hooks 'mu4e-headers-found-hook)) (when mu4e-search-threads
(mu4e-thread-mode))
;; run-hooks
(run-hooks 'mu4e-headers-found-hook))
;;; Marking ;;; Marking
@ -932,12 +935,6 @@ after the end of the search results."
(define-key map (kbd "<C-kp-subtract>") (define-key map (kbd "<C-kp-subtract>")
#'mu4e-headers-split-view-shrink) #'mu4e-headers-split-view-shrink)
;; threads
(define-key map (kbd "<S-left>") #'mu4e-thread-goto-root)
(define-key map (kbd "<tab>") #'mu4e-thread-fold-toggle-goto-next)
(define-key map (kbd "<C-tab>") #'mu4e-thread-fold-toggle-goto-next)
(define-key map (kbd "<backtab>") #'mu4e-thread-fold-toggle-all)
;; switching to view mode (if it's visible) ;; switching to view mode (if it's visible)
(define-key map "y" #'mu4e-select-other-view) (define-key map "y" #'mu4e-select-other-view)

View File

@ -32,10 +32,14 @@
;; Similarly, when a thread has marked messages, the folding stops at the first ;; Similarly, when a thread has marked messages, the folding stops at the first
;; marked message. ;; marked message.
;; Note, you can only use these functions when threads are available, roughly
;; when `mu4e-search-threads' in non-nil.
;;; Usage example: ;;; Usage example:
;; ;;
;; This enforces folding after a new search ;; After a search, mu4e-thread-mode will be enable when threads
;; (add-hook 'mu4e-headers-found-hook #'mu4e-thread-fold-apply-all) ;; are available; so, to automatically sort them:
;; (add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-apply-all)
;;; Code: ;;; Code:
@ -273,5 +277,19 @@ Reset individual folding states."
(mu4e-thread-unfold) (mu4e-thread-unfold)
(mu4e-thread-goto-next))) (mu4e-thread-goto-next)))
(define-minor-mode mu4e-thread-mode
"Mode for thread-support."
:global nil
:init-value nil ;; disabled by default
:group 'mu4e
:lighter ""
:keymap
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<S-left>") #'mu4e-thread-goto-root)
(define-key map (kbd "<tab>") #'mu4e-thread-fold-toggle-goto-next)
(define-key map (kbd "<C-tab>") #'mu4e-thread-fold-toggle-goto-next)
(define-key map (kbd "<backtab>") #'mu4e-thread-fold-toggle-all)
map))
(provide 'mu4e-thread) (provide 'mu4e-thread)
;;; mu4e-thread.el ends here ;;; mu4e-thread.el ends here

View File

@ -1118,15 +1118,19 @@ Folding stops at the @emph{first unread message}, unless you set
the folding stops at the first marked message. Marking folded messages is not the folding stops at the first marked message. Marking folded messages is not
allowed as it is too error-prone. allowed as it is too error-prone.
Thread-mode functionality is only available with @code{mu4e-search-threads}
enabled; this triggers a minor mode @code{mu4e-thread-mode} in the headers-view.
For now, this functionality is not available in the message view, due to the
conflicting key bindings.
If you want to automatically fold all threads after a query, you can use a hook: If you want to automatically fold all threads after a query, you can use a hook:
@lisp @lisp
(add-hook 'mu4e-headers-found-hook #'mu4e-thread-fold-apply-all) (add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-apply-all)
@end lisp @end lisp
By default, single-child threads are @emph{not} collapsed, since it would simply By default, single-child threads are @emph{not} collapsed, since it would result
result in replacing a single line with the collapsed one. However, if, for in replacing a single line with the collapsed one. However, if, for consistency,
consistency you also want to fold those, you can use you also want to fold those, you can use @t{mu4e-thread-fold-single-children}.
@t{mu4e-thread-fold-single-children}.
@node HV Custom headers @node HV Custom headers
@section Custom headers @section Custom headers