mrkkrp / modalka

Modal editing your way
280 stars 18 forks source link

Extended keychords not working #19

Closed ibnishak closed 6 years ago

ibnishak commented 6 years ago

I tried to use (modalka-define-kbd "s l" "C-a C-SPC C-e") which did not work. I also tried (modalka-define-kbd "s l" "<home> C-SPC <end>") which failed to translate too. While (modalka-define-kbd "c c" "C-c C-c") works.

Emacs version: 25.3 OS: Manjaro linux

mrkkrp commented 6 years ago

Well, that's right, you bind a key to some other key. The target key should be a binding corresponding to one command, while "C-a C-SPC C-e" looks like three commands to me. You should use Emacs macros instead. Or define your own little helper and bind that (this is what I would do).

Here is what you could do:

(defun my-little-helper ()
  (interactive)
  (beginning-of-line)
  (set-mark-command nil)
  (end-of-line))

(define-key modalka-mode-map (kbd "s l") #'my-little-helper)

Hope that helps.

phil-s commented 6 years ago

modalka in particular works by looking up (at call-time) the current binding for the given target key sequence -- so the target needs to be a key sequence with a binding.

A "key chord" is a number of keys held simultaneously, such as C-SPC or C-M-l. I've never heard the term "extended keychords", but what you are talking about here is a keyboard macro (i.e. an arbitrary sequence of input events).

You can always use the standard key binding functions to execute a keyboard macro. e.g.:

(global-set-key (kbd "C-c e") (kbd "C-a C-SPC C-e"))
ibnishak commented 6 years ago

thank you for clearing that up.