Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use loop with read-event in keypad #680

Merged
merged 6 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions meow-cheatsheet.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ Currently `meow-cheatsheet-layout-qwerty', `meow-cheatsheet-layout-dvorak',
(goto-char (point-min))
(when (search-forward tgt nil t)
(let ((x (- (point) (line-beginning-position))))
(backward-delete-char 9)
(delete-char -9)
(insert (concat " " upper " "))
(forward-line 1)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (propertize (meow--short-command-name upper-cmd) 'face 'meow-cheatsheet-highlight))
(forward-line 2)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (concat " " lower " "))
(forward-line 1)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (propertize (meow--short-command-name lower-cmd) 'face 'meow-cheatsheet-highlight)))))))

(defun meow--cheatsheet-render-char-thing-table (&optional key-face)
Expand Down
26 changes: 0 additions & 26 deletions meow-command.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(require 'cl-lib)
(require 'subr-x)
(require 'seq)

Check failure on line 28 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

Symbol’s function definition is void: buttonize

Check failure on line 28 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

Symbol’s function definition is void: buttonize

Check failure on line 28 in meow-command.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

Symbol’s function definition is void: buttonize
(require 'meow-var)
(require 'meow-util)
(require 'meow-visual)
Expand Down Expand Up @@ -1724,30 +1724,6 @@
(goto-char (max (point) (overlay-end ov))))
(delete-overlay ov))))))))

