Ensures magit buffers are cleaned up after magit-status is closed. Will defer cleanup on process buffers, until the processes have finished. Also fixes issue where quitting magit will leave leftover windows.
22 lines
718 B
EmacsLisp
22 lines
718 B
EmacsLisp
;;; tools/magit/autoload.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###autoload
|
|
(defun +magit/quit (&optional _kill-buffer)
|
|
"Clean up magit buffers after quitting `magit-status'."
|
|
(interactive)
|
|
(let ((buffers (magit-mode-get-buffers)))
|
|
(magit-restore-window-configuration)
|
|
(mapc #'+magit--kill-buffer buffers)))
|
|
|
|
(defun +magit--kill-buffer (buf)
|
|
"TODO"
|
|
(when (and (bufferp buf) (buffer-live-p buf))
|
|
(let ((process (get-buffer-process buf)))
|
|
(if (not (processp process))
|
|
(kill-buffer buf)
|
|
(with-current-buffer buf
|
|
(if (process-live-p process)
|
|
(run-with-timer 5 nil #'+magit--kill buf)
|
|
(kill-process process)
|
|
(kill-buffer buf)))))))
|
|
|