#'magit-status
is fun, because its argument to interactive
isn't just a string, so running it naively with call-interactively
doesn't work.Instead, the function generates its own interactive arguments. Here's the interactive
call inside (defun magit-status ...
:
(interactive
(list (and (or current-prefix-arg (not (magit-toplevel)))
(magit-read-repository
(>= (prefix-numeric-value current-prefix-arg) 16)))))
So we have to bind current-prefix-arg
directly, to pretend it's been called with a prefix arg:
(define-key evil-motion-state-map "ga"
(lambda () (interactive)
(let ((current-prefix-arg 4))
(call-interactively #'magit-status))))
Or, as I tested it (because I don't use evil-mode):
(global-set-key
(kbd "C-c C-s")
(lambda () (interactive)
(let ((current-prefix-arg 4))
(call-interactively #'magit-status))))
Thanks to @npostavs for the instruction on binding current-prefix-arg
. The previous answer (for the purposes of transparency) was:
(global-set-key
(kbd "C-c C-s")
(lambda () (interactive)
(magit-status (magit-read-repository
(>= (prefix-numeric-value current-prefix-arg) 16)))))