home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

README.md (2577B)


      1 # Shnippet
      2 
      3 
      4 **Shnippet** is a collection of
      5 [YASnippet][yas]
      6 [Haskell][haskell] snippets for Emacs.
      7 
      8 
      9 ## Installation
     10 
     11 Clone repository:
     12 
     13     $ cd ~/.emacs.d/snippets
     14     $ git clone https://github.com/LukeHoersten/shnippet
     15     OR
     16     $ hg clone https://bitbucket.org/LukeHoersten/shnippet
     17 
     18 Add the cloned repository to YASnippet's `yas-snippet-dirs`:
     19 
     20     (setq yas-snippet-dirs
     21           '("~/.emacs.d/snippets/shnippet"
     22             "/other/paths/"
     23             ))
     24 
     25 Snippets may have to be recompiled and reloaded in Emacs if YASnippet
     26 is already in use:
     27 
     28     M-x yas-recompile-all
     29     M-x yas-reload-all
     30 
     31 
     32 Haskell snippts should now be available to use! In a `haskell-mode`
     33 buffer, type `fn<TAB>`. A prompt should appear asking which `fn`
     34 snippet to expand.
     35 
     36 I **highly** recommend using YASnippet with [ido-mode]. Configure
     37 Emacs:
     38 
     39     (setq-default yas-prompt-functions '(yas-ido-prompt yas-dropdown-prompt))
     40 
     41 This is important so that alternatives (like `import` vs. `import
     42 qualified`) can quickly be selected with a single key stroke.
     43 
     44 
     45 ## Available Expansion Keys
     46 
     47 * `new` - newtype
     48 * `mod` - module [simple, exports]
     49 * `main ` - main module and function
     50 * `let` - let bindings
     51 * `lang` - language extension pragmas
     52 * `\` - lambda function
     53 * `inst` - instance declairation
     54 * `imp` - import modules [simple, qualified]
     55 * `if` - if conditional [inline, block]
     56 * `<-` - monadic get
     57 * `fn` - top level function [simple, guarded, clauses]
     58 * `data` - data type definition [inline, record]
     59 * `=>` - type constraint
     60 * `{-` - block comment
     61 * `case` - case statement
     62 
     63 
     64 ## Design Ideals
     65 
     66 * Keep snippet keys (the prefix used to auto-complete) to four
     67   characters or less while still being as easy to guess as possible.
     68 
     69 * Have as few keys as possible. The more keys there are to remember,
     70   the harder snippets are to use and learn.
     71 
     72 * Leverage [ido-mode][] when reasonable. For instance, to keep the
     73   number of snippet keys to a minimum as well as auto complete things
     74   like [Haskell Langauge Extension Pragmas][lang-pragma]. When
     75   multiple snippets share a key (ex: `fn`), the `ido-mode` prompts are
     76   unique to one character (ex: `guarded function` and `simple
     77   function` are `g` and `s` respectively).
     78 
     79 
     80 ## Authors
     81 
     82 This code is written and maintained by Luke Hoersten,
     83 <luke@hoersten.org>.
     84 
     85 
     86 [yas]: https://github.com/capitaomorte/yasnippet
     87 [ido-mode]: http://www.emacswiki.org/emacs/InteractivelyDoThings
     88 [lang-pragma]: http://hackage.haskell.org/packages/archive/Cabal/1.16.0.3/doc/html/Language-Haskell-Extension.html#t:KnownExtension
     89 [haskell]: http://haskell.org/