How can I set git-gutter:set-start-revision globally?
aguynamedben opened this issue · 3 comments
This library is awesome, thank you for making it available to everybody.
When I use git-gutter:set-start-revision
to set the start revision to a specific branch (i.e. my prerelease
branch), it applies only to the buffer I'm in.
My use case: I want to git-gutter to show all changes deviating from my prerelease
branch, across all buffers. That gives me an idea of the "working set" of changes I'm dealing with (i.e. it matches the diff in the branch's GitHub pull request).
How can I set that value globally? My use-package config:
(use-package git-gutter
:ensure t
:custom
(global-git-gutter-mode +1))
Maybe I need to set git-gutter:set-start-revision
to prerelease
when each buffer is displayed, or some other type of trigger, but I'm not sure how.
Thank you for this great library!
I think I need to use the "run hooks" documented in the README:
Run hook git-gutter-mode-on-hook when git-gutter-mode is turn on
https://github.com/syohex/emacs-git-gutter#run-hook
So I think I can catch the git-gutter hook git-gutter-mode-on-hook
then probably run (git-gutter:set-start-revision 'prerelease)
in response to that hook in the current buffer.
Does that seem right? Sorry I'm not very strong with Emacs Lisp and hooks, but that seems right.
Feel free to close this, or mark as a feature request to make this easier. If it's a feature request: it'd be cool if each git repo had a setting for git-gutter:set-start-revision
that was remembered by git-gutter, i.e. Project A has it set to master
, Project B has it set to prerelease
, and maybe git-gutter:get-start-revision
to see the current value for the current git repo.
Somewhat related: https://stackoverflow.com/questions/23344540/emacs-update-git-gutter-annotations-when-staging-or-unstaging-changes-in-magit/23364805#23364805
Hi there. I'm just starting to scan the issues in this project...
Sounds like what might be best in your case is to set git-gutter:start-revision
as a directory local variable, and then you can store which revision in the .dir-locals.el
file in each project directory?
Ok, I pushed some changes, namely updated documentation on the README, but more importantly some changes to ensure that the buffer local variable git-gutter:start-revision
isn't reset when the mode is initialized.
When the new release is up on MELPA (look for today's date in the version string) give it a try. You need to put a .dir-locals.el
file in the directory where you source files are. The contents of the file would be something like this:
;;; .dir-locals.el
((prog-mode . ((git-gutter:start-revision . "my-branch"))))
Where I'm suggesting "prog-mode" because you'll want this setting to apply to all source code, any language mode, inside that directory. And "my-branch" obviously you would adjust to be whatever branch or starting point you want to diff against.
Hope this helps...