summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-11-22 15:46:08 -0500
committerKyle Meyer <kyle@kyleam.com>2020-11-22 19:50:56 -0500
commit27495eeb67515f8dac0e7449aa2165272e8ebe5a (patch)
tree863fbc9989893da5d273054a4a7da8db458e22a6
parent72640c7b22f599369d799ce11d8bb55e10c78eeb (diff)
downloadpiem-27495eeb67515f8dac0e7449aa2165272e8ebe5a.tar.gz
Use when-let in a few more spots
-rw-r--r--piem-gnus.el50
-rw-r--r--piem-notmuch.el23
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 @@ message itself if it looks like a patch."
(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 @@ message itself if it looks like a patch."
(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