GNU bug report logs - #77323
[PATCH] Allow temp buffer cleanup in ediff-current-file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: "Paul D. Nelson" <ultrono@HIDDEN>; Keywords: patch; dated Thu, 27 Mar 2025 21:55:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Mar 2025 21:54:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 17:54:27 2025
Received: from localhost ([127.0.0.1]:51642 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1txvBC-0004td-H6
	for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 17:54:26 -0400
Received: from lists.gnu.org ([2001:470:142::17]:60124)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1txvB9-0004tQ-Jr
 for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 17:54:24 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ultrono@HIDDEN>) id 1txvB3-0007Ol-TU
 for bug-gnu-emacs@HIDDEN; Thu, 27 Mar 2025 17:54:17 -0400
Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <ultrono@HIDDEN>) id 1txvB2-0004hG-0a
 for bug-gnu-emacs@HIDDEN; Thu, 27 Mar 2025 17:54:17 -0400
Received: by mail-ej1-x62d.google.com with SMTP id
 a640c23a62f3a-aaecf50578eso254586066b.2
 for <bug-gnu-emacs@HIDDEN>; Thu, 27 Mar 2025 14:54:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743112453; x=1743717253; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Os76LRMUmokI6zD2LQp8Vx0Cvi1uA8BtVKCnM2qFzfs=;
 b=VCO7rtd7UdOuFu/FjhxupkAnKxADc6acigwF78HF8EyI24b5DSEXWKOxDIvZ9iJV8A
 rnfsBEfr0x382736dm4H0JTWaUw2LVAmW4nyu2LhokvW4qSgkCaZ7aSLSusiwjhqJ9hK
 n7p6gGumi2S87QKZKmzB5tWWSFoocZgc3b7PSU6tHqYZnr3XL8S1lfuDkNYdj0taD1qc
 NzW6KBJhx9JGJt6WMQooSzcOMRqP2RIGPFYvxOLNj/3T6o23RCzlcXg30HCVEHAscSw5
 WPhbO96hlgLb7tr2N390bzwunMwlsh6Hd+zjzF+HELIbbgC5raFWYDH84G6QRaU8CVZx
 Z/cw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743112453; x=1743717253;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Os76LRMUmokI6zD2LQp8Vx0Cvi1uA8BtVKCnM2qFzfs=;
 b=AESegHQCk2xtizlhE/hHk+bit0KWGl48Xi/BY7c88BC7K3yVZcdRKA4hpHm2D7QBU0
 OXRLTLRrPMclvIbK/2/LAivq57uRmhRNarlf/X4JIRzwYemosSu/V+nPeltagLXGubgo
 DGPK+udVW5juDHrPtaHH8PvwUDjkQ3m2uN+wEvxo1KSR2dAqy/XMmkBnj9QWnOHWpVyd
 aatd37K49zbQcsT6fIdfoI4ThFwZn0preiSZGXySEa0sxuprbfnkXgnxudCeujTnB3vz
 NfYI8uNGTsUHLAfxCC1/tHiStoWdKqZoQJBg03N9p3FL283tYXpWGSffQzI+HH2YjoFi
 wwhw==
X-Gm-Message-State: AOJu0Yz89FTwEMECqz/69ahdYlqEBamrLlCzZReGsAC5CnPlXUICeI7d
 V8eWb+7uEO/QOWyD5+W6G5gvNimw0G+W32DUU5d1pKuR/DZY2Ynwnrll+gZ3
X-Gm-Gg: ASbGnctkmGv9dVekIKJrw15+0nxS+Qgiqet/qtAywWuKD0oS0YAk1DqiMps0/0JfygH
 3l/gq1kr7Kn2gPZ3R3Pyes55XCztz/tCrmyM5A6f5WAstQSWClLT3crGZ4Giem0q/ouGcdzGYwT
 xkZv/vNHA+WNzfbURQIkrklZuegVfm9WH/DdFDJrNMW4649qRZIHTPkrP4wR9Bv6yKOIJDx1RgZ
 Kuj7GIKGSKMM62OdSBB6NJJesz+OymQYV9wNXian/25D1AfXuOsi994gNBVpBn4pyVtYaSVcK4j
 cNaPj1mU4is0p3kEo8uUVidj14d7bKwZ0M3Zyge/kpVvidmaiCg4V24tUEiq6VzH
X-Google-Smtp-Source: AGHT+IGc2TrYHIE2hoInN1uZD9mgTPTANoCuJ2C8vKPvn4f4tniWifkUlLQSZRYs0BU+XvmjRzYEgw==
X-Received: by 2002:a17:907:1b02:b0:ac2:9e1a:bf81 with SMTP id
 a640c23a62f3a-ac6faeb12edmr508314766b.21.1743112453049; 
 Thu, 27 Mar 2025 14:54:13 -0700 (PDT)
Received: from localhost ([130.225.16.16]) by smtp.gmail.com with UTF8SMTPSA id
 a640c23a62f3a-ac71927b205sm58953166b.60.2025.03.27.14.54.12
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 27 Mar 2025 14:54:12 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Allow temp buffer cleanup in ediff-current-file
Date: Thu, 27 Mar 2025 22:51:57 +0100
Message-ID: <uxsg7tmsd6i1ky.fsf@HIDDEN>
X-Debbugs-Cc: 
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::62d;
 envelope-from=ultrono@HIDDEN; helo=mail-ej1-x62d.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain

When ediff-current-file compares a modified buffer with its saved
version, it creates a temporary "FILE=..." buffer to hold the saved
contents.  Currently, this buffer persists after the Ediff session
quits, requiring manual cleanup later.

In my experience, this buffer serves no further purpose once the
comparison is done, and just clutters the buffer list.  On the other
hand, I could imagine someone using it as a way to retain a snapshot of
the saved file state.

The attached patch introduces a user option that, when non-nil, causes
the "FILE=..." buffer to be killed automatically after quitting Ediff.

The default is nil, so that the patch does not modify existing behavior.

Such automatic cleanup does not seem achievable via existing Ediff
hooks.

Any feedback would be welcome.

Thanks, best,

Paul


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment

From c0a6429b5672f43114d7d67e268f31998723071d Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@HIDDEN>
Date: Thu, 27 Mar 2025 22:00:08 +0100
Subject: [PATCH] Allow temp buffer cleanup in ediff-current-file

* lisp/vc/ediff.el
(ediff-current-file-cleanup-temporary-buffer): New custom option
that controls whether to kill the temporary buffer created by
ediff-current-file.
(ediff-current-file): Use it.
---
 etc/NEWS         |  5 +++++
 lisp/vc/ediff.el | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 1bd2fd6d486..7fbd6f830af 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1199,6 +1199,11 @@ is non-nil, this suffix is fontified using 'font-lock-type-face'.
 
 ** Ediff
 
++++
+*** New user option 'ediff-current-file-cleanup-temporary-buffer'.
+This option controls whether to kill the 'FILE=...' buffer created by
+'ediff-current-file' when the Ediff session exits.
+
 +++
 *** Ediff's copy commands now apply to all changes with 'C-u' prefix.
 The Ediff copy commands, bound to 'a', 'b', 'ab', etc., now copy all
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 36580c73d6b..401c6e2c119 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -359,6 +359,12 @@ ediff-files-internal
 ;;;###autoload
 (defalias 'ediff #'ediff-files)
 
+(defcustom ediff-current-file-cleanup-temporary-buffer nil
+  "If non-nil, kill the 'FILE=...' buffer created by `ediff-current-file'.
+If this option is non-nil, the buffer is killed automatically when the
+Ediff session ends.  Otherwise, the buffer is preserved."
+  :type 'boolean)
+
 ;;;###autoload
 (defun ediff-current-file ()
   "Start ediff between current buffer and its file on disk.
@@ -395,7 +401,14 @@ ediff-current-file
       (insert-file-contents file-name)
       ;; Assume same modes:
       (funcall current-major))
-    (ediff-buffers revert-buf (current-buffer))))
+    (ediff-buffers revert-buf (current-buffer)
+                   (when ediff-current-file-cleanup-temporary-buffer
+                     (list (lambda ()
+                             (add-hook 'ediff-quit-hook
+                                       (lambda ()
+                                         (when (buffer-live-p revert-buf)
+                                           (kill-buffer revert-buf)))
+                                       nil t)))))))
 
 
 ;;;###autoload
-- 
2.39.3 (Apple Git-145)


--=-=-=--




Acknowledgement sent to "Paul D. Nelson" <ultrono@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#77323; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 27 Mar 2025 22:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.