1
0
Fork 0

Make the diff server function clean up after itself

This commit is contained in:
Tom Willemse 2020-11-13 09:40:43 -08:00
parent 5892c9ede3
commit 690ec65a30

View file

@ -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")))
(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))