-
I want to create a key binding that should only be in effect when lem is in vi-mode and normal mode. While in insert mode, the binding should do nothing. How do I do that? How do I differentiate between normal and insert mode in code? To provide some context, what I'd eventually like to do is create a space menu like the ones Spacemacs and Doom Emacs have. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello, what about this: (define-key lem-vi-mode:*normal-keymap*
"g a"
'beginning-of-defun-on-function)
(define-key lem-vi-mode:*insert-keymap* "C-n" 'lem/abbrev:abbrev-with-pop-up-window)
I should have answered this.
and this wouldn't be necessary now. |
Beta Was this translation helpful? Give feedback.
-
@vindarel Thank you for your answer. I feel like I'm so close to having a space menu now, but I can't get it to bind SPC. Here's what I have so far. ;; SPC
(defvar *space-keymap*
(make-keymap :name '*space-keymap*)
"The root keymap for the space menu.")
;; SPC f
(defvar *space-f-keymap*
(make-keymap :name '*space-f-keymap*)
"file menu")
(define-keys *space-f-keymap*
("f" 'lem-core/commands/file:find-file)
("F" 'lem-core/commands/file:find-file-recursively))
;; SPC t
(defvar *space-t-keymap*
(make-keymap :name '*space-t-keymap*)
"toggle menu")
(define-keys *space-t-keymap*
("s" 'lem-core::list-color-themes)
("w" 'lem-core/commands/window::toggle-line-wrap))
(define-keys *space-keymap*
("f" *space-f-keymap*)
("t" *space-t-keymap*))
(define-key *global-keymap* "C-z" *space-keymap*) ; alternative leader
(define-key lem-vi-mode:*normal-keymap* " " *space-keymap*) ; FIXME: doesn't work
(define-key lem-vi-mode:*normal-keymap* "g" *space-keymap*) ; works The bottom 3 lines are where I tried to setup some leaders. C-z and g both work, but " " does not, and that's the one I really wanted. What am I doing wrong there? |
Beta Was this translation helpful? Give feedback.
Hello, what about this:
I should have answered this.
and this wouldn't be necessary now.