* bug#74881: 31.0.50; [PATCH] * lisp/vc/ediff-util.el: Remove temp files on kill-emacs
@ 2024-12-15 5:59 Lin Sun
2024-12-15 8:04 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Lin Sun @ 2024-12-15 5:59 UTC (permalink / raw)
To: 74881
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
The ediff lefts temporary files "/tmp/fineDiff*" when kill emacs during an ediff comparing.
Reproducing steps:
1. echo 0 > /tmp/0; echo 1 > /tmp/1
2. emacs -nw -q -f ediff-files-command /tmp/0 /tmp/1
on the ediff control buffer, press "n" to move to first difference; there should have two temp files like /tmp/fineDiffA* and /tmp/fineDiffB* were generated by ediff, stay on the ediff buffer (do not press "q" to quit the ediff session). then
3. Press "C-x C-c" or kill-emacs to quit the emacs directly.
Then two temp files /tmp/fineDiff* were left there.
This patch will make sure the temp files be removed when kill-emacs without quitting the ediff session.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-vc-ediff-util.el-Remove-temp-files-on-kill-emac.patch --]
[-- Type: text/x-patch; name="0001-lisp-vc-ediff-util.el-Remove-temp-files-on-kill-emac.patch", Size: 1195 bytes --]
From dee9750144df6cdd827397f3d97e74f56e25e1fa Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Sun, 15 Dec 2024 06:52:17 +0000
Subject: [PATCH] * lisp/vc/ediff-util.el: Remove temp files on kill-emacs
---
lisp/vc/ediff-util.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index 6038f3eae30..fb47b3f7563 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -213,6 +213,12 @@ ediff-setup-keymap
(fset 'ediff-mode-map ediff-mode-map)
(run-hooks 'ediff-keymap-setup-hook))
+(defun ediff--delete-temp-files-on-kill-emacs ()
+ "Delete the temp-files associated with the ediff buffers."
+ (dolist (b (buffer-list))
+ (with-current-buffer b
+ (when (eq major-mode 'ediff-mode)
+ (ediff-delete-temp-files)))))
;;; Setup functions
@@ -488,6 +494,7 @@ ediff-setup
(if (ediff-buffer-live-p ediff-meta-buffer)
(ediff-update-meta-buffer
ediff-meta-buffer nil ediff-meta-session-number))
+ (add-hook 'kill-emacs-hook #'ediff--delete-temp-files-on-kill-emacs)
(run-hooks 'ediff-startup-hook)
) ; eval in control-buffer
control-buffer))
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#74881: 31.0.50; [PATCH] * lisp/vc/ediff-util.el: Remove temp files on kill-emacs
2024-12-15 5:59 bug#74881: 31.0.50; [PATCH] * lisp/vc/ediff-util.el: Remove temp files on kill-emacs Lin Sun
@ 2024-12-15 8:04 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2024-12-15 8:04 UTC (permalink / raw)
To: Lin Sun; +Cc: 74881
> From: Lin Sun <sunlin7@hotmail.com>
> Date: Sun, 15 Dec 2024 05:59:40 +0000
>
> @@ -488,6 +494,7 @@ ediff-setup
> (if (ediff-buffer-live-p ediff-meta-buffer)
> (ediff-update-meta-buffer
> ediff-meta-buffer nil ediff-meta-session-number))
> + (add-hook 'kill-emacs-hook #'ediff--delete-temp-files-on-kill-emacs)
> (run-hooks 'ediff-startup-hook)
> ) ; eval in control-buffer
> control-buffer))
This should be carefully programmed to avoid preventing Emacs from
exiting due to some problem. If ediff-delete-temp-files or one of the
functions it calls can signal an error, it should be wrapped by
condition-case, and if it or one of its callees can try interacting
with the user, we should use kill-emacs-query-functions instead.
Alternatively, we could end the Ediff session when Emacs is killed.
Bottom line: this is a minor cleanup feature, so we should be very
careful not to cause any regressions and problems just because we want
to exit more cleanly. (On most systems, files in /tmp are routinely
deleted by system's cleanup processes anyway.)
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-15 8:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-15 5:59 bug#74881: 31.0.50; [PATCH] * lisp/vc/ediff-util.el: Remove temp files on kill-emacs Lin Sun
2024-12-15 8:04 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).