Make the diff server function clean up after itself
This commit is contained in:
parent
5892c9ede3
commit
690ec65a30
1 changed files with 18 additions and 4 deletions
16
oni-ediff.el
16
oni-ediff.el
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2020.1106.164913
|
;; Version: 2020.1113.093948
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; 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
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -52,9 +52,23 @@
|
||||||
(pcase files
|
(pcase files
|
||||||
((and `((,fileB) (,fileA) (,command))
|
((and `((,fileB) (,fileA) (,command))
|
||||||
(guard (string= (file-name-nondirectory command) "diff")))
|
(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))
|
(select-frame-set-input-focus (selected-frame))
|
||||||
(ediff-files (expand-file-name fileA)
|
(ediff-files (expand-file-name fileA)
|
||||||
(expand-file-name fileB))
|
(expand-file-name fileB))
|
||||||
|
(add-hook 'ediff-cleanup-hook cleanup-function))
|
||||||
nil)
|
nil)
|
||||||
(_
|
(_
|
||||||
(message "Got args: \"%s\"" (list files proc nowait))
|
(message "Got args: \"%s\"" (list files proc nowait))
|
||||||
|
|
Loading…
Reference in a new issue