~elais/shaolin-emacs-archive

2d75e4e5f0cc87fa40683fa0adba9582707a91d1 — Elais Player 4 years ago 7ac7ace
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.
2 files changed, 37 insertions(+), 2 deletions(-)

M init.el
M lisp/shao-vc.el
M init.el => init.el +1 -1
@@ 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"

M lisp/shao-vc.el => lisp/shao-vc.el +36 -1
@@ 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)