Skip to content

Commit dcc705b

Browse files
committed
add variable to customize keypad behavior on self insert
Adds the boolean variable meow-keypad-self-insert-undefined, true by default so this doesn't change any default behavior. If the user sets this to nil, then any undefined command from the keypad that would trigger self insert is ignored.
1 parent 74fbe3d commit dcc705b

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

CUSTOMIZATIONS.org

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ Default: ='((?c . ?c) (?h . ?h) (?x . ?x))=
183183
Alist of keys to begin keypad translation. For instance, given the default
184184
value, pressing "c" in keypad mode will look up it's value in the alist, and
185185
add "C-c" to the keypad.
186+
** meow-keypad-self-insert-undefined
187+
188+
Default: =t=
189+
190+
Whether to self-insert a key when it is undefined in the keypad. If
191+
set to =t=, then pressing and undefined key in the keypad that is
192+
bound to self insert will insert that character. If nil, then ignore
193+
the key.
186194

187195
** meow-char-thing-table
188196

meow-helpers.el

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ This function produces several items:
226226
"meow--update-cursor")
227227
,keymap))))
228228

229+
(defun meow--is-self-insertp (cmd)
230+
(and (symbolp cmd)
231+
(string-match-p "\\`.*self-insert.*\\'"
232+
(symbol-name cmd))))
233+
229234
(defun meow--mode-guess-state ()
230235
"Get initial state for current major mode.
231236
If any of the keys a-z are bound to self insert, then we should
@@ -234,11 +239,7 @@ probably start in normal mode, otherwise we start in motion."
234239
(meow--disable-current-state)
235240
(let* ((letters (split-string "abcdefghijklmnopqrstuvwxyz" "" t))
236241
(bindings (mapcar #'key-binding letters))
237-
(any-self-insert (cl-some (lambda (cmd)
238-
(and (symbolp cmd)
239-
(string-match-p "\\`.*self-insert.*\\'"
240-
(symbol-name cmd))))
241-
bindings)))
242+
(any-self-insert (cl-some #'meow--is-self-insertp bindings)))
242243
(meow--switch-state state t)
243244
(if any-self-insert
244245
'normal

meow-keypad.el

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
(require 'subr-x)
4040
(require 'meow-var)
4141
(require 'meow-util)
42+
(require 'meow-helpers)
4243

4344
(defun meow--keypad-format-upcase (k)
4445
"Return S-k for upcase k."
@@ -66,8 +67,11 @@
6667
(t "")))
6768

6869
(defun meow--keypad-lookup-key (keys)
69-
(let ((overriding-local-map meow--keypad-base-keymap))
70-
(key-binding keys)))
70+
(let* ((overriding-local-map meow--keypad-base-keymap)
71+
(keybind (key-binding keys)))
72+
(unless (and (meow--is-self-insertp keybind)
73+
(not meow-keypad-self-insert-undefined))
74+
keybind)))
7175

7276
(defun meow--keypad-has-sub-meta-keymap-p ()
7377
(and (not meow--use-literal)

meow-var.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ This will affect how selection is displayed."
103103
:group 'meow
104104
:type 'boolean)
105105

106+
(defcustom meow-keypad-self-insert-undefined t
107+
"Whether to self-insert a key in keypad mode if it is undefined"
108+
:group 'meow
109+
:type 'boolean)
110+
106111
(defcustom meow-char-thing-table
107112
'((?r . round)
108113
(?s . square)

0 commit comments

Comments
 (0)