Skip to content

Instantly share code, notes, and snippets.

@jaycfields
Created November 3, 2012 17:23
Show Gist options
  • Save jaycfields/4008015 to your computer and use it in GitHub Desktop.
Save jaycfields/4008015 to your computer and use it in GitHub Desktop.
(defun src-full-path (project-root file-name)
(concat
(replace-regexp-in-string
(concat (expand-file-name project-root) "test/clojure/expectations")
(concat project-root "src/clojure")
(file-name-directory file-name))
(replace-regexp-in-string
"_expectations"
""
(file-name-nondirectory file-name))))
(defun find-src ()
(interactive)
(let* ((project-root (locate-dominating-file
(file-name-directory (buffer-file-name)) "project.clj")))
(if project-root
(let* ((full-path (src-full-path project-root (buffer-file-name))))
(if (file-exists-p full-path)
(set-window-buffer (next-window) (find-file-noselect full-path))
(message (concat "cound not find " full-path))))
(message (concat "no project.clj found at or below " (buffer-file-name))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment