Skip to content

Instantly share code, notes, and snippets.

@autotelicum
Created September 3, 2011 15:33
Show Gist options
  • Save autotelicum/1191352 to your computer and use it in GitHub Desktop.
Save autotelicum/1191352 to your computer and use it in GitHub Desktop.
Python to CoffeeScript commands for the acme editor (sam command language)
Sam command helpers for acme-sac to avoid some manual
editing when converting Python to CoffeeScript.
Imperfect and incomplete, check manually after use.
1. Reduce indentation to half (4->2)
2. Remove colons at the end of common statements
3. Rename elif to else if
4. Change function definitions to arrow declarations
5. Change python ranges to array ranges
Edit ,x s/ / /g
Edit ,x s/(if|else|for|while) (.+)\:/\1 \2/
Edit ,x s/elif/else if/
Edit ,x s/def (.+)(\(.*\))\:/\1 = \2 ->/
Edit ,x s/range\(([^ ]+)\)/\[0\.\.\.\1\]/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment