Skip to content

Commit 6313976

Browse files
chaosbbatsov
chaos
authored andcommitted
Nbb support
1 parent 414157c commit 6313976

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changes
66

7+
* [#641](https://github.com/clojure-emacs/clojure-mode/issues/641) Recognize nbb projects (identified by the presence of `nbb.edn`).
78
* [#629](https://github.com/clojure-emacs/clojure-mode/pull/629): Set `add-log-current-defun-function` to new function `clojure-current-defun-name` (this is used by `which-function-mode` and `easy-kill`).
89

910
### Bugs fixed

Diff for: clojure-mode.el

+6-2
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ For example, \[ is allowed in :db/id[:db.part/user]."
189189
"deps.edn" ; Clojure CLI (a.k.a. tools.deps)
190190
"shadow-cljs.edn" ; shadow-cljs
191191
"bb.edn" ; babashka
192+
"nbb.edn" ; nbb
192193
)
193194
"A list of files, which identify a Clojure project's root.
194195
Out-of-the box `clojure-mode' understands lein, boot, gradle,
195-
shadow-cljs, tools.deps and babashka."
196+
shadow-cljs, tools.deps, babashka and nbb."
196197
:type '(repeat string)
197198
:package-version '(clojure-mode . "5.0.0")
198199
:safe (lambda (value)
@@ -3219,7 +3220,10 @@ With universal argument \\[universal-argument], act on the \"top-level\" form."
32193220
;; boot build scripts are Clojure source files
32203221
(add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-mode))
32213222
;; babashka scripts are Clojure source files
3222-
(add-to-list 'interpreter-mode-alist '("bb" . clojure-mode)))
3223+
;; nbb scripts are ClojureScript source files
3224+
(add-to-list 'interpreter-mode-alist
3225+
'("bb" . clojure-mode)
3226+
'("nbb" . clojurescript-mode)))
32233227

32243228
(provide 'clojure-mode)
32253229

Diff for: test/clojure-mode-util-test.el

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
(clj-file-ns "my-project.my-ns.my-file")
4040
(clojure-cache-project nil))
4141

42+
(describe "clojure-project-root-path"
43+
(it "nbb subdir"
44+
(with-temp-dir temp-dir
45+
(let* ((bb-edn (expand-file-name "nbb.edn" temp-dir))
46+
(bb-edn-src (expand-file-name "src" temp-dir)))
47+
(write-region "{}" nil bb-edn)
48+
(make-directory bb-edn-src)
49+
(expect (clojure-project-dir bb-edn-src)
50+
:to-equal (file-name-as-directory temp-dir))))))
51+
4252
(describe "clojure-project-relative-path"
4353
(cl-letf (((symbol-function 'clojure-project-dir) (lambda () project-dir)))
4454
(expect (string= (clojure-project-relative-path clj-file-path)

Diff for: test/utils/test-helper.el

+10
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,15 @@ DESCRIPTION is a string with the description of the spec."
9696
(expect (point) :to-equal expected-cursor-pos)))))
9797

9898

99+
;; https://emacs.stackexchange.com/a/55031
100+
(defmacro with-temp-dir (temp-dir &rest body)
101+
"Create a temporary directory and bind its to TEMP-DIR while evaluating BODY.
102+
Removes the temp directory at the end of evaluation."
103+
`(let ((,temp-dir (make-temp-file "" t)))
104+
(unwind-protect
105+
(progn
106+
,@body)
107+
(delete-directory ,temp-dir t))))
108+
99109
(provide 'test-helper)
100110
;;; test-helper.el ends here

0 commit comments

Comments
 (0)