-
Notifications
You must be signed in to change notification settings - Fork 26
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 customize citre-peek-keymap
without changing the source code?
#127
Comments
Hi ;) You can just learn from how (define-key map (kbd "M-n") 'citre-peek-next-line) So you could do: (define-key citre-peek-keymap (kbd "M-n") 'citre-peek-next-line) See the documentation of
I don't use doom and haven't been using evil for a long time, so I may not have a working solution for this. Keybindings defined in a minor mode can be overriden by motion state keymap (which also applies to normal state), and the simplest way is to just avoid motion state keybindings in My own solution is to let the minor mode keymap override motion state keymap. It's easy: (evil-make-overriding-map citre-peek-keymap 'motion) Then I add back |
Thank you for you help! (use-package! citre
:defer t
:init
(require 'citre-config)
(map! ;; this is the doom macro to make defining modal keymap more easily
:n "C-]" 'citre-jump
:n "C-w ]" 'citre-peek
:n "C-t" 'citre-jump-back)
(evil-make-overriding-map citre-peek-keymap 'motion)
(evil-make-overriding-map citre-peek-keymap 'normal)
;; the above three keymaps work, but the following two keymaps doesn't work
(define-key citre-peek-map (kbd "]t") 'citre-peek-next-definition)
(define-key citre-peek-map (kbd "[t") 'citre-peek-prev-definition)
;; or define keymaps using evil-define-keys also not work
(evil-define-key 'normal citre-peek-keymap
(kbd "]t") #'citre-peek-next-definition
(kbd "[t") #'citre-peek-prev-definition)) |
First, a piece of advice: when configuring Emacs, it's better to make sure a small snippet of code works, then put it into your init file, then working on the next small snippet of code, rather than just write things in the init file and hoping it to work.
But how? You got an error? The keybinding doesn't do anything? Or it triggers another command? My guess is you got an error saying "]" is not a prefix key. This is expected as normally pressing "]" should insert it, so any keybinding starting with "]" could not work. To make it work, let "]" do nothing in (define-key citre-peek-map (kbd "]") nil)
(define-key citre-peek-map (kbd "]t") 'citre-peek-next-definition) But this is undesired. When
Sorry but I don't know about this function. And again, how does it "not work"? |
I tried and your code actually works for me: (evil-define-key 'normal citre-peek-keymap
(kbd "]t") #'citre-peek-next-definition
(kbd "[t") #'citre-peek-prev-definition) The problem may be you called it before |
Hi! The thing is: nothing happens, what happens is completely the same as what happens if I didn't define those keymaps: In both case:
then I am wondering, why my override settings doesn't work? |
Thank you! I havn't see this thread before I make my reply as above! I will give it a try! |
And this works for me. So I just need to put it in the config part. May I ask about a question? What config options should I set before the package being loaded, like I set |
It's not easy to answer :D You bind But you bind peek related commands in If you need any value/function... defined in the package, you should put it in the A package could be "lazy loaded". That is, it's loaded after you use any of the specified functions in it. Package developers usually specify interactive commands as these functions, so the package is only loaded after you call the commands.
Normally, to reduce the impact on Emacs startup time, we put only necessary code ino the |
thanks for your help. After some tweaking, I find that where the keymaps are defined (at :config or :init block) doesn’t matter. What matters is I need to firstly enter the insert mode after I opens the citre-peek-window(only once) After that all the keymaps I defined in citre-peek-keymap will work. I think the reason might be I am new to elisp and I don’t know this behavior is designed as expected or not. But I’m fine with just entering insert mode once, since it doesn’t take me much more key strokes. |
I solve the issue of evil specific citre-mode-map not activated unless a state transition by the following config (add-hook 'citre-mode-hook #'evil-normalize-keymaps)
(add-hook 'citre-peek--mode-hook #'evil-normalize-keymaps) see the rationale at emacs-evil/evil#301 (comment) |
Hi! I am new to elisp and not quiet familiar it, how can I change the keymaps defined in
citre-peek-keymap
without directly changing the source code? If I directly call(define-key blablabla)
in my config file, then such keymaps would have effects globally.Besides, I am using evil with doom, so it would be better it is evil-compatible.
Thanks for your correspondence!
The text was updated successfully, but these errors were encountered: