Skip to content

Commit

Permalink
Fix meow-keypad-start, meow-keypad-start-with and meow-keypad-describ…
Browse files Browse the repository at this point in the history
…e-key
  • Loading branch information
DogLooksGood committed Dec 1, 2024
1 parent 989add2 commit 835e52d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
8 changes: 2 additions & 6 deletions meow-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@
(meow-define-state keypad
"Meow KEYPAD state minor mode."
:lighter " [K]"
:keymap meow-keypad-state-keymap
:face meow-keypad-cursor
(when meow-keypad-mode
(setq meow--prefix-arg current-prefix-arg
meow--keypad-keymap-description-activated nil
meow--keypad-allow-quick-dispatch t
meow--keypad-keymap-description-activated nil
meow--keypad-allow-quick-dispatch t
meow--keypad-base-keymap nil
meow--keypad-keys nil
meow--use-literal nil
meow--use-meta nil
meow--use-both nil)))
Expand Down Expand Up @@ -187,8 +185,6 @@ there's no chance for meow to call an init function."
`((meow-motion-mode . ,meow-motion-state-keymap)))
(add-to-ordered-list 'emulation-mode-map-alists
`((meow-normal-mode . ,meow-normal-state-keymap)))
(add-to-ordered-list 'emulation-mode-map-alists
`((meow-keypad-mode . ,meow-keypad-state-keymap)))
(add-to-ordered-list 'emulation-mode-map-alists
`((meow-beacon-mode . ,meow-beacon-state-keymap)))
(when meow-use-cursor-position-hack
Expand Down
3 changes: 2 additions & 1 deletion meow-helpers.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ meow--set-cursor-type and meow--set-cursor-color."
`(,name . ,(upcase (symbol-name name))))
(add-to-list 'meow-update-cursor-functions-alist
`(,activep . ,cursorf))
(add-to-list 'meow-keymap-alist `(,name . ,keymap)))
(when keymap
(add-to-list 'meow-keymap-alist `(,name . ,keymap))))

;;;###autoload
(defmacro meow-define-state (name-sym
Expand Down
54 changes: 22 additions & 32 deletions meow-keypad.el
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ try replacing the last modifier and try again."
meow--use-meta
meow--use-both)
(let* ((key-str (meow--keypad-format-keys nil))
(cmd (meow--keypad-lookup-key (read-kbd-macro key-str))))
(cmd (keymap-lookup nil key-str t)))

Check failure on line 408 in meow-keypad.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

You should depend on (emacs "29.1") or the compat package if you need `keymap-lookup'.

Check failure on line 408 in meow-keypad.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

You should depend on (emacs "29.1") or the compat package if you need `keymap-lookup'.

Check failure on line 408 in meow-keypad.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

You should depend on (emacs "29.1") or the compat package if you need `keymap-lookup'.
(cond
((commandp cmd t)
(setq current-prefix-arg meow--prefix-arg
Expand Down Expand Up @@ -498,51 +498,41 @@ try replacing the last modifier and try again."
(setq this-command last-command)
(meow--keypad-handle-input-event last-input-event))

(defun meow-keypad-start ()
"Enter keypad state with current input as initial key sequences."
(interactive)
(setq this-command last-command)
(setq meow--keypad-previous-state (meow--current-state))
(meow--switch-state 'keypad)
(setq overriding-local-map meow-keypad-state-keymap
overriding-terminal-local-map nil
meow--keypad-allow-quick-dispatch nil)
(meow--keypad-handle-input-event last-input-event)
(while (not (meow--keypad-handle-input-with-keymap (read-key)))))

(defun meow-keypad ()
"Enter keypad state and convert inputs."
(interactive)
(setq this-command last-command)
(setq meow--keypad-previous-state (meow--current-state))
(meow-keypad-start-with nil))

(defun meow-keypad-start ()
"Enter keypad state with current input as initial key sequences."
(interactive)
(setq this-command last-command
meow--keypad-keys nil
meow--keypad-previous-state (meow--current-state)
meow--prefix-arg current-prefix-arg)
(meow--switch-state 'keypad)
(setq overriding-local-map meow-keypad-state-keymap
overriding-terminal-local-map nil
meow--keypad-allow-quick-dispatch t)
(meow--keypad-display-message)
(meow--keypad-handle-input-with-keymap last-input-event)
(while (not (meow--keypad-handle-input-with-keymap (read-key)))))

(defun meow-keypad-start-with (input)
"Enter keypad state with INPUT.
INPUT is a string, stands for initial keys."
(setq meow--keypad-previous-state (meow--current-state))
A string INPUT, stands for initial keys.
When INPUT is nil, start without initial keys."
(setq this-command last-command
meow--keypad-keys (when input (meow--parse-string-to-keypad-keys input))
meow--keypad-previous-state (meow--current-state)
meow--prefix-arg current-prefix-arg)
(meow--switch-state 'keypad)
(setq meow--keypad-keys (meow--parse-string-to-keypad-keys input)
overriding-terminal-local-map nil
overriding-local-map meow-keypad-state-keymap)
(meow--keypad-try-execute))
(meow--keypad-show-message)
(meow--keypad-display-message)
(while (not (meow--keypad-handle-input-with-keymap (read-key)))))

(defun meow-keypad-describe-key ()
"Describe key via KEYPAD input."
(interactive)
(setq this-command last-command)
(setq overriding-local-map meow-keypad-state-keymap
meow--keypad-help t
meow--keypad-previous-state (meow--current-state))
(meow--switch-state 'keypad)
(meow--keypad-show-message)
(meow--keypad-display-message))
(setq meow--keypad-help t)
(meow-keypad))

(provide 'meow-keypad)
;;; meow-keypad.el ends here

0 comments on commit 835e52d

Please sign in to comment.