discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH 3/4] Use when-let in a few more spots
Date: Sun, 22 Nov 2020 15:46:08 -0500
Message-ID: <20201122204609.12604-4-kyle@kyleam.com> (raw)
In-Reply-To: <20201122204609.12604-1-kyle@kyleam.com>

---
 piem-gnus.el    | 50 ++++++++++++++++++++++++-------------------------
 piem-notmuch.el | 23 +++++++++++------------
 2 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/piem-gnus.el b/piem-gnus.el
index c1551ce..ca128fb 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -65,33 +65,31 @@ (defun piem-gnus-am-ready-mbox ()
   (when (derived-mode-p 'gnus-article-mode 'gnus-summary-mode)
     (cond
      (gnus-article-mime-handles
-      (let ((patches
-             (delq nil
-                   (mapcar (lambda (handle)
-                             (and (listp handle)
-                                  (piem-am-patch-attachment-p
-                                   (mm-handle-media-type handle))
-                                  (with-temp-buffer
-                                    (mm-display-inline handle)
-                                    (buffer-substring-no-properties
-                                     (point-min) (point-max)))))
-                           gnus-article-mime-handles))))
-        (when patches
-          (cons (lambda ()
-                  (dolist (patch patches)
-                    (insert patch)))
-                "mbox"))))
+      (when-let ((patches
+                  (delq nil
+                        (mapcar (lambda (handle)
+                                  (and (listp handle)
+                                       (piem-am-patch-attachment-p
+                                        (mm-handle-media-type handle))
+                                       (with-temp-buffer
+                                         (mm-display-inline handle)
+                                         (buffer-substring-no-properties
+                                          (point-min) (point-max)))))
+                                gnus-article-mime-handles))))
+        (cons (lambda ()
+                (dolist (patch patches)
+                  (insert patch)))
+              "mbox")))
      (gnus-article-buffer
-      (let ((patch (with-current-buffer gnus-article-buffer
-                     (save-restriction
-                       (widen)
-                       (and (string-match-p piem-patch-subject-re
-                                            (message-field-value "subject"))
-                            (buffer-substring-no-properties
-                             (point-min) (point-max)))))))
-        (when patch
-          (cons (lambda () (insert patch))
-                "mbox")))))))
+      (when-let ((patch (with-current-buffer gnus-article-buffer
+                          (save-restriction
+                            (widen)
+                            (and (string-match-p piem-patch-subject-re
+                                                 (message-field-value "subject"))
+                                 (buffer-substring-no-properties
+                                  (point-min) (point-max)))))))
+        (cons (lambda () (insert patch))
+              "mbox"))))))
 
 ;;;###autoload
 (define-minor-mode piem-gnus-mode
diff --git a/piem-notmuch.el b/piem-notmuch.el
index ccfae75..8f5ef77 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -88,18 +88,17 @@ (defun piem-notmuch-am-ready-mbox ()
              (call-process notmuch-command nil t nil
                            "show" "--format=mbox" id))))
         ("multipart/mixed"
-         (let ((patches
-                (delq nil
-                      (mapcar (lambda (part)
-                                (and (piem-am-patch-attachment-p
-                                      (plist-get part :content-type))
-                                     (plist-get part :content)))
-                              (plist-get body :content)))))
-           (when patches
-             (cons (lambda ()
-                     (dolist (patch patches)
-                       (insert patch)))
-                   "mbox"))))))))
+         (when-let ((patches
+                     (delq nil
+                           (mapcar (lambda (part)
+                                     (and (piem-am-patch-attachment-p
+                                           (plist-get part :content-type))
+                                          (plist-get part :content)))
+                                   (plist-get body :content)))))
+           (cons (lambda ()
+                   (dolist (patch patches)
+                     (insert patch)))
+                 "mbox")))))))
 
 ;;;###autoload
 (define-minor-mode piem-notmuch-mode
-- 
2.29.2


  parent reply	other threads:[~2020-11-22 20:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-22 20:46 [PATCH 0/4] Support text/plain patch attachments Kyle Meyer
2020-11-22 20:46 ` [PATCH 1/4] gnus: Prefer mm-handle-media-type over direct access Kyle Meyer
2020-11-22 20:46 ` [PATCH 2/4] gnus, notmuch: Share "attachment is patch?" logic Kyle Meyer
2020-11-22 20:46 ` Kyle Meyer [this message]
2020-11-22 20:46 ` [PATCH 4/4] gnus, notmuch: Consider text/plain patch attachments Kyle Meyer
2020-11-22 21:10   ` 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=20201122204609.12604-4-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --subject='Re: [PATCH 3/4] Use when-let in a few more spots' \
    /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