7

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?

  • The day will come when you don't want that, but by then it will be too late. – Sean Allred Nov 8 '14 at 3:48
  • See magit-key-mode.el:715 – Sean Allred Nov 8 '14 at 3:55
  • Too late for what? – Sean Nov 8 '14 at 21:56
  • Oh, my apologies :) I mistook the --all option to display, well, all of the log entries. My mistake! :) – Sean Allred Nov 8 '14 at 22:04
8

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.

  1. C-h c l in a magit-mode buffer gives:

    l runs the command magit-key-mode-popup-logging

  2. 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 binding l to a keyboard macro. – Sean Nov 8 '14 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. – Sean Allred Nov 8 '14 at 22:05
  • 2
    No need for that, on the next branch support for setting default arguments is already implemented. – tarsius Nov 8 '14 at 23:34
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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