1

Every time I open Magit status buffer I need to press ?. How can I make it so it opens automatically?

doing this didn't help

(add-hook 'magit-mode 'magit-dispatch-popup)  

1 Answer 1

5

There's no hook variable named magit-mode. You were looking for magit-mode-hook (mode hooks are always named MODENAME-hook). That's not the solution here, though.

I can only imagine this very quickly going from "I have to press ? every time to get the help" to "I have to press q every time to dismiss the help", however you can do what you've asked for by defining some after-advice for magit-status:

(defadvice magit-status (after my-magit-status-dispatch-popup)
  (magit-dispatch-popup))
(ad-activate 'magit-status)

n.b. That won't trigger for anything other than calling magit-status, so refreshing the status buffer (which calls magit-refresh) won't do it (which I think is a good thing).


Edit: In more recent versions of Magit the above code causes a byte-compilation warning (see comments), but you could use the following variation instead:

(defadvice magit-status (after my-magit-status-dispatch)
  (call-interactively 'magit-dispatch))
(ad-activate 'magit-status)
1
  • Works perfectly, but issues a warning now: Warning (bytecomp): ‘magit-dispatch-popup’ is an obsolete function (as of Magit 3.0.0); use ‘magit-dispatch’ instead. - When I use magit-dispatch, it complains that is for interactive use only :/
    – xeruf
    Feb 23, 2021 at 8:54

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.