mrkkrp / modalka

Modal editing your way
280 stars 18 forks source link

Key sequence x o starts with non-prefix key x #22

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'm getting started with modalka, and I tried to run (modalka-define-kbd "x o" "C-x o") like i saw here but I got an error. Would you mind pointing me in the right direction? Thanks!

Debugger entered--Lisp error: (error "Key sequence x o starts with non-prefix key x")
  define-key((keymap (120 . modalka-translation) (99 . modalka-translation) (32 . modalka-translation) (107 . modalka-translation) (121 . modalka-translation) (119 . modalka-translation) (112 . modalka-translation) (110 . modalka-translation) (103 . modalka-translation) (102 . modalka-translation) (101 . modalka-translation) (98 . modalka-translation) (97 . modalka-translation) (89 . modalka-translation) (87 . modalka-translation) (57 . modalka-translation) (56 . modalka-translation) (55 . modalka-translation) (54 . modalka-translation) (53 . modalka-translation) (52 . modalka-translation) (51 . modalka-translation) (50 . modalka-translation) (49 . modalka-translation) (48 . modalka-translation)) "xo" modalka-translation)
  modalka-define-key("xo" "o")
  modalka-define-kbd("x o" "C-x o")
  (progn (modalka-define-kbd "x o" "C-x o"))
  eval((progn (modalka-define-kbd "x o" "C-x o")) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
mrkkrp commented 6 years ago

I guess the problem is that x is already bound to something in the context where you try to use modalka. So it's not a prefix key and thus you cannot get a sequential command.

ghost commented 6 years ago

Oh of course, I misunderstood how it works. I had set (modalka-define-kbd "x" "C-x") earlier, which was blocking the x key. Thanks!

contrapunctus-1 commented 5 years ago

On a related note - once we have...

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

...why can't we press x e to get C-x C-e? Instead, my config looks like -

(let ((keybind-re (rx-to-string '(group-n 1 (or (and bow (1+ (char graph)) eow)
                                                  (and (1+ (char graph))))))))
    (mapc
     (lambda (actual)
       (let ((target (replace-regexp-in-string keybind-re "C-\\1" actual)))
         (modalka-define-kbd actual target)))
     '("`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "="
           "q" "w" "e" "r"     "y" "u" "i" "o" "p" "[" "]" "\\"
            "a" "s" "d" "f"   "h" "j" "k" "l" ";" "'"
             "z"         "v" "b" "n" "m" "," "." "/"
                                         "<" ">" "?"
                           "SPC"
       "x =" "x -" "x e" "x s" "x d"
       "x f" "x l" "x x" "x c" "x v" "x b"
       "t w" "t e" "t l"
       "c n" "c ," "c ." "c p"
       "c c n" "c h u" "c h m")))

...21 definitions where 3 could have sufficed :disappointed: