discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH] piem-am: Clean up hidden buffers produced by interactive calls
Date: Tue, 11 Aug 2020 00:32:20 -0400	[thread overview]
Message-ID: <20200811043220.14679-1-kyle@kyleam.com> (raw)

When called interactively, piem-am retrieves the mbox with
piem-am-ready-mbox.  As piem-am-ready-mbox's docstring says, the
caller is responsible for cleaning up the buffer.  Make piem-am do so
to avoid leaving a hidden buffer around for each mbox applied.
 piem.el | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/piem.el b/piem.el
index ece30bd..6a3c2b3 100644
--- a/piem.el
+++ b/piem.el
@@ -553,12 +553,18 @@ (defun piem-am (mbox &optional format info coderepo)
                 (or (piem-am-ready-mbox)
                      "Could not find am-ready mbox for current buffer"))))
-     (list mbox
+     ;; We're responsible for cleaning up the buffer created by
+     ;; `piem-am-ready-mbox'; sneak in an indication to let the
+     ;; downstream code know.
+     (list (cons :interactive mbox)
            (piem-extract-mbox-info mbox)
   (setq format (or format "mboxrd"))
-  (let ((default-directory (or coderepo default-directory)))
+  (let ((default-directory (or coderepo default-directory))
+        (interactivep (eq (car-safe mbox) :interactive)))
+    (when interactivep
+      (setq mbox (cdr mbox)))
     (let ((new-branch (read-string
                        "New branch (empty for detached): "
                        (funcall piem-default-branch-function info)))
@@ -578,8 +584,11 @@ (defun piem-am (mbox &optional format info coderepo)
     (let ((args (cons (concat "--patch-format=" format)
       (if (bufferp mbox)
-          (apply #'piem-process-call-with-buffer-input
-                 nil mbox piem-git-executable "am" args)
+          (unwind-protect
+              (apply #'piem-process-call-with-buffer-input
+                     nil mbox piem-git-executable "am" args)
+            (when interactivep
+              (kill-buffer mbox)))
         (apply #'piem-process-call nil piem-git-executable "am"
                (append args (list mbox)))))
     (if (and piem-use-magit

base-commit: 2341b3403e607a1efd8cd47093cd7200bc63e521

                 reply	other threads:[~2020-08-11  4:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

  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=20200811043220.14679-1-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \


* 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


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).