discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH 2/5] Move "has gunzip?" check to helper
Date: Sun, 16 Aug 2020 21:33:40 -0400	[thread overview]
Message-ID: <20200817013343.15615-3-kyle@kyleam.com> (raw)
In-Reply-To: <20200817013343.15615-1-kyle@kyleam.com>

This will be needed in another spot.
---
 piem.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/piem.el b/piem.el
index bcbec78..4b35938 100644
--- a/piem.el
+++ b/piem.el
@@ -365,6 +365,13 @@ (defun piem-am-ready-mbox ()
 \f
 ;;;; Maildir injection
 
+(defvar piem--has-gunzip)
+(defun piem-check-gunzip ()
+  "Return non-nil if gunzip is available."
+  (unless (boundp 'piem--has-gunzip)
+    (setq piem--has-gunzip (executable-find "gunzip")))
+  piem--has-gunzip)
+
 (defun piem--write-mbox-to-maildir ()
   (let ((n-messages 0))
     (while (and (not (eobp))
@@ -413,8 +420,6 @@ (defun piem--inject-thread-callback (status mid message-only)
       (and (buffer-live-p buffer)
            (kill-buffer buffer)))))
 
-(defvar piem--has-gunzip)
-
 ;;;###autoload
 (defun piem-inject-thread-into-maildir (mid &optional message-only)
   "Inject thread containing MID into `piem-maildir-directory'.
@@ -428,15 +433,13 @@ (defun piem-inject-thread-into-maildir (mid &optional message-only)
    (list (or (piem-mid)
              (user-error "No message ID found for the current buffer"))
          current-prefix-arg))
-  (unless (or message-only (boundp 'piem--has-gunzip))
-    (setq piem--has-gunzip (executable-find "gunzip")))
   (cond
    ((not piem-maildir-directory)
     (user-error "`piem-maildir-directory' is not configured"))
    ((not (piem-maildir-dir-is-maildir-p piem-maildir-directory))
     (user-error
      "`piem-maildir-directory' does not look like a Maildir directory"))
-   ((not (or message-only piem--has-gunzip))
+   ((not (or message-only (piem-check-gunzip)))
     (user-error "gunzip executable not found")))
   (url-retrieve (concat (or (piem-inbox-url)
                             (user-error
-- 
2.28.0


  parent reply	other threads:[~2020-08-17  1:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  1:33 [PATCH 0/5] b4: Try to download thread from piem-inboxes URL Kyle Meyer
2020-08-17  1:33 ` [PATCH 1/5] Use url-http-end-of-headers move to payload Kyle Meyer
2020-08-17  1:33 ` Kyle Meyer [this message]
2020-08-17  1:33 ` [PATCH 3/5] Extract logic from inject-thread-callback Kyle Meyer
2020-08-17  1:33 ` [PATCH 4/5] b4: Use a clearer variable name Kyle Meyer
2020-08-17  1:33 ` [PATCH 5/5] b4: Try to download thread from piem-inboxes URL 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=20200817013343.15615-3-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).