diff options
Diffstat (limited to 'piem-notmuch.el')
-rw-r--r-- | piem-notmuch.el | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/piem-notmuch.el b/piem-notmuch.el index 41f2793..9077ec8 100644 --- a/piem-notmuch.el +++ b/piem-notmuch.el @@ -85,31 +85,36 @@ have surrounding brackets." (defun piem-notmuch-am-ready-mbox () "Return a function that inserts an am-ready mbox. + If the buffer has any MIME parts that look like a patch, use -those parts' contents (in order) as the mbox. Otherwise, use the -message itself if it looks like a patch." +those parts' contents as the mbox, ordering the patches based on +the number at the start of the file name. If none of the file +names start with a number, retain the original order of the +attachments. + +If no MIME parts look like a patch, use the message itself if it +looks like a patch." (when (derived-mode-p 'notmuch-show-mode) (let* ((handle (piem-notmuch--with-current-message (mm-dissect-buffer))) (n-attachments (notmuch-count-attachments handle)) patches) (if (= n-attachments 0) - (when (string-match-p piem-patch-subject-re - (notmuch-show-get-subject)) - (let ((id (notmuch-show-get-message-id))) - (lambda () - (call-process notmuch-command nil t nil - "show" "--format=mbox" id)))) + (let ((id (notmuch-show-get-message-id))) + (lambda () + (call-process notmuch-command nil t nil + "show" "--format=mbox" id))) (notmuch-foreach-mime-part (lambda (p) (when-let ((patch (piem-am-extract-attached-patch p))) (push patch patches))) handle) (when patches - (setq patches (nreverse patches)) + (setq patches (sort (nreverse patches) + (lambda (x y) (< (car x) (car y))))) (cons (lambda () (dolist (patch patches) - (insert patch))) + (insert (cdr patch)))) "mbox")))))) (defun piem-notmuch-extract-patch-am-ready-mbox () @@ -118,8 +123,6 @@ Use the message itself if it looks like a patch using notmuch-extract-patch to get the latest patch series from the notmuch thread." (when (and (derived-mode-p 'notmuch-show-mode) - (string-match-p piem-patch-subject-re - (notmuch-show-get-subject)) (= (notmuch-count-attachments (piem-notmuch--with-current-message (mm-dissect-buffer))) |