summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2023-02-12 12:55:34 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2023-02-12 12:58:05 +0200
commit92ac6de09cf84aea4e196d494a726bf06299bd77 (patch)
tree6a45ed99e4d25699f9c85f1ad3d6398d89afb823
parent88cb22d178f3fb5cdfe5c6c66a8b46fc5e3b2b70 (diff)
mu4e: support jumping to previous/next thread
in headers view, message view with '{' and '}. Also update documentation. Fixes #1523
-rw-r--r--mu4e/mu4e-headers.el25
-rw-r--r--mu4e/mu4e-view.el23
-rw-r--r--mu4e/mu4e.texi6
3 files changed, 46 insertions, 8 deletions
diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el
index 92abaeb..c21c83d 100644
--- a/mu4e/mu4e-headers.el
+++ b/mu4e/mu4e-headers.el
@@ -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-next-unread)
+ (define-key map (kbd "{") #'mu4e-headers-prev-thread)
+ (define-key map (kbd "}") #'mu4e-headers-next-thread)
+
;; change the number of headers
(define-key map (kbd "C-+") #'mu4e-headers-split-view-grow)
(define-key map (kbd "C--") #'mu4e-headers-split-view-shrink)
@@ -1467,7 +1470,7 @@ previous header."
(defun mu4e~headers-prev-or-next-unread (backwards)
"Move point to the next message that is unread (and
untrashed). If BACKWARDS is non-`nil', move backwards."
- (interactive)
+ (interactive "P")
(or (mu4e-headers-find-if-next
(lambda (msg)
(let ((flags (mu4e-message-field msg :flags)))
@@ -1488,6 +1491,26 @@ untrashed)."
(interactive)
(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)
"In split-view, grow the headers window.
In horizontal split-view, increase the number of lines shown by N.
diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el
index 776f71f..38ea62a 100644
--- a/mu4e/mu4e-view.el
+++ b/mu4e/mu4e-view.el
@@ -193,14 +193,13 @@ previous header."
(mu4e--view-in-headers-context
(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.
Go to the previous message if BACKWARDS is non-nil.
unread message header in the headers buffer connected with this
message view. If this succeeds, return the new docid. Otherwise,
return nil."
- (mu4e--view-in-headers-context
- (mu4e~headers-prev-or-next-unread backwards))
+ (mu4e--view-in-headers-context (funcall func backwards))
(mu4e-select-other-view)
(mu4e-headers-view-message))
@@ -208,13 +207,25 @@ return nil."
"Move point to the previous unread message header.
If this succeeds, return the new docid. Otherwise, return nil."
(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 ()
"Move point to the next unread message header.
If this succeeds, return the new docid. Otherwise, return nil."
(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
@@ -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-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)
(define-key map "y" #'mu4e-select-other-view)
diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi
index e4fbe7a..ad4e67c 100644
--- a/mu4e/mu4e.texi
+++ b/mu4e/mu4e.texi
@@ -978,7 +978,8 @@ key description
===========================================================
n,p view the next, previous 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
searching
@@ -1304,7 +1305,8 @@ key description
==============================================================
n,p view the next, previous 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
M-RET open URL at point / attachment at point