Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 'clojure-jump-between-tests-and-code' when the namespace is #105

Merged
merged 2 commits into from Dec 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions clojure-mode.el
Expand Up @@ -1198,17 +1198,13 @@ The arguments are dir, hostname, and port. The return value should be an `alist

(defun clojure-test-for (namespace)
(let* ((namespace (clojure-underscores-for-hyphens namespace))
(segments (split-string namespace "\\."))
(before (subseq segments 0 clojure-test-ns-segment-position))
(after (subseq segments clojure-test-ns-segment-position))
(newfile (car after))
(test-segments (append before (list newfile))))
(mapconcat 'identity test-segments "/test/")))
(segments (split-string namespace "\\.")))
(mapconcat 'identity segments "/")))

(defun clojure-jump-to-test ()
"Jump from implementation file to test."
(interactive)
(find-file (format "%stest/%s.clj"
(find-file (format "%stest/%s_test.clj"
(file-name-as-directory
(locate-dominating-file buffer-file-name "src/"))
(clojure-test-for (clojure-find-ns)))))
Expand Down
10 changes: 3 additions & 7 deletions clojure-test-mode.el
Expand Up @@ -326,13 +326,9 @@ Retuns the problem overlay if such a position is found, otherwise nil."
(defun clojure-test-implementation-for (namespace)
(let* ((namespace (clojure-underscores-for-hyphens namespace))
(segments (split-string namespace "\\."))
(test-position
(if (> 0 clojure-test-ns-segment-position)
(1- (+ (length segments) clojure-test-ns-segment-position))
clojure-test-ns-segment-position))
(before (subseq segments 0 test-position))
(after (subseq segments (1+ test-position)))
(impl-segments (append before after)))
(namespace-end (split-string (car (last segments)) "_"))
(namespace-end (mapconcat 'identity (butlast namespace-end 1) "_"))
(impl-segments (append (butlast segments 1) (list namespace-end))))
(mapconcat 'identity impl-segments "/")))

;; Commands
Expand Down