Revert +hub flag, but disable magithub by default

Must be enabled on a per-project basis. You can change this behavior by
setting +magit-hub-enabled-by-default to non-nil (before magit is
loaded).

Magithub has been made opt-in because:

1. Magithub is imposing, asking the user for a token, especially for
   users who don't use github (much or at all), but may occasionally
   have a project with a github remote.
2. magithub is really slow on first load for medium-to-large repos.
3. It's really easy to enable it through the magithub popup (H C e).
   magithub.enabled is saved into the project's .git/config file, so the
   setting will persist.

Also added a docstring to +magit-hub-features
This commit is contained in:
Henrik Lissner 2018-06-01 10:53:08 +02:00
parent 592205e1dd
commit bab530ea2e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 31 additions and 3 deletions

View file

@ -56,7 +56,7 @@
;gist ; interacting with github gists ;gist ; interacting with github gists
;macos ; MacOS-specific commands ;macos ; MacOS-specific commands
;make ; run make tasks from Emacs ;make ; run make tasks from Emacs
;(magit +hub) ; ;magit ;
;password-store ; password manager for nerds ;password-store ; password manager for nerds
pdf ; pdf enhancements pdf ; pdf enhancements
;prodigy ; FIXME managing external services & code builders ;prodigy ; FIXME managing external services & code builders

View file

@ -51,3 +51,19 @@ format."
.owner.login .name))) .owner.login .name)))
(magithub-clone repo dir))) (magithub-clone repo dir)))
(magit-clone url-or-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))

View file

@ -1,8 +1,12 @@
;;; tools/magit/config.el -*- lexical-binding: t; -*- ;;; 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 (defvar +magit-hub-features
'(pull-request-merge commit-browse completion) '(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 (def-package! magithub
:when (featurep! +hub)
:after magit :after magit
:preface :preface
(setq magithub-dir (concat doom-etc-dir "magithub/")) (setq magithub-dir (concat doom-etc-dir "magithub/"))
@ -37,6 +40,15 @@
(setq magithub-clone-default-directory "~/" (setq magithub-clone-default-directory "~/"
magithub-preferred-remote-method 'clone_url) magithub-preferred-remote-method 'clone_url)
:config :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)) (magithub-feature-autoinject +magit-hub-features))