lispy.el demo 1: practice generating code
Back to github | This file in org-mode | Function reference |
Intro
Comes from this emacs.stackexchange question.
Task summary
For LaTeX-mode
, swap - to _, and swap 6 to ^.
Screencast
The screencast for this demo is here: https://www.youtube.com/watch?v=2w1h48CYOMo
Resulting code
(define-key LaTeX-mode-map "_" (lambda () (interactive) (insert "-"))) (define-key LaTeX-mode-map "-" (lambda () (interactive) (insert "_"))) (define-key LaTeX-mode-map "^" (lambda () (interactive) (insert "6"))) (define-key LaTeX-mode-map "6" (lambda () (interactive) (insert "^")))
How to generate this code:
step one
Write:
"-" "_" "6" "^"
- position the point at the start
- C-7 to add one cursor
- M-m to mark the first string
- > to extend the region to the second string
- c to clone region
- i to select the first element of the region
- s to move the region down
- C-7 to cancel
multiple-cursors
.
You should now have:
"_" "-" "-" "_" "^" "6" "6" "^"
step two
Write:
(define-key LaTeX-mode-map (lambda () (interactive) (insert)))
Kill it with C-, or C-k.
step three
- position the point at the start
- M-3 C-7 to add three cursors
- C-y to paste the code from before
- add one space
- M-m mark
- > grow
- ok insert up
- iw select first and move up
- jj go down twice
- okok insert up twice
- C-7 to cancel
multiple-cursors