Procházet zdrojové kódy

Add handling for closing all magit buffers

Simon Watson před 2 roky
rodič
revize
4f739b94e2
2 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. 2 0
      emacs/.emacs-all
  2. 10 0
      emacs/elisp/helpers.el

+ 2 - 0
emacs/.emacs-all

@@ -185,6 +185,8 @@
   (load-theme 'solarized-light))
 
 ;; Keybinds/macros
+;;(global-set-key (kbd "C-c C-q") #'mu-magit-kill-buffers magit-status-mode-map)
+(global-set-key (kbd "C-c C-q") #'mu-magit-kill-buffers)
 (global-set-key (kbd "C-c ;") 'comment-line)
 (global-set-key (kbd "C-c b") 'fzf-switch-buffer)
 (global-set-key (kbd "C-c z") 'fzf-find-file)

+ 10 - 0
emacs/elisp/helpers.el

@@ -2,3 +2,13 @@
   (interactive)
   "Little helper for showing full file path in minibuffer"
   (message (buffer-file-name)))
+
+;;; See great post here:
+;;; https://www.manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/
+
+(defun mu-magit-kill-buffers ()
+  "Restore window configuration and kill all Magit buffers."
+  (interactive)
+  (let ((buffers (magit-mode-get-buffers)))
+    (magit-restore-window-configuration)
+    (mapc #'kill-buffer buffers)))