Skip to content

Instantly share code, notes, and snippets.

@c-garcia
Created February 12, 2017 19:44
Show Gist options
  • Save c-garcia/e4218c6ebe17afd2b06171128acb0728 to your computer and use it in GitHub Desktop.
Save c-garcia/e4218c6ebe17afd2b06171128acb0728 to your computer and use it in GitHub Desktop.
Guess the file path of an emacs buffer holding a clojure file.
(defun guess-clojure-test-file ()
"Guesses the test file path of the current buffer if it is a clojure file."
(interactive)
(let ((clojure-file-name buffer-file-name))
(with-temp-buffer
(insert clojure-file-name)
(goto-char (point-max))
(search-backward "src")
(replace-match "test")
(goto-char (point-max))
(search-backward ".")
(replace-match "_test.")
(message (buffer-string)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment