lispy.el demo 1: practice generating code
20 |Back to github | 33 |This file in org-mode | 34 |Function reference | 35 |
Intro
40 |42 | Comes from this emacs.stackexchange question. 43 |
44 |Task summary
48 |
50 | For LaTeX-mode
, swap - to _, and swap 6 to ^.
51 |
Screencast
56 |58 | The screencast for this demo is here: https://www.youtube.com/watch?v=2w1h48CYOMo 59 |
60 |Resulting code
64 |(define-key LaTeX-mode-map "_" (lambda () (interactive) (insert "-"))) 67 | (define-key LaTeX-mode-map "-" (lambda () (interactive) (insert "_"))) 68 | (define-key LaTeX-mode-map "^" (lambda () (interactive) (insert "6"))) 69 | (define-key LaTeX-mode-map "6" (lambda () (interactive) (insert "^"))) 70 |71 |
How to generate this code:
76 |step one
80 |82 | Write: 83 |
84 |"-" "_" 86 | "6" "^" 87 |88 |
-
90 |
- position the point at the start 91 |
- C-7 to add one cursor 92 |
- M-m to mark the first string 93 |
- > to extend the region to the second string 94 |
- c to clone region 95 |
- i to select the first element of the region 96 |
- s to move the region down 97 |
- C-7 to cancel
multiple-cursors
.
98 |
100 | You should now have: 101 |
102 |"_" "-" 104 | "-" "_" 105 | "^" "6" 106 | "6" "^" 107 |108 |
step two
113 |115 | Write: 116 |
117 |(define-key LaTeX-mode-map (lambda () (interactive) (insert))) 119 |120 |
122 | Kill it with C-, or C-k. 123 |
124 |step three
128 |-
130 |
- position the point at the start 131 |
- M-3 C-7 to add three cursors 132 |
- C-y to paste the code from before 133 |
- add one space 134 |
- M-m mark 135 |
- > grow 136 |
- ok insert up 137 |
- iw select first and move up 138 |
- jj go down twice 139 |
- okok insert up twice 140 |
- C-7 to cancel
multiple-cursors
141 |
145 | <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> 146 | <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> 147 | <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> 148 |
149 | 150 |