tools/magit: clean up after magit more intelligently #506
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.
This commit is contained in:
parent
ee921f581d
commit
460461ef54
3 changed files with 23 additions and 8 deletions
|
@ -345,3 +345,6 @@ with `org-cycle')."
|
||||||
((org-in-src-block-p)
|
((org-in-src-block-p)
|
||||||
(org-babel-remove-result)
|
(org-babel-remove-result)
|
||||||
t)))))
|
t)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defalias #'+org/toggle-fold #'+org|toggle-only-current-fold)
|
||||||
|
|
|
@ -2,9 +2,21 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +magit/quit (&optional _kill-buffer)
|
(defun +magit/quit (&optional _kill-buffer)
|
||||||
"TODO"
|
"Clean up magit buffers after quitting `magit-status'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(magit-restore-window-configuration)
|
(let ((buffers (magit-mode-get-buffers)))
|
||||||
(cl-loop for buf in (doom-buffers-in-mode 'magit-mode (buffer-list) t)
|
(magit-restore-window-configuration)
|
||||||
unless (eq (buffer-local-value 'major-mode buf) 'magit-process-mode)
|
(mapc #'+magit--kill-buffer buffers)))
|
||||||
do (kill-buffer buf)))
|
|
||||||
|
(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)))))))
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
#'magit-builtin-completing-read)
|
#'magit-builtin-completing-read)
|
||||||
magit-revision-show-gravatars '("^Author: " . "^Commit: "))
|
magit-revision-show-gravatars '("^Author: " . "^Commit: "))
|
||||||
|
|
||||||
(add-hook 'magit-popup-mode-hook #'hide-mode-line-mode)
|
|
||||||
(set! :popup "^\\(?:\\*magit\\|magit:\\)" :ignore)
|
(set! :popup "^\\(?:\\*magit\\|magit:\\)" :ignore)
|
||||||
|
;; no mode-line in magit popups
|
||||||
|
(add-hook 'magit-popup-mode-hook #'hide-mode-line-mode)
|
||||||
;; Clean up after magit by properly killing buffers
|
;; Clean up after magit by properly killing buffers
|
||||||
(setq magit-bury-buffer-function #'+magit/quit)
|
(map! :map magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit))
|
||||||
(map! :map magit-mode-map [remap quit-window] #'+magit/quit))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! magit-blame
|
(def-package! magit-blame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue