pavelp

Use digit keys as function keys in meow-normal-mode (Emacs)

This post is about this diff that I made to my Emacs configuration.

   (meow-define-keys 'normal
-    '("0" . meow-expand-0) '("9" . meow-expand-9) '("8" . meow-expand-8)
-    '("7" . meow-expand-7) '("6" . meow-expand-6) '("5" . meow-expand-5)
-    '("4" . meow-expand-4) '("3" . meow-expand-3) '("2" . meow-expand-2)
-    '("1" . meow-expand-1)
+    `("0" . ,(lookup-key (current-global-map) (kbd "<f10>")))
+    `("1" . ,(lookup-key (current-global-map) (kbd "<f1>")))
+    `("2" . ,(lookup-key (current-global-map) (kbd "<f2>")))
+    `("3" . ,(lookup-key (current-global-map) (kbd "<f3>")))
+    `("4" . ,(lookup-key (current-global-map) (kbd "<f4>")))
+    `("5" . ,(lookup-key (current-global-map) (kbd "<f5>")))
+    `("6" . ,(lookup-key (current-global-map) (kbd "<f6>")))
+    `("7" . ,(lookup-key (current-global-map) (kbd "<f7>")))
+    `("8" . ,(lookup-key (current-global-map) (kbd "<f8>")))
+    `("9" . ,(lookup-key (current-global-map) (kbd "<f9>")))
     '("-" . negative-argument) '("`" . pulse-line) '("+" . balance-windows)
     '("<" . lispy-barf) '(">" . lispy-slurp)

I mostly use Keyboardio Model 100 for typing, and most of my typing happens in Emacs. Model 100 doesn't have function keys, instead there is layer activated by right palm key that runs digit keys 0-9 into function keys, 1 is F1, 2 is F2, 0 is F10. I use function keys in Emacs a lot, having these bindings:

(define-key (current-global-map) (kbd "<f1>") (toggle-function "*eshell*" 'eshell))
(define-key (current-global-map) (kbd "<f2>") #'deadgrep)
(define-key (current-global-map) (kbd "<f7>") #'project-async-shell-command)
(define-key (current-global-map) (kbd "<f8>") #'reverso-translate))
(define-key (current-global-map) (kbd "<f9>") #'ace-window)
(define-key (current-global-map) (kbd "<f13>") #'repeat)

Plus, F3 and F4 are default Emacs for dealing with macros, I use them often.

Pressing right palm key is a burden, e.g. to press F2 I have to use two hands.

I use meow for modal editing, its advantage over Evil (VIM keybindings) is that meow is subtle, it doesn't override anything in Emacs keybidings and explicitly requires configuration of what each key is doing in each of its modes. meow-normal-mode is the default mode I'm in for 90% of the time. By default (and that's what I used), in normal mode, Meow uses digits for expansion, say select a word with e, then 5 will expand for five words and so on. Meow provides overlays to it's visible where to expand. I don't use them as found them distracting. Instead I use Avy, having avy-goto-char-timer bound to C-;, check Avy can do anything post for how powerful Avy is.

Effectively, I never use digit keys in meow-normal-mode. So, on <2023-09-30 Sat> I rebind them to act as function keys! The snippet is at the top of the post. I found the recipe how to do that in keyboard shortcuts - How to alias keybindings in emacs? - Super User post.

Thoughts? Leave a comment