|
| 1 | +#+TITLE: lispy.el demo 1: practice generating code |
| 2 | +#+LANGUAGE: en |
| 3 | +#+OPTIONS: H:3 num:nil toc:nil |
| 4 | +#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="demo-style.css"/> |
| 5 | + |
| 6 | +| [[https://github.com/abo-abo/lispy][Back to github]] | [[https://raw.githubusercontent.com/abo-abo/lispy/gh-pages/demo-1.org][This file in org-mode]] | [[http://abo-abo.github.io/lispy/][Function reference]] | |
| 7 | + |
| 8 | +* Intro |
| 9 | +Comes from [[http://emacs.stackexchange.com/questions/3881/changing-the-role-of-the-underline-and-the-minus-sign-just-in-latex-mode][this emacs.stackexchange question]]. |
| 10 | +* Task summary |
| 11 | +For =LaTeX-mode=, swap ~-~ to ~_~, and swap ~6~ to ~^~. |
| 12 | +* Screencast |
| 13 | +The screencast for this demo is here: https://www.youtube.com/watch?v=2w1h48CYOMo |
| 14 | +* Resulting code |
| 15 | +#+begin_src emacs-lisp |
| 16 | +(define-key LaTeX-mode-map "_" (lambda () (interactive) (insert "-"))) |
| 17 | +(define-key LaTeX-mode-map "-" (lambda () (interactive) (insert "_"))) |
| 18 | +(define-key LaTeX-mode-map "^" (lambda () (interactive) (insert "6"))) |
| 19 | +(define-key LaTeX-mode-map "6" (lambda () (interactive) (insert "^"))) |
| 20 | +#+end_src |
| 21 | +* How to generate this code: |
| 22 | +** step one |
| 23 | +Write: |
| 24 | +#+begin_src emacs-lisp |
| 25 | +"-" "_" |
| 26 | +"6" "^" |
| 27 | +#+end_src |
| 28 | +- position the point at the start |
| 29 | +- ~C-7~ to add one cursor |
| 30 | +- ~M-m~ to mark the first string |
| 31 | +- ~>~ to extend the region to the second string |
| 32 | +- ~c~ to clone region |
| 33 | +- ~i~ to select the first element of the region |
| 34 | +- ~s~ to move the region down |
| 35 | +- ~C-7~ to cancel =multiple-cursors=. |
| 36 | +You should now have: |
| 37 | +#+begin_src emacs-lisp |
| 38 | +"_" "-" |
| 39 | +"-" "_" |
| 40 | +"^" "6" |
| 41 | +"6" "^" |
| 42 | +#+end_src |
| 43 | +** step two |
| 44 | +Write: |
| 45 | +#+begin_src emacs-lisp |
| 46 | +(define-key LaTeX-mode-map (lambda () (interactive) (insert))) |
| 47 | +#+end_src |
| 48 | +Kill it with ~C-,~ or ~C-k~. |
| 49 | +** step three |
| 50 | +- position the point at the start |
| 51 | +- ~M-3 C-7~ to add three cursors |
| 52 | +- ~C-y~ to paste the code from before |
| 53 | +- add one space |
| 54 | +- ~M-m~ mark |
| 55 | +- ~>~ grow |
| 56 | +- ~ok~ insert up |
| 57 | +- ~iw~ select first and move up |
| 58 | +- ~jj~ go down twice |
| 59 | +- ~okok~ insert up twice |
| 60 | +- ~C-7~ to cancel =multiple-cursors= |
| 61 | + |
| 62 | +#+BEGIN_HTML |
| 63 | +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> |
| 64 | +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> |
| 65 | +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> |
| 66 | +#+END_HTML |
0 commit comments