8

When I start emacs and press C-x g, it says: "C-x g is undefined". I can open a file belonging to the repository, and it still doesn't work. I need to start it manually (?) (C-x magit-status). And it's only after that that the keybinding starts working. But it still doesn't work in the *GNU Emacs* buffer, and in Dired. What's the supposed workflow? Should I add something to the config?

My current ~/.emacs:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages (quote (magit))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
1
  • 1
    Maybe if you post your current config someone might be able to help you.
    – loris
    Commented Jun 19, 2020 at 12:53

1 Answer 1

7

Magit tries to establish that binding automatically using global-magit-file-mode. However that does not actually work. It's a known bug. You didn't mention this mode so I don't know whether you are aware that this mode is supposed to define that binding. But since it doesn't actually work that doesn't matter.

You have to define the binding yourself by adding something like this to your init file.

(define-key global-map (kbd "C-c g") 'magit-status)
4
  • That's not particularly relevant, but recently I had to switch to *terminal* and back a lot. Which made me think of at least mapping C-c b to C-x b, and overall using C-c combinations in place of C-x ones. Is it possibly why you're mapping C-c g, not C-x g?
    – x-yuri
    Commented Jun 20, 2020 at 5:52
  • Because doing that in a package is forbidden. ;D
    – tarsius
    Commented Jun 20, 2020 at 8:11
  • C-c <letter> is reserved for users and packages are not allowed to use it.
    – tarsius
    Commented Jun 20, 2020 at 8:12
  • When a buffer is opened if magit is not on, can it enable itself automatically without the need of the keybinding? @tarsius
    – alper
    Commented Jul 8, 2020 at 23:21

Your Answer

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

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