(defun meow-start-kmacro ()
"Start kmacro.

This command is a replacement for built-in `kmacro-start-macro'."
(interactive)
(cond
((or (meow-normal-mode-p) (meow-motion-mode-p))
(call-interactively #'kmacro-start-macro))
(t
(message "Can only start recording in NORMAL or MOTION state."))))

(defun meow-start-kmacro-or-insert-counter ()
"Start kmacro or insert counter.

This command is a replacement for built-in
`kmacro-start-macro-or-insert-counter'."
(interactive)
(cond
((or defining-kbd-macro executing-kbd-macro)
(call-interactively #'kmacro-insert-counter))
((or (meow-normal-mode-p) (meow-motion-mode-p))
(call-interactively #'kmacro-start-macro-or-insert-counter))
(t (message "Can only start recording in NORMAL or MOTION state."))))

(defun meow-end-or-call-kmacro ()
"End kmacro recording or call macro.

Expand All @@ -1771,8 +1747,6 @@
This command is a replacement for built-in `kmacro-end-macro'."
(interactive)
(cond
(meow--keypad-this-command
(message "Can't end kmacro with KEYPAD command"))
((or (meow-normal-mode-p)
(meow-motion-mode-p))
(call-interactively #'kmacro-end-or-call-macro))
Expand Down
10 changes: 3 additions & 7 deletions meow-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;;; Commentary:

;;; Modes definition in Meow.

Check failure on line 23 in meow-core.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

Symbol’s function definition is void: buttonize

Check failure on line 23 in meow-core.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

Symbol’s function definition is void: buttonize

Check failure on line 23 in meow-core.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

Symbol’s function definition is void: buttonize
;;; Code:

(require 'cl-lib)
Expand Down 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 @@ -162,7 +160,7 @@
(meow--cancel-second-selection)))

(defun meow--enable-theme-advice (theme)
"Prepare face if the theme to enable is `user'."
"Prepare face if the THEME to enable is `user'."
(when (eq theme 'user)
(meow--prepare-face)))

Expand All @@ -187,8 +185,6 @@
`((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
41 changes: 9 additions & 32 deletions meow-keymap.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

(require 'meow-var)

(declare-function meow-describe-key "meow-command")
(declare-function meow-end-or-call-kmacro "meow-command")
(declare-function meow-end-kmacro "meow-command")

(defvar meow-keymap
(let ((keymap (make-sparse-keymap)))
(define-key keymap [remap describe-key] #'meow-describe-key)
Expand All @@ -33,8 +37,6 @@
(defvar meow-insert-state-keymap
(let ((keymap (make-keymap)))
(define-key keymap [escape] 'meow-insert-exit)
(define-key keymap [remap kmacro-start-macro] #'meow-start-kmacro)
(define-key keymap [remap kmacro-start-macro-or-insert-counter] #'meow-start-kmacro-or-insert-counter)
(define-key keymap [remap kmacro-end-or-call-macro] #'meow-end-or-call-kmacro)
(define-key keymap [remap kmacro-end-macro] #'meow-end-kmacro)
keymap)
Expand All @@ -60,8 +62,6 @@
(define-key keymap (kbd "SPC") 'meow-keypad)
(define-key keymap (kbd "i") 'meow-insert)
(define-key keymap (kbd "a") 'meow-append)
(define-key keymap [remap kmacro-start-macro] #'meow-start-kmacro)
(define-key keymap [remap kmacro-start-macro-or-insert-counter] #'meow-start-kmacro-or-insert-counter)
(define-key keymap [remap kmacro-end-or-call-macro] #'meow-end-or-call-kmacro)
(define-key keymap [remap kmacro-end-macro] #'meow-end-kmacro)
keymap)
Expand All @@ -77,33 +77,13 @@
(defvar meow-keypad-state-keymap
(let ((map (make-sparse-keymap)))
(suppress-keymap map t)
(define-key map [remap self-insert-command] 'meow-keypad-self-insert)
(define-key map [remap kmacro-start-macro] #'meow-start-kmacro)
(define-key map [remap kmacro-start-macro-or-insert-counter] #'meow-start-kmacro-or-insert-counter)
(define-key map [remap kmacro-end-or-call-macro] #'meow-end-or-call-kmacro)
(define-key map [remap kmacro-end-macro] #'meow-end-kmacro)
(let ((i ?\s))
(while (< i 256)
(define-key map (vector i) 'meow-keypad-self-insert)
(setq i (1+ i)))
(define-key map (kbd "DEL") 'meow-keypad-undo)
(define-key map (kbd "<backspace>") 'meow-keypad-undo)
(define-key map (kbd "<escape>") 'meow-keypad-quit)
(define-key map [remap keyboard-quit] 'meow-keypad-quit)
(define-key map (kbd "<deletechar>") 'meow-keypad-self-insert)
(define-key map (kbd "<tab>") 'meow-keypad-self-insert)
(define-key map (kbd "TAB") 'meow-keypad-self-insert)
(define-key map (kbd "<return>") 'meow-keypad-self-insert)
(define-key map (kbd "<up>") 'meow-keypad-self-insert)
(define-key map (kbd "<down>") 'meow-keypad-self-insert)
(define-key map (kbd "<left>") 'meow-keypad-self-insert)
(define-key map (kbd "<right>") 'meow-keypad-self-insert)
(define-key map (kbd "<home>") 'meow-keypad-self-insert)
(define-key map (kbd "<end>") 'meow-keypad-self-insert)
(define-key map (kbd "<next>") 'meow-keypad-self-insert)
(define-key map (kbd "<prior>") 'meow-keypad-self-insert)
(define-key map (kbd "<insert>") 'meow-keypad-self-insert)
(define-key map (kbd "RET") 'meow-keypad-self-insert))
(define-key map (kbd "DEL") 'meow-keypad-undo)
(define-key map (kbd "<backspace>") 'meow-keypad-undo)
(define-key map (kbd "<escape>") 'meow-keypad-quit)
(define-key map (kbd "ESC") 'meow-keypad-quit)

Check failure on line 85 in meow-keymap.el

View workflow job for this annotation

GitHub Actions / check (26.3, true)

This key sequence is reserved (see Key Binding Conventions in the Emacs Lisp manual)

Check failure on line 85 in meow-keymap.el

View workflow job for this annotation

GitHub Actions / check (27.1, true)

This key sequence is reserved (see Key Binding Conventions in the Emacs Lisp manual)

Check failure on line 85 in meow-keymap.el

View workflow job for this annotation

GitHub Actions / check (28.2, true)

This key sequence is reserved (see Key Binding Conventions in the Emacs Lisp manual)
(define-key map [remap keyboard-quit] 'meow-keypad-quit)
map)
"Keymap for Meow keypad state.")

Expand All @@ -123,9 +103,6 @@
(define-key map [remap kmacro-end-or-call-macro] 'meow-beacon-apply-kmacro)
(define-key map [remap kmacro-start-macro-or-insert-counter] 'meow-beacon-start)
(define-key map [remap kmacro-start-macro] 'meow-beacon-start)

(define-key map [remap meow-start-kmacro] 'meow-beacon-start)
(define-key map [remap meow-start-kmacro-or-insert-counter] 'meow-beacon-start)
(define-key map [remap meow-end-or-call-kmacro] 'meow-beacon-apply-kmacro)

;; noops
Expand Down
Loading
Loading