18

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?

5 Answers 5

22

Beginning 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:

  1. c Show the committing popup
  2. - v Turn on --verbose
  3. C-x C-s Save the currently set arguments as defaults (in the custom option 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.

0
7

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.

2
  • 1
    That's interesting! Thank you for also explaining how you found those functions :)
    – Dogbert
    Nov 26, 2014 at 10:59
  • @Dogbert: please see the link in the updated answer if you care to know that others thought about default git options not that long ago. :-) (I don't know how I missed that yesterday.) Nov 27, 2014 at 6:56
4

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

0

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.)

0

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")))
4
  • You shouldn't do that. See my answer.
    – tarsius
    Jul 3, 2015 at 14:57
  • @tarsius You have a valid point. My usecase is that I sync my dotfiles between multiple computers and when I set a default it should be default on all my computers. If I want to change it, I'll just change it in my config and it will be synced across all my computers.
    – Maiku Mori
    Jul 3, 2015 at 15:01
  • 1
    Oh and I don't use the custom options because it makes my config hard to document. I prefer to set everything explicitly.
    – Maiku Mori
    Jul 3, 2015 at 15:04
  • Also, setting --no-verify is useful when you have projects that use git hooks (use with caution, obviously).
    – yurisich
    Aug 31, 2016 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.