Right now, instead of pressing just cc
in magit-mode, I have to press c-vc
every time to enable --verbose
.
Is it possible to make it enabled by default?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityBeginning with v2.1.0
, Magit uses the library magit-popup.el
to implement such "popup buffers" or "prefix-infix-suffix combos". Despite its name, that library can be used by packages not related to Magit, and is therefore made available as a separate Elpa package. It even has its own manual now!
Default arguments can now be set directly from a popup buffer. To always use --verbose
when committing do this:
--verbose
magit-commit-arguments
)By default all popup buffers end with a section named "Common Commands". If not, use C-t to show it. You probably don't want to see that section all the time and should therefore set magit-popup-show-common-commands
to nil
.
Of course it is also possible to set the value of magit-commit-arguments
and other such variables using the Custom interface, setq
, or add-to-list
. But I recommend against that, because that would make it impossible to change the defaults on-the-fly.
As far as I can tell Magit does not keep track of "default" options, but we can make it "press -v
" every time the Committing buffer pops up:
(advice-add #'magit-key-mode-popup-committing :after
(lambda ()
(magit-key-mode-toggle-option (quote committing) "--verbose")))
To find what function to advise, I opened a magic-status
buffer and pressed C-h k c
. This led me to magit-key-mode-popup-committing
. Then (with the Committing buffer still displayed) I pressed C-h k -v
to find the lambda
form Magit calls when you press -v
in the Committing window.
Update: I did write this answer independently, but see Can I have the git-log “--all” option be initially selected?, the answer given there, and comments to that answer.
In the versions of magit that use transient (after February 2019 or so), set the flag, and then save while still in the transient buffer.
So for commit, the key sequence would be something like
C-x g # start magit
s # to stage changes
c # start commiting
-v # enable verbose
C-x C-s # Save the setting persistently across sessions
c # do the actual commit
After that, next time commit is invoked, verbose will still be set. (You do not have to complete the commit, and can exit after saving with C-x C-s
.)
The actual default is saved in a transient/
directory in .emacs.d/
.
See the transient manual https://magit.vc/manual/transient.html#Saving-Values
While it's not exactly what you want (diff in your commit buffer), you can set magit to expand the staged diffs in the status window:
(setq magit-expand-staged-on-commit 'full)
The magit workflow seems to always be open status buffer and then open split with commit buffer, you always end up with two buffers displayed. The above setting will make the second (previously not useful) buffer display your diff.
You can also use t
to only expand the diff headers (so it shows the line numbers):
(setq magit-expand-staged-on-commit t)
While writing your diff, you can switch to the status buffer and use TAB
to expand (or fold) the diffs.
Alternatively, you can use C-c C-d
from the commit buffer to open another buffer with a diff with magit-diff-staged
. (See this issue.)
As of magit
version 2.1
, you can use this in your config:
;; When commiting enable verbose mode by default.
(setq magit-commit-arguments (quote ("--verbose")))
--no-verify
is useful when you have projects that use git hooks (use with caution, obviously).