Skip to content

Commit ff5315b

Browse files
authored
Allow kbd-macros to also be callbacks (#764)
* allow kbd-macros to also be callbacks * doc for meow kbd macro callbacks * fix docs
1 parent 034fb55 commit ff5315b

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

FAQ.org

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ Here you can map Delete character to internal Meow's delete character function.
2121
(setq meow--kbd-delete-char "<deletechar>")
2222
#+end_src
2323

24+
The keyboard macro variables can also be assigned to defuns if you don't want them to correspond to a keyboard macro.
25+
26+
Example:
27+
#+BEGIN_SRC emacs-lisp
28+
(setq meow--kbd-forward-line #'next-line)
29+
#+END_SRC
30+
31+
2432
* Is there a integration with treesit?
2533

2634
Yes, please check out [[https://github.com/skissue/meow-tree-sitter][meow-tree-sitter]].

TUTORIAL.org

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ Meow will find underlying commands based on keybindings. You may find abnormal b
66
some default keybindings. For example: forward-char on ~C-f~ is used by ~meow-right~. If you changed this keybinding,
77
you have to change variable ~meow--kbd-forward-char~ to the correct value.
88

9+
Example:
10+
11+
#+BEGIN_SRC emacs-lisp
12+
(setq meow--kbd-forward-char "<right>")
13+
14+
;; or bind it to the function directly
15+
(setq meow--kbd-forward-char #'forward-char)
16+
#+END
17+
918
* Keybindings Cheat Sheet
1019

1120
We have created some recommended configs for specific keyboard layouts that you can re-use for a quick setup.

meow-util.el

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151
(declare-function meow--beacon-apply-command "meow-beacon")
5252
(declare-function meow-keypad-start-with "meow-keypad")
5353

54-
(defun meow--execute-kbd-macro (kbd-macro)
55-
"Execute KBD-MACRO."
56-
(when-let* ((ret (key-binding (read-kbd-macro kbd-macro))))
54+
(defun meow--execute-kbd-macro (kbd-macro-or-defun)
55+
"Execute the function bound to `KBD-MACRO-OR-DEFUN'. If `KBD-MACRO-OR-DEFUN' is a string,
56+
instead execute the keyboard macro it corresponds to."
57+
(when-let* ((ret (if (and (symbolp kbd-macro-or-defun) (fboundp kbd-macro-or-defun))
58+
kbd-macro-or-defun
59+
(key-binding (read-kbd-macro kbd-macro-or-defun)))))
5760
(cond
5861
((commandp ret)
5962
(setq this-command ret)
@@ -63,7 +66,7 @@
6366
(set-transient-map ret nil nil))
6467

6568
((and meow-use-keypad-when-execute-kbd (keymapp ret))
66-
(meow-keypad-start-with kbd-macro)))))
69+
(meow-keypad-start-with kbd-macro-or-defun)))))
6770

6871
(defun meow-insert-mode-p ()
6972
"Whether insert mode is enabled."

0 commit comments

Comments
 (0)