-
Notifications
You must be signed in to change notification settings - Fork 45
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
Using general.el with meow #546
Comments
@ChauhanT I've made a separate issue. I don't fully understand what you want. Could you give me an example keybinding form that you would like to be able to use and tell me what it should do? Since meow doesn't support this directly, I don't think there are any perfect solutions to do what you want. Using a hook like you describe won't work well since it will clobber keybindings in a global keymap. You'd have to update the keybindings every time you switched buffers as well. Depending on specifically what you want to do, there might be some workable solution. |
Hi, sorry, should have started a separate thread for this. An example: in org-mode I bind things like increasing priority or changing the TODO keyword to mode-specific menus. I use evil in my current distro emacs-groundup, and I implement such bindings so that they only appear in the required mode (org-mode in this case). These are implemented (assuming the hydras) as:
I am looking for something similar as I try to replace evil with meow. In my meow variant, the relevant config could be summed up in:
So, in org-mode I am trying to implement a function like (there are similar variants I am trying with
The idea is to be able to do mode-local keybindings with:
I also tried the |
There are a couple of approaches you could take, though none of them are great.
(defvar my-local-normal-spc-prefix-map nil)
(make-variable-buffer-local 'my-local-normal-spc-prefix-map)
(defmacro my-local-normal-spc-bind (&rest args)
`(progn (unless (and my-local-normal-spc-prefix-map
(local-variable-p 'my-local-normal-spc-prefix-map))
(setq my-local-normal-spc-prefix-map (make-sparse-keymap)))
(general-def my-local-normal-spc-prefix-map ,@args)))
;; assuming you've aliased normal to `meow-normal-state-keymap'
;; using a menu-item to get the local version of the keymap at lookup time
(general-def
'normal
"SPC"
'(menu-item
""
nil
:filter (lambda (&optional _)
my-local-normal-spc-prefix-map)))
;; or just
(general-def 'normal "SPC" (general-predicate-dispatch my-local-normal-spc-prefix-map))
;; create a wrapper to use hooks to make keybindings
(add-hook 'org-mode-hook
(lambda (&rest _)
(my-local-normal-spc-bind "a" #'a))) This is just a basic example. I'll leave it up to you to create wrappers/clean things up if you like the approach. You could, for example, create a wrapper to automate the setup process (create keymaps for all meow states and bind keys to them), e.g. |
I really appreciate your taking the time/interest/pains to give such a detailed response. I will attempt implementing this during the coming weekend, and I will update this thread with my results. Thank you once again ! |
I have been doing some testing using a config like this:
My mode-specific mappings end up covering all state, including the insert state.
I have tried to make a function which will take a mode and a list of keybindings as inputs, and will then add a hook to the said mode which only maps to
meow-normal-state-keymap
. This also fails miserably. However, in this case, I think it might be my lack of elisp skills... Any tips or comments will be very helpful !Originally posted by @ChauhanT in #497 (comment)
The text was updated successfully, but these errors were encountered: