Skip to content

Commit

Permalink
Merge pull request #597 from danieroux/non-interactive-mark-thread
Browse files Browse the repository at this point in the history
mu4e: Extract mu4e-headers-mark-thread-using-markpair
  • Loading branch information
djcb committed Mar 17, 2015
2 parents 33804f6 + 69ef303 commit 209f10b
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions mu4e/mu4e-headers.el
Original file line number Diff line number Diff line change
Expand Up @@ -1082,21 +1082,20 @@ matching messages with that mark."
(otherwise (mu4e-error "Not supported")))))


(defun mu4e-headers-mark-thread (&optional subthread)
"Mark the thread at point. If SUBTHREAD is non-nil, marking is
limited to the message at point and its descendants."
(defun mu4e-headers-mark-thread-using-markpair (markpair &optional subthread)
"Mark the thread at point using the given markpair. If SUBTHREAD is
non-nil, marking is limited to the message at point and its
descendants."
(let* ((mark (car markpair))
(allowed-marks (mapcar 'car mu4e-marks)))
(unless (memq mark allowed-marks)
(mu4e-error "The mark (%s) has to be one of: %s"
mark allowed-marks)))
;; note: the tread id is shared by all messages in a thread
(interactive "P")
(let* ((msg (mu4e-message-at-point))
(thread-id (mu4e~headers-get-thread-info msg 'thread-id))
(path (mu4e~headers-get-thread-info msg 'path))
;; FIXME: e.g., for refiling we should evaluate this
;; for each line separately
(markpair
(mu4e~mark-get-markpair
(if subthread "Mark subthread with: " "Mark whole thread with: ")
t))
(last-marked-point))
(thread-id (mu4e~headers-get-thread-info msg 'thread-id))
(path (mu4e~headers-get-thread-info msg 'path))
(last-marked-point))
(mu4e-headers-for-each
(lambda (mymsg)
(let ((my-thread-id (mu4e~headers-get-thread-info mymsg 'thread-id)))
Expand All @@ -1116,6 +1115,17 @@ limited to the message at point and its descendants."
(goto-char last-marked-point)
(mu4e-headers-next))))

(defun mu4e-headers-mark-thread (&optional subthread)
"Like `mu4e-headers-mark-thread-using-markpair' but prompt for the markpair."
(interactive "P")
(let* (;; FIXME: e.g., for refiling we should evaluate this
;; for each line separately
(markpair
(mu4e~mark-get-markpair
(if subthread "Mark subthread with: " "Mark whole thread with: ")
t)))
(mu4e-headers-mark-thread-using-markpair markpair)))

(defun mu4e-headers-mark-subthread ()
"Like `mu4e-mark-thread', but only for a sub-thread."
(interactive)
Expand Down

0 comments on commit 209f10b

Please sign in to comment.