-
Hi! I'm a new emacs user and have been enjoying meow very much. I am however a little confused on what is the recommended way to organize keybindings. I'll give a couple of examples. Example 1: Accessing projectile command mapLets say I'm using the projectile package and wish to make a nice and easy button combination to access its command map. Currently my setup looks like this: (use-package projectile
:straight t
:bind (:map projectile-mode-map ("C-c p" . projectile-command-map))
... I can now access projectile commands with Could I maybe bind it to just Example 2: Binding smartparens commandsHere is my current setup: (use-package smartparens
:straight t
:bind
(:map smartparens-mode-map
("C-c s d" . sp-unwrap-sexp )
("C-c s r" . sp-wrap-round)
("C-c s c" . sp-wrap-curly)
("C-c s s" . sp-wrap-square))
... Again it works fine but i would like quicker access to Example 3: Emacs built-in functionsI've bound the If you could enlighten me on how you handle your keybindings with code examples I would be very thankful! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't use I'm not sure what the issue with just binding it to I do something like this with projectile also. If projectile is on and I'm in (defun find-file-or-projectile ()
(interactive)
(if (projectile-project-p)
(call-interactively #'projectile-find-file)
(call-interactively #'find-file)))
(meow-leader-define-key '("U" . find-file-or-projectile)) I also don't think there's anything wrong with your second example either. If (meow-normal-define-key
'("= r" . sp-wrap-round)
'("= s" . sp-wrap-square)) is probably the purest way to do it. I don't think the custom state is what you're looking for. That's meant for The custom state creates a layer that's toggled by a key (chosen I'll try to improve the documentation in a (setq meow-paren-keymap (make-keymap))
(meow-define-state paren
"meow state for interacting with smartparens"
:lighter " [P]"
:keymap meow-paren-keymap)
;; meow-define-state creates the variable
(setq meow-cursor-type-paren 'hollow)
;; fills in meow-paren-keymap
(meow-define-keys 'paren
'("<escape>" . meow-normal-mode) ;; disables the paren state
'("j" . sp-down-sexp)
'("k" . sp-up-sexp)
'("r" . sp-raise-sexp)
'("s s" . sp-wrap-square)
'("s r" . sp-wrap-round)
'("s c" . sp-wrap-curly)
'("s d" . sp-unwrap-sexp))
;; meow-paren-mode is automatically created
(meow-define-keys 'normal
'("b" . meow-paren-mode)) Now, pressing Finally, as for your example 3, as a meow user, I'd tend to put that under some In any case, my meow keybindings are I like this article about emacs bindings |
Beta Was this translation helpful? Give feedback.
-
Yeah, following the convention, your keybinding This behavior is controlled by |
Beta Was this translation helpful? Give feedback.
I don't use
use-package
, so I'm not entirely sure, but I think what you'redoing in example 1 is in general correct. I think the recommended way is to use
:bind-keymap.
I'm not sure what the issue with just binding it to
b
in the leader (so,SPC B
) is. If projectile mode is not active, and the command is undefined,then pressing SPC b will just do nothing, which is reasonable. You can also
use some kind of fallback behavior.
I do something like this with projectile also. If projectile is on and I'm in
a project, SPC-f will call
projectile-find-file
, but if not, then it callsthe normal
find-file
. Maybe this could be useful? I implement it like this: