pyenv-mode icon indicating copy to clipboard operation
pyenv-mode copied to clipboard

The pyenv keybinds conflict with magit/org

Open hjpotter92 opened this issue 4 years ago • 7 comments

The key binding for C-c C-s is bound to git-commit-signoff when editing a commit message in magit, however, if we're working in a python project, the same gets overwritten by pyenv mode.

hjpotter92 avatar Dec 30 '20 08:12 hjpotter92

You can bind it to something else with

(setq pyenv-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-c C-m") 'pyenv-mode-set)
    (define-key map (kbd "C-c C-u") 'pyenv-mode-unset)
    map))

CeleritasCelery avatar Dec 30 '20 20:12 CeleritasCelery

My issue is with pyenv-mode overriding keybinds for other major modes, when it is set as a hook for python-mode only.

hjpotter92 avatar Dec 31 '20 09:12 hjpotter92

It is actually a global minor mode, which is why you are seeing the conflict.

CeleritasCelery avatar Jan 01 '21 14:01 CeleritasCelery

It would be great to make it only enable with python-mode and not global. It is also conflicting with org-schedule (C-c C-s) - and when I'm inside org, I'm not at all working on any python project - no need of pyenv, but projectile is on. So can we use it as python-mode hook too?

grauschnabel avatar Feb 10 '21 11:02 grauschnabel

It looks like #31 was submitted to do exactly that.

CeleritasCelery avatar Feb 10 '21 17:02 CeleritasCelery

For anyone still annoyed by the overriding of keys, a workaround I've found is to delete the keymap of pyenv-mode-map and rebind the commands in the python-mode-map. One obvious downside to this is having the keys mapped permanently, whether in pyenv-mode or not, but since I use it pretty much all the time it works for me.

(use-package pyenv-mode
  :init
  (setq pyenv-mode-map
	(let ((map (make-sparse-keymap)))
	  map))
  :hook python-ts-mode python-mode
  :bind
  (:map python-ts-mode-map
	("C-c C-s" . pyenv-mode-set)
	("C-c C-u" . pyenv-mode-unset)))

wenzlawski avatar Jan 27 '24 18:01 wenzlawski

I don't use pyenv-mode so I can't answer this myself, but would making this mode buffer local be the right solution? If so, we can do that.

CeleritasCelery avatar Jan 29 '24 16:01 CeleritasCelery