aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--oni-ediff.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/oni-ediff.el b/oni-ediff.el
index cb52386..1d6d860 100644
--- a/oni-ediff.el
+++ b/oni-ediff.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2020.1106.164913
+;; Version: 2020.1113.093948
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -52,9 +52,23 @@
(pcase files
((and `((,fileB) (,fileA) (,command))
(guard (string= (file-name-nondirectory command) "diff")))
- (select-frame-set-input-focus (selected-frame))
- (ediff-files (expand-file-name fileA)
- (expand-file-name fileB))
+ (let* ((file-a-path (expand-file-name fileA))
+ (file-b-path (expand-file-name fileB))
+ (file-a-opened-p (find-buffer-visiting fileA))
+ (file-b-opened-p (find-buffer-visiting fileB))
+ cleanup-function)
+ (setq cleanup-function
+ (lambda ()
+ (remove-hook 'ediff-cleanup-hook cleanup-function)
+ (when (not file-a-opened-p)
+ (kill-buffer (find-buffer-visiting file-a-path)))
+ (when (not file-b-opened-p)
+ (kill-buffer (find-buffer-visiting file-b-path)))
+ (delete-process proc)))
+ (select-frame-set-input-focus (selected-frame))
+ (ediff-files (expand-file-name fileA)
+ (expand-file-name fileB))
+ (add-hook 'ediff-cleanup-hook cleanup-function))
nil)
(_
(message "Got args: \"%s\"" (list files proc nowait))