mirror of
https://github.com/vale981/boon
synced 2025-03-04 17:11:40 -05:00
step towards cheat sheet generation
This commit is contained in:
parent
0ebc0658ca
commit
54e9e3b8e3
3 changed files with 35 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ TAGS
|
|||
|
||||
/.stack-work
|
||||
/boon.elc
|
||||
/Colemak.hs
|
||||
|
|
7
Makefile
7
Makefile
|
@ -11,6 +11,13 @@ cheat.pdf: cheat-sheet.hs
|
|||
test:
|
||||
$(emacs) -batch --script boon-test.el
|
||||
|
||||
Colemak.hs:
|
||||
$(emacs) -batch \
|
||||
--eval "(add-to-list 'load-path (expand-file-name \".\"))" \
|
||||
--eval "(package-initialize)" \
|
||||
-l boon-tutorial.el \
|
||||
--eval '(boon-dump-cheatsheet "colemak")'
|
||||
|
||||
clean:
|
||||
rm -f *.elc
|
||||
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
(require 'dash)
|
||||
|
||||
(defun boon-dump-map (map)
|
||||
"Dump the MAP in a format usable to generate a cheat sheet.
|
||||
Currently unused."
|
||||
(apply 'concat
|
||||
(--map (format "('%c',\"%S\"):" it
|
||||
(let ((b (lookup-key map (make-vector 1 it))))
|
||||
"Dump the MAP in a format usable to generate a cheat sheet."
|
||||
(apply
|
||||
'concat
|
||||
(--map (let* ((b (lookup-key map (make-vector 1 it)))
|
||||
(mn (boon-mnemonic-noformat b map)))
|
||||
(format "(%d,%S,\"%S\"):" it mn
|
||||
(cond ((symbolp b) b)
|
||||
((eq b boon-x-map) 'x-map)
|
||||
((eq b boon-goto-map) 'goto-map))
|
||||
|
@ -26,6 +27,20 @@ Currently unused."
|
|||
'(?\; ?: ?- ?' ?, ?. ?< ?>)
|
||||
))))
|
||||
|
||||
(defun boon-dump-cheatsheet (flavour)
|
||||
"Dump cheatcheat info for FLAVOUR."
|
||||
(let ((module (capitalize flavour))
|
||||
(el (concat "boon-" flavour ".el")))
|
||||
(require 'boon)
|
||||
(load el)
|
||||
(with-temp-buffer
|
||||
(insert (format "module %s where \n " module))
|
||||
(insert (format "nil = \"\"\n"))
|
||||
(insert (format "commandMap = %s:[]\n" (boon-dump-map boon-command-map)))
|
||||
(insert (format "movesMap = %s:[]\n" (boon-dump-map boon-moves-map)))
|
||||
(insert (format "selectMap = %s:[]\n" (boon-dump-map boon-select-map)))
|
||||
(write-region nil nil (concat module ".hs")))))
|
||||
|
||||
(defun boon-keymap-rev-look (sub map)
|
||||
"Return an event yielding SUB from the keymap MAP."
|
||||
(let (res)
|
||||
|
@ -35,7 +50,7 @@ Currently unused."
|
|||
map)
|
||||
(key-description (vector res))))
|
||||
|
||||
(defun boon-mnemonic (sub &optional map)
|
||||
(defun boon-mnemonic-noformat (sub &optional map)
|
||||
"Return the mnemonic for SUB from the keymap MAP."
|
||||
(let (res)
|
||||
(map-keymap (lambda (_event b) (when (and (consp b)
|
||||
|
@ -43,7 +58,12 @@ Currently unused."
|
|||
(eq (cdr b) sub))
|
||||
(setq res (car b))))
|
||||
(or map boon-command-map))
|
||||
(format "(mnemonic: %s)" res)))
|
||||
res))
|
||||
|
||||
|
||||
(defun boon-mnemonic (sub &optional map)
|
||||
"Return the formatted mnemonic for SUB from the keymap MAP."
|
||||
(format "(mnemonic: %s)" (boon-mnemonic-noformat sub map)))
|
||||
|
||||
|
||||
;; utilities to create the tutorial
|
||||
|
|
Loading…
Add table
Reference in a new issue