magit/magit — pull request #296 by sigma (2011-11-25 19:13:19+00:00)
Title: extensions as minor modes

This patch changes the strategy for loading magit extensions.

Until now, `require'-ing the extension file was sufficient to enable it for
every git repository. This is probably not the right behavior, because some
extensions might not apply to in every case.

For example, there is little sense using both topgit and stgit in the same
repo, but one could to use one or the other depending on the case.
Extensions such as https://github.com/sigma/magit-gh-pulls will make sense only
for repositories hosted in GitHub.

In any case, it would probably be desirable for the user to be able to toggle
the use of a specific extension.

We reach that goal by making extensions minor modes (as was initially quickly
discussed when I introduced extensions). For example, toggling
`magit-topgit-mode' while in the "status" buffer will make the "Topics" section
appear/disappear.

Therefore, extensions can now be loaded with code like:

(add-hook 'magit-mode-hook 'turn-on-magit-topgit)

Additionally, it is possible to introduce git configuration elements to
automatically load relevant extensions (configured on a global and/or per
repository basis)

(add-hook 'magit-mode-hook 'magit-load-config-extensions)

This will in effect call "git config --get-all magit.extension" in the
repository and load whatever extensions are required there

In the following case:
$ git config --get-all magit.extension
topgit
svn

the minor modes `magit-topgit-mode' and `magit-svn-mode' will be activated.

Comments welcome !