|
30 | 30 | ;; |
31 | 31 | ;;; Code: |
32 | 32 |
|
| 33 | +(require 'cl-lib) |
33 | 34 | (require 'subr-x) |
34 | 35 | (require 'meow-var) |
35 | 36 | (require 'meow-util) |
|
66 | 67 | (let* ((keybind (if meow--keypad-base-keymap |
67 | 68 | (lookup-key meow--keypad-base-keymap keys) |
68 | 69 | (key-binding keys)))) |
69 | | - (unless (and (meow--is-self-insertp keybind) |
70 | | - (not meow-keypad-self-insert-undefined)) |
71 | | - keybind))) |
| 70 | + keybind)) |
72 | 71 |
|
73 | 72 | (defun meow--keypad-has-sub-meta-keymap-p () |
74 | 73 | "Check if there's a keymap belongs to Meta prefix. |
@@ -408,8 +407,8 @@ If there are beacons, execute it at every beacon." |
408 | 407 | (defun meow--keypad-try-execute () |
409 | 408 | "Try execute command, return t when the translation progress can be ended. |
410 | 409 |
|
411 | | -If there is a command available on the current key binding, |
412 | | -try replacing the last modifier and try again." |
| 410 | +This function supports a fallback behavior, where it allows to use `SPC |
| 411 | +x f' to execute `C-x C-f' or `C-x f' when `C-x C-f' is not bound." |
413 | 412 | (unless (or meow--use-literal |
414 | 413 | meow--use-meta |
415 | 414 | meow--use-both) |
@@ -439,23 +438,32 @@ try replacing the last modifier and try again." |
439 | 438 | (meow--keypad-try-execute)) |
440 | 439 | (t |
441 | 440 | (setq meow--prefix-arg nil) |
442 | | - (message "%s is undefined" (meow--keypad-format-keys nil)) |
443 | 441 | (meow--keypad-quit) |
| 442 | + (if (or (eq t meow-keypad-leader-transparent) |
| 443 | + (eq meow--keypad-previous-state meow-keypad-leader-transparent)) |
| 444 | + (let* ((key (meow--parse-input-event last-input-event)) |
| 445 | + (origin-cmd (cl-some (lambda (m) |
| 446 | + (lookup-key m key)) |
| 447 | + (current-active-maps))) |
| 448 | + (remapped-cmd (command-remapping origin-cmd)) |
| 449 | + (cmd-to-call (if (member remapped-cmd '(undefined nil)) |
| 450 | + (or origin-cmd 'undefined) |
| 451 | + remapped-cmd))) |
| 452 | + (meow--keypad-execute cmd-to-call)) |
| 453 | + (message "%s is undefined" key-str)) |
444 | 454 | t))))) |
445 | 455 |
|
446 | 456 | (defun meow--keypad-handle-input-with-keymap (input-event) |
447 | 457 | "Handle INPUT-EVENT with `meow-keypad-state-keymap'. |
448 | 458 |
|
449 | 459 | Return t if handling is completed." |
450 | | - (if (numberp input-event) |
451 | | - (let* ((k (if (= 27 input-event) |
452 | | - [escape] |
453 | | - (kbd (single-key-description input-event)))) |
454 | | - (cmd (lookup-key meow-keypad-state-keymap k))) |
455 | | - (if cmd |
456 | | - (call-interactively cmd) |
457 | | - (meow--keypad-handle-input-event input-event))) |
458 | | - (meow--keypad-quit))) |
| 460 | + (if (equal 'escape last-input-event) |
| 461 | + (meow--keypad-quit) |
| 462 | + (setq last-command-event last-input-event) |
| 463 | + (let ((kbd (single-key-description input-event))) |
| 464 | + (if-let* ((cmd (lookup-key meow-keypad-state-keymap (read-kbd-macro kbd)))) |
| 465 | + (call-interactively cmd) |
| 466 | + (meow--keypad-handle-input-event input-event))))) |
459 | 467 |
|
460 | 468 | (defun meow--keypad-handle-input-event (input-event) |
461 | 469 | "Handle the INPUT-EVENT. |
|
0 commit comments