Add function madots to use magit for dotfiles. Hacky but mostly works.

This commit is contained in:
MitchMarq42 2022-11-15 21:03:37 -09:00
parent 2aefe688ad
commit d5dadb6ad1

View File

@ -784,8 +784,30 @@ See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode
(corfu-terminal-mode +1))) (corfu-terminal-mode +1)))
(use-package magit (use-package magit
:commands magit :commands (madots magit-status magit)
:hook (magit-mode . turn-off-line-numbers)) :hook (magit-mode . turn-off-line-numbers)
:config
(defun madots--magit-buffers-p ()
(not (not ; converts all non-nil values to t
(remove nil ; clean useless elements
(mapcar (lambda (buffer)
(if (string-match-p "magit: " (buffer-name buffer))
buffer))
(buffer-list))))))
(defun madots--cleanup ()
"Remove modifications made for `madots' once all magit buffers are killed."
(if (not (madots--magit-buffers-p))
(progn
(setq magit-git-executable madots--old-magit-exe)
(cancel-function-timers #'madots--cleanup))))
(defun madots (&optional exe)
"Magit but with custom EXE, default \"dots\"."
(interactive)
(require 'magit)
(setq madots--old-magit-exe magit-git-executable)
(setq magit-git-executable (or exe "dots"))
(magit-status)
(run-with-timer 5 3 #'madots--cleanup)))
(use-package hyperbole (use-package hyperbole
;; :straight (:type built-in) ;; doesn't work ;; :straight (:type built-in) ;; doesn't work