Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Last active December 30, 2015 13:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdone/4a62278438b219433b4b to your computer and use it in GitHub Desktop.
Save chrisdone/4a62278438b219433b4b to your computer and use it in GitHub Desktop.

structured-haskell-mode

This minor mode provides structured editing operations based on the syntax of Haskell. In short-hand it's called SHM and throughout the codebase, too. It acts a bit like, and is heavily inspired by, paredit-mode for Emacs.

Features

Its features work by parsing the current declaration with an executable called structured-haskell-mode, and then creates marks for all the nodes' positions in the buffer.

Feature | Explanation --- | --- | --- newline-indent | Indenting: shm/newline-indent takes the current node and its type into consideration giving very predictable and useful behaviour. goto-parent | Going to parent: shm/goto-parent jumps to the start of the parent. goto-parent-end | Going to parent end: shm/goto-parent-end jumps to the end of the parent. add-list-item | Adding a list item: shm/newline-indent (C-j) will automatically add a comma when inside a list. add-operand | Adding operands: shm/add-operand (C-+) will look at the current node and add another operand in the direction the cursor is leaning towards. auto-re-indent | Auto-reindenting: Typing and deleting will automatically re-indent dependent code blocks. raise | Raising: shm/raise raises the current node to replace its parent. If its direct parent is not the same expression type, it continues up the tree. re-indenting | Re-indenting: shm/newline-indent and shm/delete-indentation allow you to bring nodes inwards or outwards relative to the parent. record-syntax | Record syntax: Creating new elements with record syntax, like lists (and tuples) automatically adds the right separators. transposition | Transposition: shm/tranpose will swap two sibling nodes. kill-yank | Copy/pasting: shm/kill and shm/yank take indentation into account, and automatically normalize so that re-inserting will indent properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment