tools/magit: larger fringe in magit-mode

Since Doom sets a small fringe by default, magit's fringe indicators are
obscured, so we increase it only while a magit-mode buffer is visible.
This commit is contained in:
Henrik Lissner 2021-05-22 22:24:59 -04:00
parent 5abba3642b
commit 6824b9270d

View file

@ -4,6 +4,14 @@
"What direction to open new windows from the status buffer.
For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
(defvar +magit-fringe-size 14
"Size of the fringe in magit-mode buffers.
Can be an integer or a cons cell whose CAR and CDR are integer widths for the
left and right fringe.
Only has an effect in GUI Emacs.")
;;
;;; Packages
@ -106,6 +114,17 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
;; Close transient with ESC
(define-key transient-map [escape] #'transient-quit-one)
(add-hook! 'magit-mode-hook
(add-hook! 'window-configuration-change-hook :local
(defun +magit-enlargen-fringe-h ()
"Make fringe larger in magit."
(and (display-graphic-p)
(derived-mode-p 'magit-mode)
+magit-fringe-size
(let ((left (or (car-safe +magit-fringe-size) +magit-fringe-size))
(right (or (cdr-safe +magit-fringe-size) +magit-fringe-size)))
(set-window-fringes nil left right))))))
;; An optimization that particularly affects macOS and Windows users: by
;; resolving `magit-git-executable' Emacs does less work to find the
;; executable in your PATH, which is great because it is called so frequently.