I would like to arrange for Magit's minor mode
git-commit-mode to be enabled whenever a relevant Git file (e.g.
COMMIT_EDITMSG) is visited, from both within Emacs (e.g.
magit-commit) and without (e.g.
git commit with environment variables
EDITOR set to
emacsclient --create-frame --no-wait and
I would, however, like the loading of
git-commit.el to be deferred until such a file is visited, as loading it and its dependencies increases my Emacs startup time by nearly 100% (i.e. an extra
I have seen major modes usually tackle this problem by autoloading an addition to
auto-mode-alist. The single autoloaded entry-point that
git-commit.el defines, on the other hand, is the globalised minor mode itself, which modifies
find-file-hook instead. This means that there is no way (obvious to me) to enable the mode or read the value of
git-commit-filename-regexp without loading the package, its baggage and the kitchen sink.
What I have successfully done until now is add the equivalent of
(cons git-commit-filename-regexp #'git-commit-mode) to
auto-mode-alist (despite its being a minor mode), where I manually substitute the value of the
git-commit-filename-regexp as defined in the package.
- What effects does adding a minor mode entry to
auto-mode-alisthave compared to adding a major mode? Does it create a (potentially trivial) risk of breaking something, somewhere? Does this only work with
- Is there a more elegant or idiomatic solution for autoloading
git-commit-modespecifically and minor modes generally?
git-commit.elbe extended in some way to alleviate this issue?
Those interested, see here for the followup discussion and patch on the project's page.