mu4e: support jumping to previous/next thread

in headers view, message view with '{' and '}.
Also update documentation.

Fixes #1523
This commit is contained in:
Dirk-Jan C. Binnema
2023-02-12 12:55:34 +02:00
parent 88cb22d178
commit 92ac6de09c
3 changed files with 46 additions and 8 deletions

View File

@ -923,6 +923,9 @@ after the end of the search results."
(define-key map (kbd "[") #'mu4e-headers-prev-unread) (define-key map (kbd "[") #'mu4e-headers-prev-unread)
(define-key map (kbd "]") #'mu4e-headers-next-unread) (define-key map (kbd "]") #'mu4e-headers-next-unread)
(define-key map (kbd "{") #'mu4e-headers-prev-thread)
(define-key map (kbd "}") #'mu4e-headers-next-thread)
;; change the number of headers ;; change the number of headers
(define-key map (kbd "C-+") #'mu4e-headers-split-view-grow) (define-key map (kbd "C-+") #'mu4e-headers-split-view-grow)
(define-key map (kbd "C--") #'mu4e-headers-split-view-shrink) (define-key map (kbd "C--") #'mu4e-headers-split-view-shrink)
@ -1467,7 +1470,7 @@ previous header."
(defun mu4e~headers-prev-or-next-unread (backwards) (defun mu4e~headers-prev-or-next-unread (backwards)
"Move point to the next message that is unread (and "Move point to the next message that is unread (and
untrashed). If BACKWARDS is non-`nil', move backwards." untrashed). If BACKWARDS is non-`nil', move backwards."
(interactive) (interactive "P")
(or (mu4e-headers-find-if-next (or (mu4e-headers-find-if-next
(lambda (msg) (lambda (msg)
(let ((flags (mu4e-message-field msg :flags))) (let ((flags (mu4e-message-field msg :flags)))
@ -1488,6 +1491,26 @@ untrashed)."
(interactive) (interactive)
(mu4e~headers-prev-or-next-unread nil)) (mu4e~headers-prev-or-next-unread nil))
(defun mu4e~headers-prev-or-next-thread (backwards)
"Move point to the top of the next thread.
If BACKWARDS is non-`nil', move backwards."
(interactive "P")
(or (mu4e-headers-find-if-next
(lambda (msg)
(eq 0 (plist-get (plist-get msg :meta) :level)))
backwards)
(mu4e-message (format "No %s thread found"
(if backwards "previous" "next")))))
(defun mu4e-headers-prev-thread ()
"Move point to the previous thread."
(interactive) (mu4e~headers-prev-or-next-thread t))
(defun mu4e-headers-next-thread ()
"Move point to the previous thread."
(interactive) (mu4e~headers-prev-or-next-thread nil))
(defun mu4e-headers-split-view-grow (&optional n) (defun mu4e-headers-split-view-grow (&optional n)
"In split-view, grow the headers window. "In split-view, grow the headers window.
In horizontal split-view, increase the number of lines shown by N. In horizontal split-view, increase the number of lines shown by N.

View File

@ -193,14 +193,13 @@ previous header."
(mu4e--view-in-headers-context (mu4e--view-in-headers-context
(mu4e~headers-move (- (or n 1))))) (mu4e~headers-move (- (or n 1)))))
(defun mu4e--view-prev-or-next-unread (backwards) (defun mu4e--view-prev-or-next (func backwards)
"Move point to the next or previous message. "Move point to the next or previous message.
Go to the previous message if BACKWARDS is non-nil. Go to the previous message if BACKWARDS is non-nil.
unread message header in the headers buffer connected with this unread message header in the headers buffer connected with this
message view. If this succeeds, return the new docid. Otherwise, message view. If this succeeds, return the new docid. Otherwise,
return nil." return nil."
(mu4e--view-in-headers-context (mu4e--view-in-headers-context (funcall func backwards))
(mu4e~headers-prev-or-next-unread backwards))
(mu4e-select-other-view) (mu4e-select-other-view)
(mu4e-headers-view-message)) (mu4e-headers-view-message))
@ -208,13 +207,25 @@ return nil."
"Move point to the previous unread message header. "Move point to the previous unread message header.
If this succeeds, return the new docid. Otherwise, return nil." If this succeeds, return the new docid. Otherwise, return nil."
(interactive) (interactive)
(mu4e--view-prev-or-next-unread t)) (mu4e--view-prev-or-next #'mu4e~headers-prev-or-next-unread t))
(defun mu4e-view-headers-next-unread () (defun mu4e-view-headers-next-unread ()
"Move point to the next unread message header. "Move point to the next unread message header.
If this succeeds, return the new docid. Otherwise, return nil." If this succeeds, return the new docid. Otherwise, return nil."
(interactive) (interactive)
(mu4e--view-prev-or-next-unread nil)) (mu4e--view-prev-or-next #'mu4e~headers-prev-or-next-unread nil))
(defun mu4e-view-headers-prev-thread()
"Move point to the previous thread.
If this succeeds, return the new docid. Otherwise, return nil."
(interactive)
(mu4e--view-prev-or-next #'mu4e~headers-prev-or-next-thread t))
(defun mu4e-view-headers-next-thread()
"Move point to the previous thread.
If this succeeds, return the new docid. Otherwise, return nil."
(interactive)
(mu4e--view-prev-or-next #'mu4e~headers-prev-or-next-thread nil))
;;; Interactive functions ;;; Interactive functions
@ -907,6 +918,8 @@ This is useful for advising some Gnus-functionality that does not work in mu4e."
(define-key map (kbd "[") #'mu4e-view-headers-prev-unread) (define-key map (kbd "[") #'mu4e-view-headers-prev-unread)
(define-key map (kbd "]") #'mu4e-view-headers-next-unread) (define-key map (kbd "]") #'mu4e-view-headers-next-unread)
(define-key map (kbd "{") #'mu4e-view-headers-prev-thread)
(define-key map (kbd "}") #'mu4e-view-headers-next-thread)
;; switching from view <-> headers (when visible) ;; switching from view <-> headers (when visible)
(define-key map "y" #'mu4e-select-other-view) (define-key map "y" #'mu4e-select-other-view)

View File

@ -978,7 +978,8 @@ key description
=========================================================== ===========================================================
n,p view the next, previous message n,p view the next, previous message
],[ move to the next, previous unread message ],[ move to the next, previous unread message
y select the message view (if it's visible) },{ move to the next, previous thread
y select the message view (if visible)
RET open the message at point in the message view RET open the message at point in the message view
searching searching
@ -1304,7 +1305,8 @@ key description
============================================================== ==============================================================
n,p view the next, previous message n,p view the next, previous message
],[ move to the next, previous unread message ],[ move to the next, previous unread message
y select the headers view (if it's visible) },{ move to the next, previous thread
y select the headers view (if visible)
RET scroll down RET scroll down
M-RET open URL at point / attachment at point M-RET open URL at point / attachment at point