meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.07k stars 128 forks source link

Motion override keys with prefix maps #561

Closed skissue closed 2 months ago

skissue commented 3 months ago

When defining motion keys with meow-motion-overwrite-define-key, only keys bound to commands work. Sometimes keys are bound to prefix maps though. Right now I'm working around it by redefining meow--save-origin-commands to this:

(defun meow--save-origin-commands ()
  (cl-loop for key-code being the key-codes of meow-motion-state-keymap do
           (let* ((key (meow--parse-input-event key-code))
                  (rebind-key (concat meow-motion-remap-prefix key)))
             (keymap-local-set
              rebind-key
              (lambda ()
                (interactive)
                (let ((bind (or (keymap-local-lookup key)
                                (keymap-global-lookup key))))
                  (cond
                   ((commandp bind)
                    (call-interactively bind))
                   ((keymapp bind)
                    (keymap-local-set rebind-key bind)
                    (meow--execute-kbd-macro key)))))))))

Is this something that can be added? I can make a PR if necessary, though I'm not super proficient with Emacs Lisp :sweat_smile:.

DogLooksGood commented 2 months ago

The idea of this meow-motion-overwrite-define-key is to provide a way to tweak some navigation key bindings, primarily for up/down/left/right. It shouldn't become a way to build a complex keymap. So I think we should keep it as it is.