소스 검색

Add handling for closing all magit buffers

Simon Watson 2 년 전
부모
커밋
4f739b94e2
2개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  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)))