Freigeben über


C# snippets for yasnippet.el (Emacs snippets)

Some nice person built yasnippet.el, a snippet package for emacs. You type 2 or 3 letters, then hit TAB, and it expands into a snippet.  Like dabbrev, but with forms-based fill-in fields.  It's quickie code generation. Sadly, no C# snippets are included.

Here's my contribution (attached).  There's one for try..catch, foreach, for, using, while, class definition, property definition, singleton, and a couple others.

yasnippet worked like a charm for me.  I did have to make a change in yasnippet.el:

 (defvar yas/known-modes
 ; added csharp so it will show up in the menu!! 
  '(ruby-mode rst-mode csharp-mode)
  "A list of mode which is well known but not part of emacs.")

Also I built a tool to generate the snippet bundle:

 ;; CreateSnippetBundle.el
;;
;; Useful utility for creating / updating / maintaining snippets ..
;; Complements the yasnippet package. 
;;
;; Run this once, and it creates the bundle.el file. 
;; do not delete this file!
;;
;; Time-stamp: <Friday, April 11, 2008  19:04:17  (by dinoch)>
;;


(require 'yasnippet)
(yas/compile-bundle 
 ; the starting point
 "c:/users/dinoch/elisp/yasnippet.el"

 ; the bundle file to generate
 "c:/users/dinoch/elisp/yasnippet-bundle.el" 

 ; the snippet dir from which to generate the bundle
 "c:/users/dinoch/elisp/snippets")

 

csharp-snippets.zip