diff --git a/init.example.el b/init.example.el index bd4a173e0..027fcacd1 100644 --- a/init.example.el +++ b/init.example.el @@ -56,7 +56,7 @@ ;gist ; interacting with github gists ;macos ; MacOS-specific commands ;make ; run make tasks from Emacs - ;(magit +hub) ; + ;magit ; ;password-store ; password manager for nerds pdf ; pdf enhancements ;prodigy ; FIXME managing external services & code builders diff --git a/modules/tools/magit/autoload.el b/modules/tools/magit/autoload.el index 925032f49..9645426e8 100644 --- a/modules/tools/magit/autoload.el +++ b/modules/tools/magit/autoload.el @@ -51,3 +51,19 @@ format." .owner.login .name))) (magithub-clone repo dir))) (magit-clone url-or-repo dir))) + + +;; +;; Advice +;; + +;;;###autoload +(defun +magit*hub-settings--format-magithub.enabled () + "Change the setting to display 'false' as its default." + (magit--format-popup-variable:choices "magithub.enabled" '("true" "false") "false")) + +;;;###autoload +(defun +magit*hub-enabled-p () + "Disables magithub by default." + (magithub-settings--value-or "magithub.enabled" nil + #'magit-get-boolean)) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 0fb3d7155..488d4a7a5 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -1,8 +1,12 @@ ;;; tools/magit/config.el -*- lexical-binding: t; -*- +(defvar +magit-hub-enable-by-default nil + "Whether or not to enable magithub features for all projects by default.") + (defvar +magit-hub-features '(pull-request-merge commit-browse completion) - "TODO") + "What features to initialize when `magithub' is loaded. Set this to `t' to +load everything.") ;; @@ -29,7 +33,6 @@ (def-package! magithub - :when (featurep! +hub) :after magit :preface (setq magithub-dir (concat doom-etc-dir "magithub/")) @@ -37,6 +40,15 @@ (setq magithub-clone-default-directory "~/" magithub-preferred-remote-method 'clone_url) :config + (unless +magit-hub-enable-by-default + ;; Disable magit by default. Can be enabled through magithub settings popup, + ;; or setting `+magit-hub-enable-by-default'. + (advice-add #'magithub-enabled-p :override #'+magit*hub-enabled-p) + ;; I don't use `magithub-settings--simple' to redefine this because it + ;; changes the order of settings. Obnoxious, but the alternative is even + ;; more so. + (advice-add #'magithub-settings--format-magithub.enabled + :override #'+magit*hub-settings--format-magithub.enabled)) (magithub-feature-autoinject +magit-hub-features))