Skip to content

Commit

Permalink
Remove temp files /tmp/fineDiff* for kill-emacs without quit ediff
Browse files Browse the repository at this point in the history
* core/core-versions.el: New macro spacemacs/block-before-emacs-min-version
* layers/+spacemacs/spacemacs-defaults/funcs.el: New function
    spacemacs//ediff-delete-temp-files.
* layers/+spacemacs/spacemacs-defaults/packages.el: Use
    spacemacs//ediff-delete-temp-files on the kill-emacs-hook
  • Loading branch information
sunlin7 authored and Lin Sun committed Dec 30, 2024
1 parent c5fc206 commit c712025
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions core/core-versions.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@
(defconst spacemacs-version "0.999.0" "Spacemacs version.")
(defconst spacemacs-emacs-min-version "28.2" "Minimal version of Emacs.")

(defmacro spacemacs/block-before-emacs-min-version (version msg &rest body)
"Apply the BODY if `spacemacs-emacs-min-version' < VERSION, otherwise
warn the MSG."
(declare (indent 1))
`(if (version< spacemacs-emacs-min-version ,version)
(progn ,@body)
(apply 'warn
(if ,msg '("%s" ,msg)
'("Minimum emacs version %s is newer than supported version %s"
,version spacemacs-emacs-min-version)))))

(provide 'core-versions)
11 changes: 11 additions & 0 deletions layers/+spacemacs/spacemacs-defaults/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,17 @@ variable."
(ediff-files (dotspacemacs/location)
(concat dotspacemacs-template-directory ".spacemacs.template")))

(spacemacs/block-before-emacs-min-version "31.0.50"
"Use builtin `ediff--delete-temp-files-on-kill-emacs' first"

(defun spacemacs//ediff-delete-temp-files ()
"Delete the temp-files associated with the ediff buffers."
(let ((inhibit-interaction t))
(dolist (b ediff-session-registry)
(ignore-errors
(with-current-buffer b
(ediff-delete-temp-files)))))))

(defun spacemacs/new-empty-buffer (&optional split)
"Create a new buffer called: \"untitled\".
Expand Down
4 changes: 3 additions & 1 deletion layers/+spacemacs/spacemacs-defaults/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@
(require 'outline)
(add-hook 'ediff-prepare-buffer-hook #'show-all)
;; restore window layout when done
(add-hook 'ediff-quit-hook #'winner-undo)))
(add-hook 'ediff-quit-hook #'winner-undo)
(when (fboundp 'spacemacs//ediff-delete-temp-files)
(add-hook 'kill-emacs-hook #'spacemacs//ediff-delete-temp-files))))

(defun spacemacs-defaults/init-eldoc ()
(use-package eldoc
Expand Down

0 comments on commit c712025

Please sign in to comment.