-
Notifications
You must be signed in to change notification settings - Fork 2
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
Examples with evil mode ? #2
Comments
Is there a function or a map you would normally bind into for evil mode? |
I am not sure here what general does. I used general which handled that for me. I can't see how I can bind a function to two maps like in evil normal state map if the other open map is org mode map then have this key call x function. |
It seems like we can make use of I am guessing that this would cover most of the cases but needs a bit of testing but I don't have time for it right now. Nonetheless, it would be good to have someone who is knowledgeable about |
Hi @repelliuss I'm a big fan of this package. Perhaps you won't believe it but every time I went down your show-don't-tell section I was wowed--not just because of the impressiveness of the macro but also because it was as if you read my mind. Your macro is essentially the embodiment of almost all I wanted. Anyways I digress. I use evil too and I tried to write the code you described. Lmk what you think. ;; 1. Write something similar to =bind-undo= and =bind-save=
;; This function would put evil states to bind metadata.
(defmacro evil-bind! (state &rest forms)
"Undo (or unbind) `bind' FORM keys."
`(let ((bind--definer #'+bind--evil-definer))
(bind-with-metadata (:engine 'evil-bind :state ,state)
(bind ,@forms))))
;; 2. write a wrapper function for evil-define-key* to
;; transform it to what bind--definer expects and read states through metadata.
(defun +bind--evil-definer (keymap key def)
(-when-let (state (plist-get bind--metadata :state))
;; (message "%s->%s %s" state key def)
(evil-define-key* state keymap key def))) While writing this I realized it's probably even better to wrap the call to (defun +bind--evil-definer (keymap key def)
(-when-let (state (plist-get bind--metadata :state))
;; (message "%s->%s %s" state key def)
(with-eval-after-load 'evil
(evil-define-key* state keymap key def)))) |
Also I wonder whether it is possible to make a processing function for this. This may be even more desirable because it would allow you to be able to bind to different states in one binding form. But I'm not sure whether you can apply different values of bind metadata for different bindings. ;; Processing function that does not actually modify bindings. Instead it adds
;; the `state' to `bind--metadata' for those bindings.
(defun bind-state (states &rest bindings)...)
;; This would be nice.
(bind org-mode-map
(:states '(normal insert) ;; bind--metadata would contain `:states '(normal insert) only for these bindings
"i" #'foo
"g" #'bar)
(:states '(emacs)
"t" #'lap
"v" #'lop)) Then you could have a more generalized definer. (defun +bind--definer (keymap key def)
(cond ((plist-get bind--metadata :state)
(with-eval-after-load 'evil
(evil-define-key* state keymap key def)))
(t
(define-key state keymap key def)))) |
Hi, @Luis-Henriquez-Perez . Thank you for your kind words, I really appreciate it. The functionality you described with processing function would be a perfect match for Other than this, it is certainly one way to implement |
I spoke the truth.
I'll also try to take a stab at it soon. |
bind really help to organize and view the bindings in a logical way but i am not sure how to set evil mode specific bindings
Like how can i set
For just the evil normal state
The text was updated successfully, but these errors were encountered: