aboutsummaryrefslogtreecommitdiffstats
path: root/oni-ediff.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-11-13 09:40:43 -0800
committerGravatar Tom Willemse2020-11-13 09:40:43 -0800
commit690ec65a30bea59b77a4cec1c21814b077a04c13 (patch)
tree9f2b385add6ff1cb8018a362458b97cdec5a9cca /oni-ediff.el
parent5892c9ede32d923d7186cfb02280458fe06a60ce (diff)
downloademacs-config-690ec65a30bea59b77a4cec1c21814b077a04c13.tar.gz
emacs-config-690ec65a30bea59b77a4cec1c21814b077a04c13.zip
Make the diff server function clean up after itself
Diffstat (limited to 'oni-ediff.el')
-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))