IC
This commit is contained in:
+129
@@ -0,0 +1,129 @@
|
||||
;;; ../../lyfi/configs/apps/doom/custom/meow.el -*- lexical-binding: t; -*-
|
||||
;;Custom Meow Cheatsheet Renderer
|
||||
|
||||
(defvar my-meow-board-grid
|
||||
'(("1" "2" "3" "4" "5" "6" "7" "8" "9" "0")
|
||||
("q" "w" "e" "r" "t" "y" "u" "i" "o" "p")
|
||||
("a" "s" "d" "f" "g" "h" "j" "k" "l" ";")
|
||||
("z" "x" "c" "v" "b" "n" "m" "," "." "/" "'"))
|
||||
"The physical layout of the board as a 2D array.")
|
||||
|
||||
(defun my-meow-get-cmd-name (key)
|
||||
"Helper to get the short name of a command for a given key, or a placeholder."
|
||||
(let ((cmd (key-binding key)))
|
||||
(if cmd
|
||||
(meow--short-command-name cmd)
|
||||
(if (member key '("TAB" "SFT" "CTL" "CAPS" "GUI" "ALT" "MO1" "SPC" "ENT" "BKSL" "LMB" "RMB" "UP" "DN" "N2"))
|
||||
key
|
||||
"<not bound>"))))
|
||||
|
||||
(defun my-meow-render-grid ()
|
||||
"Generates a clean table of Meow commands with base and shift layers."
|
||||
(let ((output ""))
|
||||
(dolist (row my-meow-board-grid)
|
||||
(let ((row-lower "")
|
||||
(row-upper ""))
|
||||
(dolist (key row)
|
||||
(let* ((low-name (my-meow-get-cmd-name key))
|
||||
(up-key (upcase key))
|
||||
(up-name (my-meow-get-cmd-name up-key)))
|
||||
;; Build the lower layer string
|
||||
(setq row-lower (concat row-lower
|
||||
(format "[%s = %-12s] " key low-name)))
|
||||
;; Build the upper layer string
|
||||
(setq row-upper (concat row-upper
|
||||
(format "[%s = %-12s] " up-key up-name)))))
|
||||
;; Append both layers, then a newline for a gap between physical rows
|
||||
(setq output (concat output row-lower "\n" row-upper "\n\n"))))
|
||||
output))
|
||||
|
||||
(defun my-meow-cheatsheet ()
|
||||
"Custom cheatsheet that uses a grid instead of fragile ASCII art."
|
||||
(interactive)
|
||||
(let ((buf (get-buffer-create "*Meow Cheatsheet*")))
|
||||
(with-current-buffer buf
|
||||
(text-mode)
|
||||
(setq buffer-read-only nil)
|
||||
(erase-buffer)
|
||||
(insert "Meow Custom Layout Cheatsheet\n")
|
||||
(insert "====================================================================================================\n\n")
|
||||
(insert (my-meow-render-grid))
|
||||
(insert "\n====================================================================================================\n")
|
||||
(insert meow--cheatsheet-note)
|
||||
(insert (meow--render-cheatsheet-thing-table))
|
||||
(add-face-text-property (point-min) (point-max) 'meow-cheatsheet-command)
|
||||
(setq buffer-read-only t))
|
||||
(switch-to-buffer buf)))
|
||||
|
||||
(defun meow-setup ()
|
||||
;; We no longer need the physical-layout strings because we use my-meow-board-grid
|
||||
(meow-motion-overwrite-define-key
|
||||
'("j" . meow-next)
|
||||
'("k" . meow-prev)
|
||||
'("<escape>" . mode-line-other-buffer))
|
||||
|
||||
(meow-leader-define-key
|
||||
'("/" . meow-keypad-describe-key)
|
||||
'("?" . my-meow-cheatsheet)) ;; Use our new custom renderer here
|
||||
|
||||
(meow-normal-define-key
|
||||
'("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)
|
||||
'("-" . negative-argument)
|
||||
'(";" . meow-reverse)
|
||||
'("," . meow-inner-of-thing)
|
||||
'("." . meow-bounds-of-thing)
|
||||
'("[" . meow-beginning-of-thing)
|
||||
'("]" . meow-end-of-thing)
|
||||
'("a" . meow-append)
|
||||
'("A" . meow-open-below)
|
||||
'("b" . meow-back-word)
|
||||
'("B" . meow-back-symbol)
|
||||
'("c" . meow-change)
|
||||
'("d" . meow-delete)
|
||||
'("D" . meow-backward-delete)
|
||||
'("e" . meow-next-word)
|
||||
'("E" . meow-next-symbol)
|
||||
'("f" . meow-find)
|
||||
'("g" . meow-cancel-selection)
|
||||
'("G" . meow-grab)
|
||||
'("h" . meow-left)
|
||||
'("H" . meow-left-expand)
|
||||
'("i" . meow-insert)
|
||||
'("I" . meow-open-above)
|
||||
'("j" . meow-next)
|
||||
'("J" . meow-next-expand)
|
||||
'("k" . meow-prev)
|
||||
'("K" . meow-prev-expand)
|
||||
'("l" . meow-right)
|
||||
'("L" . meow-right-expand)
|
||||
'("m" . meow-join)
|
||||
'("n" . meow-search)
|
||||
'("o" . meow-block)
|
||||
'("O" . meow-to-block)
|
||||
'("p" . meow-yank)
|
||||
'("q" . meow-quit)
|
||||
'("Q" . meow-goto-line)
|
||||
'("r" . meow-replace)
|
||||
'("R" . meow-swap-grab)
|
||||
'("s" . meow-kill)
|
||||
'("t" . meow-till)
|
||||
'("u" . meow-undo)
|
||||
'("U" . meow-undo-in-selection)
|
||||
'("v" . meow-visit)
|
||||
'("w" . meow-mark-word)
|
||||
'("W" . meow-mark-symbol)
|
||||
'("x" . meow-line)
|
||||
'("X" . meow-goto-line)
|
||||
'("y" . meow-save)
|
||||
'("Y" . meow-sync-grab)
|
||||
'("z" . meow-pop-selection)
|
||||
'("'" . repeat)))
|
||||
Reference in New Issue
Block a user