Skip to content

Commit

Permalink
fix spc spc dispatching in motion state
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Jan 11, 2022
1 parent 1689b28 commit b4dd313
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
7 changes: 0 additions & 7 deletions meow-command.el
Original file line number Diff line number Diff line change
Expand Up @@ -1374,13 +1374,6 @@ Argument ARG if not nil, switching in a new window."
(t
(meow--switch-state 'normal))))

(defun meow-motion-origin-command ()
"Execute the original command bound in special mode."
(interactive)
(let ((key (meow--parse-input-event last-input-event)))
(when-let* ((rebind-key (meow--get-origin-command key)))
(meow--execute-kbd-macro rebind-key))))

(defun meow-eval-last-exp ()
"Eval last sexp."
(interactive)
Expand Down
3 changes: 3 additions & 0 deletions meow-helpers.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Example usage:
Check `meow-normal-define-key' for usages."
(apply #'meow-define-keys 'leader keybinds))

;; Remap Leader SPC
(meow-leader-define-key (cons "SPC" (concat meow-motion-remap-prefix "SPC")))

(defun meow-motion-overwrite-define-key (&rest keybinds)
"Define key for MOTION state.
Expand Down
4 changes: 0 additions & 4 deletions meow-keymap.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

(require 'meow-var)

(defvar-local meow--origin-commands nil
"Overwritten commands in MOTION state.")

(defvar meow-keymap
(let ((keymap (make-sparse-keymap)))
(define-key keymap [remap describe-key] #'meow-describe-key)
Expand All @@ -36,7 +33,6 @@
(defvar meow-leader-keymap
(let ((keymap (make-sparse-keymap)))
(suppress-keymap keymap t)
(define-key keymap (kbd "SPC") 'meow-motion-origin-command)
(define-key keymap (kbd "u") 'meow-universal-argument)
(define-key keymap (kbd "m") 'meow-keypad-start)
(define-key keymap (kbd "g") 'meow-keypad-start)
Expand Down
10 changes: 2 additions & 8 deletions meow-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,15 @@ Looks up the state in meow-replace-state-name-list"
(format "<%s>" e))
(t nil)))

(defun meow--get-origin-command (key)
(cdr (cl-find-if (lambda (it) (equal (car it) key))
meow--origin-commands)))

(defun meow--save-origin-commands ()
(setq meow--origin-commands nil)
(cl-loop for key-code being the key-codes of meow-motion-state-keymap do
(ignore-errors
(let* ((key (char-to-string key-code))
(let* ((key (meow--parse-input-event key-code))
(cmd (key-binding (kbd key))))
(when (and (commandp cmd)
(not (equal cmd 'undefined)))
(let ((rebind-key (concat meow-motion-remap-prefix key)))
(local-set-key (kbd rebind-key) cmd)
(push (cons key rebind-key) meow--origin-commands)))))))
(local-set-key (kbd rebind-key) cmd)))))))

(defun meow--prepare-region-for-kill ()
(when (and (equal '(expand . line) (meow--selection-type))
Expand Down

0 comments on commit b4dd313

Please sign in to comment.