Skip to content

Nbb support #642

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 2 commits into from
Dec 3, 2022
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
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
entrypoint: bash
<<: *default-steps

test-emacs-28:
docker:
- image: silex/emacs:28-ci-cask
entrypoint: bash
<<: *default-steps

test-emacs-master:
docker:
- image: silex/emacs:master-ci-cask
Expand All @@ -46,4 +52,5 @@ workflows:
- test-emacs-25
- test-emacs-26
- test-emacs-27
- test-emacs-28
- test-emacs-master
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changes

* [#641](https://github.com/clojure-emacs/clojure-mode/issues/641) Recognize nbb projects (identified by the presence of `nbb.edn`).
* [#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`).

### Bugs fixed
Expand Down
8 changes: 6 additions & 2 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ For example, \[ is allowed in :db/id[:db.part/user]."
"deps.edn" ; Clojure CLI (a.k.a. tools.deps)
"shadow-cljs.edn" ; shadow-cljs
"bb.edn" ; babashka
"nbb.edn" ; nbb
)
"A list of files, which identify a Clojure project's root.
Out-of-the box `clojure-mode' understands lein, boot, gradle,
shadow-cljs, tools.deps and babashka."
shadow-cljs, tools.deps, babashka and nbb."
:type '(repeat string)
:package-version '(clojure-mode . "5.0.0")
:safe (lambda (value)
Expand Down Expand Up @@ -3219,7 +3220,10 @@ With universal argument \\[universal-argument], act on the \"top-level\" form."
;; boot build scripts are Clojure source files
(add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-mode))
;; babashka scripts are Clojure source files
(add-to-list 'interpreter-mode-alist '("bb" . clojure-mode)))
;; nbb scripts are ClojureScript source files
(add-to-list 'interpreter-mode-alist
'("bb" . clojure-mode)
'("nbb" . clojurescript-mode)))

(provide 'clojure-mode)

Expand Down
10 changes: 10 additions & 0 deletions test/clojure-mode-util-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
(clj-file-ns "my-project.my-ns.my-file")
(clojure-cache-project nil))

(describe "clojure-project-root-path"
(it "nbb subdir"
(with-temp-dir temp-dir
(let* ((bb-edn (expand-file-name "nbb.edn" temp-dir))
(bb-edn-src (expand-file-name "src" temp-dir)))
(write-region "{}" nil bb-edn)
(make-directory bb-edn-src)
(expect (clojure-project-dir bb-edn-src)
:to-equal (file-name-as-directory temp-dir))))))

(describe "clojure-project-relative-path"
(cl-letf (((symbol-function 'clojure-project-dir) (lambda () project-dir)))
(expect (string= (clojure-project-relative-path clj-file-path)
Expand Down
10 changes: 10 additions & 0 deletions test/utils/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,15 @@ DESCRIPTION is a string with the description of the spec."
(expect (point) :to-equal expected-cursor-pos)))))


;; https://emacs.stackexchange.com/a/55031
(defmacro with-temp-dir (temp-dir &rest body)
"Create a temporary directory and bind its to TEMP-DIR while evaluating BODY.
Removes the temp directory at the end of evaluation."
`(let ((,temp-dir (make-temp-file "" t)))
(unwind-protect
(progn
,@body)
(delete-directory ,temp-dir t))))

(provide 'test-helper)
;;; test-helper.el ends here