Skip to content

Instantly share code, notes, and snippets.

@pallix
Created April 20, 2011 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pallix/931439 to your computer and use it in GitHub Desktop.
Save pallix/931439 to your computer and use it in GitHub Desktop.
Emacs YASnippet snippet for Clojure ns declarations
(ns `(let* ((nsname '())
(dirs (split-string (buffer-file-name) "/"))
(aftersrc nil))
(dolist (dir dirs)
(if aftersrc
(progn
(setq nsname (cons dir nsname))
(setq nsname (cons "." nsname)))
(when (or (string= dir "src") (string= dir "test"))
(setq aftersrc t))))
(when nsname
(replace-regexp-in-string "_" "-" (substring (apply 'concat (reverse nsname)) 0 -5))))`
(:use $1)
(:require ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment