discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH v2 0/3] notmuch: Improve handling of attached patches
Date: Mon, 04 Jan 2021 01:54:43 GMT	[thread overview]
Message-ID: <20210104015435.18397-1-kyle@kyleam.com> (raw)
In-Reply-To: <87zh1pbh7x.fsf@kyleam.com>

I've hit into a few cases where piem-notmuch-am-ready-mbox hasn't been
able to find an attached patch.  This series, in particular patch 2,
should improve the situation.

v2: Fix handling of inline multipart/signed patches by using the
attachment count rather than the top-level content-type to decide
whether to go down the attachment or inline code path.

  [1/3] piem-notmuch--with-current-message: Declare debug and indent specs
  [2/3] piem-notmuch-am-ready-mbox: Improve handling of attachments
  [3/3] gnus, notmuch: Absorb now-shared bits into patch attachment helper

 piem-gnus.el    | 14 ++------------
 piem-notmuch.el | 49 +++++++++++++++++++++++++------------------------
 piem.el         | 21 +++++++++++++--------
 3 files changed, 40 insertions(+), 44 deletions(-)

Range-diff against v1:
1:  f4ff1f1 = 1:  f4ff1f1 piem-notmuch--with-current-message: Declare debug and indent specs
2:  8eb290d ! 2:  ca8d684 piem-notmuch-am-ready-mbox: Improve handling of attachments
    @@ piem-notmuch.el: (defun piem-notmuch-am-ready-mbox ()
     -                   (dolist (patch patches)
     -                     (insert patch)))
     -                 "mbox")))))))
    -+    (if (string-prefix-p
    -+         "multipart/"
    -+         (plist-get
    -+          (car (plist-get (notmuch-show-get-message-properties)
    -+                          :body))
    -+          :content-type))
    -+        (let (patches)
    -+          (piem-notmuch--with-current-message
    -+            (notmuch-foreach-mime-part
    -+             (lambda (p)
    -+               (and (piem-am-patch-attachment-p
    -+                     (mm-handle-media-type p)
    -+                     (mm-handle-filename p))
    -+                    (with-temp-buffer
    -+                      (mm-display-inline p)
    -+                      (push (buffer-substring-no-properties
    -+                             (point-min) (point-max))
    -+                            patches))))
    -+             (mm-dissect-buffer)))
    -+          (when patches
    -+            (setq patches (nreverse patches))
    -+            (cons (lambda ()
    -+                    (dolist (patch patches)
    -+                      (insert patch)))
    -+                  "mbox")))
    -+      (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* ((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))))
    ++        (notmuch-foreach-mime-part
    ++         (lambda (p)
    ++           (and (piem-am-patch-attachment-p
    ++                 (mm-handle-media-type p)
    ++                 (mm-handle-filename p))
    ++                (with-temp-buffer
    ++                  (mm-display-inline p)
    ++                  (push (buffer-substring-no-properties
    ++                         (point-min) (point-max))
    ++                        patches))))
    ++         handle)
    ++        (when patches
    ++          (setq patches (nreverse patches))
    ++          (cons (lambda ()
    ++                  (dolist (patch patches)
    ++                    (insert patch)))
    ++                "mbox"))))))
      
      ;;;###autoload
      (define-minor-mode piem-notmuch-mode
3:  6bbde3b ! 3:  ee314a5 gnus, notmuch: Absorb now-shared bits into patch attachment helper
    @@ piem-gnus.el: (defun piem-gnus-am-ready-mbox ()
     
      ## piem-notmuch.el ##
     @@ piem-notmuch.el: (defun piem-notmuch-am-ready-mbox ()
    -           (piem-notmuch--with-current-message
    -             (notmuch-foreach-mime-part
    -              (lambda (p)
    --               (and (piem-am-patch-attachment-p
    --                     (mm-handle-media-type p)
    --                     (mm-handle-filename p))
    --                    (with-temp-buffer
    --                      (mm-display-inline p)
    --                      (push (buffer-substring-no-properties
    --                             (point-min) (point-max))
    --                            patches))))
    -+               (when-let ((patch (piem-am-extract-attached-patch p)))
    -+                 (push patch patches)))
    -              (mm-dissect-buffer)))
    -           (when patches
    -             (setq patches (nreverse patches))
    +                               "show" "--format=mbox" id))))
    +         (notmuch-foreach-mime-part
    +          (lambda (p)
    +-           (and (piem-am-patch-attachment-p
    +-                 (mm-handle-media-type p)
    +-                 (mm-handle-filename p))
    +-                (with-temp-buffer
    +-                  (mm-display-inline p)
    +-                  (push (buffer-substring-no-properties
    +-                         (point-min) (point-max))
    +-                        patches))))
    ++           (when-let ((patch (piem-am-extract-attached-patch p)))
    ++             (push patch patches)))
    +          handle)
    +         (when patches
    +           (setq patches (nreverse patches))
     
      ## piem.el ##
     @@

base-commit: 96da1c622caac904e3f60e306847a4e68ca15e0c
-- 
2.29.2


  reply	other threads:[~2021-01-04  1:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-03 18:09 [PATCH " Kyle Meyer
2021-01-03 18:09 ` [PATCH 1/3] piem-notmuch--with-current-message: Declare debug and indent specs Kyle Meyer
2021-01-03 18:09 ` [PATCH 2/3] piem-notmuch-am-ready-mbox: Improve handling of attachments Kyle Meyer
2021-01-04  1:53   ` Kyle Meyer
2021-01-04  1:54     ` Kyle Meyer [this message]
2021-01-04  1:54       ` [PATCH v2 1/3] piem-notmuch--with-current-message: Declare debug and indent specs Kyle Meyer
2021-01-04  1:54       ` [PATCH v2 2/3] piem-notmuch-am-ready-mbox: Improve handling of attachments Kyle Meyer
2021-01-04  1:54       ` [PATCH v2 3/3] gnus, notmuch: Absorb now-shared bits into patch attachment helper Kyle Meyer
2021-01-03 18:09 ` [PATCH " Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://git.kyleam.com/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210104015435.18397-1-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --subject='Re: [PATCH v2 0/3] notmuch: Improve handling of attached patches' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

discussion and development of piem

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.kyleam.com/piem/0 piem/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 piem piem/ https://inbox.kyleam.com/piem \
		piem@inbox.kyleam.com
	public-inbox-index piem

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.piem


code repositories for project(s) associated with this inbox:

	https://git.kyleam.com/piem/

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git