mrkkrp / modalka

Modal editing your way
280 stars 18 forks source link

Prefix keys like C-x #36

Closed SequentialDesign closed 2 years ago

SequentialDesign commented 2 years ago

Note that the target key binding cannot be a prefix key (prefix keys will be ignored).

I'm not sure what you mean by this, but I want to make it clear that this works because it sounds like you mean prefix key are not possible with Modalka:

(setq keymap (make-sparse-keymap))
(define-key keymap "C-x" #'ctl-x-map)

(define-key modalka-mode-map "x" ctl-x-map)
(define-key ctl-x-map (kbd "e") 'eval-last-sexp)
(define-key ctl-x-map (kbd "s") 'save-buffer)

x works like CTL-x does. that is, x acts just like the normal prefix key.

I think it's a game changer. hat tip to @Horrih for the tip

PS apologies if I misunderstood you.

mrkkrp commented 2 years ago

That sentence is in a section that talks about key remapping, like this:

(modalka-define-kbd "." "C-.")

Indeed, you cannot do:

(modalka-define-kbd "x" "C-x")

That said, I think it is useful to include your approach in the readme. What is the use of the first two lines though? Why is keymap defined? I'd think that this should suffice:

(define-key modalka-mode-map "x" ctl-x-map)
(define-key ctl-x-map (kbd "e") #'eval-last-sexp)
(define-key ctl-x-map (kbd "s") #'save-buffer)