From 2d75e4e5f0cc87fa40683fa0adba9582707a91d1 Mon Sep 17 00:00:00 2001 From: Elais Player Date: Wed, 20 May 2020 14:26:48 -0600 Subject: [PATCH] use doom-emacs magit buffer function I was spoiled by this behavior that was introduced to doom, so I decided to co-opt it for my own config. Thank you Henrik. --- init.el | 2 +- lisp/shao-vc.el | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index 46a731d..71d8099 100644 --- a/init.el +++ b/init.el @@ -33,7 +33,7 @@ :init (setq tao-theme-use-sepia nil) :config - (load-theme 'white t)) + (load-theme 'tao-yang t)) ;; Credentials (setq user-name "Elais Player" diff --git a/lisp/shao-vc.el b/lisp/shao-vc.el index ed53910..4cd88e3 100644 --- a/lisp/shao-vc.el +++ b/lisp/shao-vc.el @@ -1,7 +1,42 @@ ;;; shao-vc.el -*- lexical-binding: t; -*- +;; stolen from doom-emacs +;;;###autoload +(defun +magit-display-buffer-fn (buffer) + "Same as `magit-display-buffer-traditional', except... +- If opened from a commit window, it will open below it. +- Magit process windows are always opened in small windows below the current. +- Everything else will reuse the same window." + (let ((buffer-mode (buffer-local-value 'major-mode buffer))) + (display-buffer + buffer (cond + ((and (eq buffer-mode 'magit-status-mode) + (get-buffer-window buffer)) + '(display-buffer-reuse-window)) + ;; Any magit buffers opened from a commit window should open below + ;; it. Also open magit process windows below. + ((or (bound-and-true-p git-commit-mode) + (eq buffer-mode 'magit-process-mode)) + (let ((size (if (eq buffer-mode 'magit-process-mode) + 0.35 + 0.7))) + `(display-buffer-below-selected + . ((window-height . ,(truncate (* (window-height) size))))))) + + ;; Everything else should reuse the current window. + ((or (not (derived-mode-p 'magit-mode)) + (not (memq (with-current-buffer buffer major-mode) + '(magit-process-mode + magit-revision-mode + magit-diff-mode + magit-stash-mode + magit-status-mode)))) + '(display-buffer-same-window)))))) + (use-package magit :general - ("C-x g" 'magit-status)) + ("C-x g" 'magit-status) + :init + (setq magit-display-buffer-function #'+magit-display-buffer-fn)) (provide 'shao-vc) -- 2.45.2