Skip to content

Instantly share code, notes, and snippets.

@tomjack

tomjack/init.el Secret

Created February 3, 2010 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomjack/c120edd064ad145656eb to your computer and use it in GitHub Desktop.
Save tomjack/c120edd064ad145656eb to your computer and use it in GitHub Desktop.
(defun insert-clojure-ns ()
(interactive)
(let* ((current-file-name (buffer-file-name))
(project-dir (expand-file-name (locate-dominating-file current-file-name "project.clj")))
(relative-file (substring current-file-name
(+ 4 (length project-dir))
(- (length current-file-name) 4))))
(insert "(ns " (replace-regexp-in-string "/" "." relative-file) ")")))
(define-key clojure-mode-map (kbd "C-c C-n") 'insert-clojure-ns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment