xah talk show 2024-04-19 Ep546 emacs lisp coding
(setq x-qwerty
"~ ! @ # $ % ^ & * ( ) _ +
` 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 , . /
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 < > ?")
(setq x-colemak_dh
"~ ! @ # $ % ^ & * ( ) _ +
` 1 2 3 4 5 6 7 8 9 0 - =
q w f p b j l u y ; [ ] \\
a r s t g m n e i o '
z x c d v k h , . /
Q W F P B J L U Y : { } |
A R S T G M N E I O \"
Z X C D V K H < > ?"
)
(defun xah_create_layout_map (Layout1 Layout2)
"
Takes two strings layout1 layout2, they are in ascii art form.
Return a associative list, that remaps key in layout1 to layout2.
Version 2024-04-19"
(interactive)
(let (xkeys1 xkeys2 )
(setq xkeys1 (split-string Layout1 " +\\|\n+"))
(setq xkeys2 (split-string Layout2 " +\\|\n+"))
(seq-mapcat
(lambda (x)
(if (string-equal (car x) (cdr x))
nil
(list x)
))
(seq-mapn (lambda (x y) (cons x y)) xkeys1 xkeys2))
))
(print (xah_create_layout_map x-qwerty x-colemak_dh) )