From e9e94488737b313cf87c25635a8dea68fde55283 Mon Sep 17 00:00:00 2001 From: Jinseop Kim Date: Thu, 30 Jul 2015 18:31:49 +0900 Subject: [PATCH] Fix for error in `clojure-expected-ns` When call `clojure-expected-ns` function without arguments, error occured. --- clojure-mode.el | 4 ++-- test/clojure-mode-util-test.el | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/clojure-mode.el b/clojure-mode.el index 083ddb29..6830875d 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -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))))) (sans-file-sep (mapconcat 'identity (cdr (split-string sans-file-type "/")) ".")) (sans-underscores (replace-regexp-in-string "_" "-" sans-file-sep))) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index 37367578..5fd689b2 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -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)