summaryrefslogtreecommitdiff
path: root/piem.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-08-16 21:33:43 -0400
committerKyle Meyer <kyle@kyleam.com>2020-08-17 20:23:21 -0400
commit846c69cae321442bb2f5cefec7000328943c7560 (patch)
treea95117e00ac9b05cd2040737dbc26cc252f4aaf6 /piem.el
parent261bed7a522c34b77a47143725ae1f16f548abd4 (diff)
downloadpiem-846c69cae321442bb2f5cefec7000328943c7560.tar.gz
b4: Try to download thread from piem-inboxes URL
If a call to piem-b4-am-from-mid fails to generate the thread for a message ID via piem-mid-to-thread-functions, b4 is called without a local mbox. In this case, b4 tries to download the thread from the URL specified by b4.midmask in the caller's Git configuration. That works, but it's inconvenient because the user needs to configure the URL in two places. If the current buffer is associated with an inbox in piem-inboxes, try to download the thread from its :url before falling back to b4's midmask. Message-Id: <20200817013343.15615-6-kyle@kyleam.com>
Diffstat (limited to 'piem.el')
-rw-r--r--piem.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/piem.el b/piem.el
index 029b647..3669cfe 100644
--- a/piem.el
+++ b/piem.el
@@ -390,6 +390,21 @@ buffer."
(delete-region (point) (point-max))
(goto-char (point-min)))
+(defun piem--decompress-callback (status)
+ (if (plist-get status :error)
+ (kill-buffer (current-buffer))
+ (piem--url-remove-header)
+ (piem--url-decompress)))
+
+(defun piem-download-and-decompress (url)
+ "Retrieve gzipped content at URL and decompress it.
+A buffer with the decompressed content is returned. A live
+buffer indicates that the request did not result in an error."
+ (unless (piem-check-gunzip)
+ (user-error "gunzip executable not found"))
+ (let ((url-asynchronous nil))
+ (url-retrieve url #'piem--decompress-callback)))
+
(defun piem--write-mbox-to-maildir ()
(let ((n-messages 0))
(while (and (not (eobp))