From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id 0BUIIV8fMl84DAAAsNZ9tg (envelope-from ) for ; Tue, 11 Aug 2020 04:32:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mMS4HF8fMl9bLgAAbx9fmQ (envelope-from ) for ; Tue, 11 Aug 2020 04:32:31 +0000 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 955899404CF for ; Tue, 11 Aug 2020 04:32:30 +0000 (UTC) Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 590D17F2FB; Tue, 11 Aug 2020 00:32:28 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=sasl; bh=N35Y2wV5El3nMeS7rtXqFFeAxdk=; b=XyThDtmZ46s/csmZtf5N nM4XvnmXU4LnmuErvX79mIsFsnBNs9fbl1ZqSfsfEawHx9jSa2ffogrqvkhmqIuy ZY99caDZZbSJ8wgRuUgMdzdO+OoT0b4BiTapAKv3az37rE9NZR4i3/aE7bLcbRNU NFWJt3VYFcUSTGbgU0IPCdc= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 513067F2FA; Tue, 11 Aug 2020 00:32:28 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:subject:date:message-id:mime-version:content-transfer-encoding; s=mesmtp; bh=b670YpGs8jzQT6/JTofhnZoCwBkztGg+QMxj/NHdBRE=; b=PHI9zQkOczwD27bUoM4bIBNRt0uZ1JrJexoj1PXmAqi+WzOCSyT7KyM2ylKall04ff/DLd6YSy5S1g5si0t/MmDIo1xAOMB7bs6/m6j2/CVQkPNan9aDxzlWBarUWxNEraIhIP62ZnsjMEZdj1Wwitoh9KbDs5ATX2Mz26RfJvY= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id ACDF97F2F9; Tue, 11 Aug 2020 00:32:27 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer 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 Message-Id: <20200811043220.14679-1-kyle@kyleam.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Pobox-Relay-ID: A9668D0A-DB8B-11EA-AB9F-01D9BED8090B-24757444!pb-smtp1.pobox.com Content-Transfer-Encoding: quoted-printable X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=XyThDtmZ; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=PHI9zQkO; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 64.147.108.70 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: kPcaowvGiAeE 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=3D" 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 --=20 2.28.0