Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to overwrite wakib-key for 1 mode? #11

Open
gety9 opened this issue Feb 13, 2024 · 1 comment
Open

How to overwrite wakib-key for 1 mode? #11

gety9 opened this issue Feb 13, 2024 · 1 comment

Comments

@gety9
Copy link

gety9 commented Feb 13, 2024

I want to use default wakib-key binding for all modes, except for when i do programming (in python), there i want to use different binding. Could you please tell how to do that?

I tried

(use-package eglot
  :bind (:map wakib-keys-overriding-map
    ("C-f" . xref-find-definitions))
  :hook (python-ts-mode . eglot-ensure))

I works, but it overrides C-f binding for all modes/buffers.

I also tried

(use-package eglot
  :bind (:map eglot-mode-map
    ("C-f" . xref-find-definitions))
  :hook (python-ts-mode . eglot-ensure))

it doesn't work

And i also tried

(use-package eglot
  :config
  (define-key eglot-mode-map (kbd "C-f") 'xref-find-definitions)
  :hook (python-ts-mode . eglot-ensure))

also doesn't work

@gety9
Copy link
Author

gety9 commented Feb 16, 2024

Update:

1, Seems like key can't be rebind (cause emulation-mode-map-alists is higher in hierarchy then eglot-mode-map or py-ts-map), but suprisingly command can be remapped, so i solved it like this:

  (define-key eglot-mode-map [remap consult-outline] 'xref-find-definitions)
  (define-key eglot-mode-map [remap consult-ripgrep] 'xref-go-back)

2, But remap can be used only one time, so if key is already remapped (by cua mode like in case of M-s) then above didn't work, so i solved it with custom function with if major mode check:
https://stackoverflow.com/a/41080009/23311868
https://emacs.stackexchange.com/a/47106/42471

Please tell me if there was better way to do it :)

Thx for great package, learned a lot from your code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant