[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/clojure-mode 6313976a8f 1/2: Nbb support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/clojure-mode 6313976a8f 1/2: Nbb support |
Date: |
Sat, 3 Dec 2022 16:58:23 -0500 (EST) |
branch: elpa/clojure-mode
commit 6313976a8fd5b5ee28466cdfcf641b3c818e8d55
Author: chaos <chaos@sympan>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
Nbb support
---
CHANGELOG.md | 1 +
clojure-mode.el | 8 ++++++--
test/clojure-mode-util-test.el | 10 ++++++++++
test/utils/test-helper.el | 10 ++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f267c99af..34ce38bf6a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/clojure-mode.el b/clojure-mode.el
index 0ed97f1f7f..89d903090e 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -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)
@@ -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)
diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el
index 95931d9dc9..bf17d02a54 100644
--- a/test/clojure-mode-util-test.el
+++ b/test/clojure-mode-util-test.el
@@ -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)
diff --git a/test/utils/test-helper.el b/test/utils/test-helper.el
index fd3db30912..c8dfed86e0 100644
--- a/test/utils/test-helper.el
+++ b/test/utils/test-helper.el
@@ -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