Skip to content

Instantly share code, notes, and snippets.

@ussy
Created August 26, 2011 11:06
Show Gist options
  • Save ussy/1173199 to your computer and use it in GitHub Desktop.
Save ussy/1173199 to your computer and use it in GitHub Desktop.
Quick Scala Specs
(defun my-quick-specs()
(interactive)
(if buffer-file-name
(cond
((string-match "^\\(.*?/src/\\)test\\(/scala/.+?/\\)\\(.+?\\)Spec\\.scala$" buffer-file-name)
(let* ((base-dir (match-string 1 buffer-file-name))
(target-dir (match-string 2 buffer-file-name))
(target-name (match-string 3 buffer-file-name))
(target-path (concat base-dir "main" target-dir target-name ".scala")))
(find-file target-path)))
((string-match "^\\(.*?/src/\\)main\\(/scala/.+?/\\)\\(.+?\\)\\.scala$" buffer-file-name)
(let* ((base-dir (match-string 1 buffer-file-name))
(target-dir (match-string 2 buffer-file-name))
(target-name (match-string 3 buffer-file-name))
(target-path (concat base-dir "test" target-dir target-name "Spec.scala")))
(find-file target-path))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment