Skip to content

Commit

Permalink
Stubbornly double down on C-x g
Browse files Browse the repository at this point in the history
Re #4311.
  • Loading branch information
tarsius committed Feb 5, 2021
1 parent 5182f3e commit 75ae42a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lisp/magit.el
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ We recommend that you bind \"C-c g\" instead of \"C-c M-g\" to
but the \"C-c <letter>\" namespace is strictly reserved for
users; preventing Magit from using it by default.
The Magit documentation recommended binding \"C-x g\" to
`magit-status' for more than a decade before Emacs developers
decided it was okay to knowingly ignore that precedent and bind
it to `revert-buffer' instead. As described above Magit tries
hard not to override a binding that was added by the user; but
because this binding is not actually added by the user, Magit
exempt it from this protection. See #4311.
Also see info node `(magit)Commands for Buffers Visiting Files'."
:package-version '(magit . "3.0.0")
:group 'magit-essentials
Expand All @@ -268,11 +276,14 @@ Also see info node `(magit)Commands for Buffers Visiting Files'."
(dolist (elt '(("C-x g" . magit-status)
("C-x M-g" . magit-dispatch)
("C-c M-g" . magit-file-dispatch)))
(let ((key (kbd (car elt)))
(def (cdr elt)))
(unless (or (lookup-key map key)
(where-is-internal def (make-sparse-keymap) t))
(define-key map key def)))))))
(let* ((key (kbd (car elt)))
(ours (cdr elt))
(theirs (lookup-key map key)))
(unless (or (and theirs
;; See variable documentation.
(not (eq theirs 'revert-buffer)))
(where-is-internal ours (make-sparse-keymap) t))
(define-key map key ours)))))))
(if after-init-time
(magit-maybe-define-global-key-bindings)
(add-hook 'after-init-hook 'magit-maybe-define-global-key-bindings t)))
Expand Down

0 comments on commit 75ae42a

Please sign in to comment.