* mu4e-mark: fix thread-based marking for marks with targets
This commit is contained in:
@ -153,7 +153,7 @@ The following marks are available, and the corresponding props:
|
|||||||
the region, for moving to maildir TARGET. If target is not
|
the region, for moving to maildir TARGET. If target is not
|
||||||
provided, function asks for it."
|
provided, function asks for it."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mu4e-message-at-point) ;; raises error if there is none
|
;; (mu4e-message-at-point) ;; raises error if there is none
|
||||||
(let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
|
(let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
|
||||||
(target (if (string= (substring target 0 1) "/")
|
(target (if (string= (substring target 0 1) "/")
|
||||||
target
|
target
|
||||||
@ -165,27 +165,28 @@ provided, function asks for it."
|
|||||||
(mu4e~proc-mkdir fulltarget)))
|
(mu4e~proc-mkdir fulltarget)))
|
||||||
target)))
|
target)))
|
||||||
|
|
||||||
|
(defun mu4e~mark-get-target (mark &optional target)
|
||||||
|
"Get the target for MARK, if it is a mark that has a target;
|
||||||
|
otherwise return nil."
|
||||||
|
(case mark
|
||||||
|
(refile (mu4e-get-refile-folder (mu4e-message-at-point)))
|
||||||
|
(move (mu4e~mark-get-move-target target))
|
||||||
|
(trash (mu4e-get-trash-folder (mu4e-message-at-point)))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-mark-set (mark &optional target)
|
(defun mu4e-mark-set (mark &optional target)
|
||||||
"Mark the header at point, or, if region is active, mark all
|
"Mark the header at point, or, if region is active, mark all
|
||||||
headers in the region. Optionally, provide TARGET (for moves)."
|
headers in the region. Optionally, provide TARGET (for moves)."
|
||||||
(let ((get-target
|
|
||||||
(lambda (target)
|
|
||||||
(or target ;; ask or check the target if it's a move
|
|
||||||
(case mark
|
|
||||||
(refile (mu4e-get-refile-folder (mu4e-message-at-point)))
|
|
||||||
(move (mu4e~mark-get-move-target target))
|
|
||||||
(trash (mu4e-get-trash-folder (mu4e-message-at-point))))))))
|
|
||||||
(if (not (use-region-p))
|
(if (not (use-region-p))
|
||||||
;; single message
|
;; single message
|
||||||
(mu4e-mark-at-point mark (funcall get-target target))
|
(mu4e-mark-at-point mark (or target (mu4e~mark-get-target mark target)))
|
||||||
;; mark all messages in the region.
|
;; mark all messages in the region.
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((cant-go-further) (eor (region-end)))
|
(let ((cant-go-further) (eor (region-end)))
|
||||||
(goto-char (region-beginning))
|
(goto-char (region-beginning))
|
||||||
(while (and (<= (point) eor) (not cant-go-further))
|
(while (and (<= (point) eor) (not cant-go-further))
|
||||||
(mu4e-mark-at-point mark (funcall get-target target))
|
(mu4e-mark-at-point mark (or target (mu4e~mark-get-target mark target)))
|
||||||
(setq cant-go-further (not (mu4e-headers-next)))))))))
|
(setq cant-go-further (not (mu4e-headers-next))))))))
|
||||||
|
|
||||||
(defun mu4e-mark-restore (docid)
|
(defun mu4e-mark-restore (docid)
|
||||||
"Restore the visual mark for the message with DOCID."
|
"Restore the visual mark for the message with DOCID."
|
||||||
@ -212,9 +213,7 @@ is non-nil, allow the 'something' pseudo mark as well."
|
|||||||
(append marks (list '("something" . something)))
|
(append marks (list '("something" . something)))
|
||||||
marks))
|
marks))
|
||||||
(mark (mu4e-read-option prompt marks))
|
(mark (mu4e-read-option prompt marks))
|
||||||
(target
|
(target (mu4e~mark-get-target mark)))
|
||||||
(when (eq mark 'move)
|
|
||||||
(mu4e-ask-maildir-check-exists "Move message to: "))))
|
|
||||||
(cons mark target)))
|
(cons mark target)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user