When I press the "l" key in the main Magit status mode, it pops up a window where I can adjust the options to be passed to the magit log
command. Can I arrange for the --all
option to always be initially selected, just as the --graph
option is?
2 Answers
You can define a custom command to do what you want, and bind it to l
to override the default behavior:
(defun magit-log-all ()
(interactive)
(magit-key-mode-popup-logging)
(magit-key-mode-toggle-option (quote logging) "--all"))
(define-key magit-mode-map (kbd "l") 'magit-log-all)
With this in place, pressing l in magit-mode
automatically selects the --all
option in the menu that comes up.
Additional information
In case you are curious, here is how I arrived at the solution above: There are two steps involved in what you are currently doing to set options for git log
. First, you bring up the menu for choosing options by pressing l. To tell magit
to pass the --all
option to git log
, you then have to press -al
. If you want to define a custom command to automate this process, you need to know which commands are bound to these key presses. This information can be obtained by pressing C-h c (describe-key-briefly
) or C-h k (describe-key
) followed by the key sequence you want to examine.
C-h c l in a
magit-mode
buffer gives:l
runs the commandmagit-key-mode-popup-logging
C-h c -al after pressing l in a
magit-mode
buffer gives:- a l
runs the command(lambda nil (interactive) (magit-key-mode-toggle-option (quote logging) "--all"))
Equipped with this information, all that's left to do is create a command that calls the relevant functions in the right order.
-
I'd been hoping for a configuration setting, but this'll work fine. Other options include advising
magit-key-mode-popup-logging
and bindingl
to a keyboard macro.– SeanNov 8, 2014 at 21:55 -
@Sean I would open an issue on GitHub – it is noted in the code as something that needs to be made better; perhaps they were waiting for someone with the need. Nov 8, 2014 at 22:05
-
2No need for that, on the next branch support for setting default arguments is already implemented.– tarsiusNov 8, 2014 at 23:34
Beginning with v2.1.0
Magit's logging popup no longer features the --all
infix argument. Instead the popup provides three new related suffix commands.
- l L Log local branches (
--branches
) - l b Log all branches (
--branches --remotes
) - l a Log all references (
--all
)
While it is no longer possible (or necessary) to set the --all
argument, you might want to change the default value of some other argument. See How can I make `--verbose` flag be enabled by default in magit commit screen? for information about that.
magit-key-mode.el:715
--all
option to display, well, all of the log entries. My mistake! :)