Skip to content

Fix for error in clojure-expected-ns. #313

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

Merged
merged 1 commit into from
Aug 1, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ nil."
PATH is expected to be an absolute file path.

If PATH is nil, use the path to the file backing the current buffer."
(let* ((relative (clojure-project-relative-path
(or path (file-truename (buffer-file-name)))))
(let* ((path (or path (file-truename (buffer-file-name))))
(relative (clojure-project-relative-path path))
(sans-file-type (substring relative 0 (- (length (file-name-extension path t)))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can't spot the problem, @bbatsov, path will be nil on this line when the function is called without any arguments.

(sans-file-sep (mapconcat 'identity (cdr (split-string sans-file-type "/")) "."))
(sans-underscores (replace-regexp-in-string "_" "-" sans-file-sep)))
Expand Down
11 changes: 10 additions & 1 deletion test/clojure-mode-util-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@
(cl-letf (((symbol-function 'clojure-project-relative-path)
(lambda (&optional current-buffer-file-name)
project-relative-clj-file-path)))
(should (string= (clojure-expected-ns clj-file-path) clj-file-ns)))))
(should (string= (clojure-expected-ns clj-file-path) clj-file-ns))))

(ert-deftest expected-ns-without-argument ()
:tags '(utils)
(cl-letf (((symbol-function 'clojure-project-relative-path)
(lambda (&optional current-buffer-file-name)
project-relative-clj-file-path)))
(should (string= (let ((buffer-file-name clj-file-path))
(clojure-expected-ns))
clj-file-ns)))))

(provide 'clojure-mode-util-test)

Expand Down