summaryrefslogtreecommitdiff
path: root/piem.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-08-10 23:16:32 -0400
committerKyle Meyer <kyle@kyleam.com>2020-08-10 23:37:50 -0400
commit2341b3403e607a1efd8cd47093cd7200bc63e521 (patch)
tree30519fbe3ca48f67ec0ef7933cd04d5eff4ee28a /piem.el
parent0ee97e900f7daef3995284d0b4312c371b3427fa (diff)
downloadpiem-2341b3403e607a1efd8cd47093cd7200bc63e521.tar.gz
Fix handling of -am-ready-mbox values
0ee97e9 (Explicitly specify --patch-format in git-am calls, 2020-08-09) made it possible for a piem-am-ready-mbox-functions member to specify the format of the mbox by returning (FUNCTION FORMAT). If FUNCTION is returned, then mboxrd is supposed to be taken as the default format. The handling is broken, though, because piem-am-ready-mbox tries to detect the (FUNCTION FORMAT) form with listp, but that of course also returns true when the return value is simply a function. Instead, check to see whether the element matches a valid format value. Switch from (FUNCTION FORMAT) to (FUNCTION . FORMAT) to make it more convenient to pull out FORMAT with cdr-safe. Message-Id: <877du5c1nz.fsf@kyleam.com>
Diffstat (limited to 'piem.el')
-rw-r--r--piem.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/piem.el b/piem.el
index e70c259..ece30bd 100644
--- a/piem.el
+++ b/piem.el
@@ -99,7 +99,7 @@ mbox's contents (in mboxrd format) in the current buffer."
The functions are called with no arguments. If a function knows
how to create an mbox, it should return a function that takes no
arguments and inserts the mbox's contents in the current buffer.
-The return value can also be (FUNCTION FORMAT), where FORMAT is
+The return value can also be (FUNCTION . FORMAT), where FORMAT is
either \"mbox\" or \"mboxrd\" and maps to the --patch-format
value passed to `git am'. If unspecified, \"mboxrd\" is used."
:type 'hook)
@@ -337,13 +337,16 @@ intended to be used by libraries implementing a function for
(defun piem-am-ready-mbox ()
"Generate a buffer containing an am-ready mbox.
-The return value is (BUFFER FORMAT), where FORMAT is either
+The return value is (BUFFER . FORMAT), where FORMAT is either
\"mbox\" or \"mboxrd\". Callers are responsible for killing the
buffer."
(when-let ((res (run-hook-with-args-until-success
'piem-am-ready-mbox-functions)))
(pcase-let ((buffer (generate-new-buffer " *piem am-ready mbox*"))
- (`(,fn ,format) (if (listp res) res (list res "mboxrd")))
+ (`(,fn . ,format)
+ (if (member (cdr-safe res) '("mbox" "mboxrd"))
+ res
+ (cons res "mboxrd")))
(mid (and piem-add-message-id-header (piem-mid)))
(has-content nil))
(with-current-buffer buffer
@@ -353,7 +356,7 @@ buffer."
(goto-char (point-min))
(piem--insert-message-id-header mid)))
(if has-content
- (list buffer format)
+ (cons buffer format)
(kill-buffer buffer)
nil))))
@@ -546,7 +549,7 @@ for a list of possible properties).
If CODEREPO is given, switch to this directory before calling
`git am'."
(interactive
- (pcase-let ((`(,mbox ,format)
+ (pcase-let ((`(,mbox . ,format)
(or (piem-am-ready-mbox)
(user-error
"Could not find am-ready mbox for current buffer"))))