discussion and development of piem
 help / color / mirror / Atom feed
* [PATCH] piem-am: Clean up hidden buffers produced by interactive calls
@ 2020-08-11  4:32 Kyle Meyer
  0 siblings, 0 replies; only message in thread
From: Kyle Meyer @ 2020-08-11  4:32 UTC (permalink / raw)
  To: piem

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)
                     (user-error
                      "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)
            format
            (piem-extract-mbox-info mbox)
            (piem-inbox-coderepo-maybe-read))))
   (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)
                       piem-am-args)))
       (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
-- 
2.28.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-11  4:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11  4:32 [PATCH] piem-am: Clean up hidden buffers produced by interactive calls Kyle Meyer

discussion and development of piem

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.kyleam.com/piem/0 piem/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 piem piem/ https://inbox.kyleam.com/piem \
		piem@inbox.kyleam.com
	public-inbox-index piem

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.piem


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git