Skip to content

Commit 12e9c9d

Browse files
committed
Add clojure-ts-mode support
Add support to `clojure-ts-mode`, a Clojure major mode that uses tree-sitter. For more details on `clojure-ts-mode`, consult its repository [0]. [0]: https://github.com/clojure-emacs/clojure-ts-mode.
1 parent 9aea501 commit 12e9c9d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* [#202](https://github.com/clojure-emacs/inf-clojure/issues/202): Add ClojureCLR support.
66
* [#204](https://github.com/clojure-emacs/inf-clojure/issues/204): Scroll repl buffer on insert commands
77
* [#208](https://github.com/clojure-emacs/inf-clojure/pull/208) Display message after setting repl.
8-
* [#210](https://github.com/clojure-emacs/inf-clojure/pull/210) Include `inf-clojure-socket-repl` to create a socket REPL and connect to it from inside Emacs.
9-
8+
* [#210](https://github.com/clojure-emacs/inf-clojure/pull/210) Include `inf-clojure-socket-repl` to create a socket REPL and connect to it from inside Emacs.
9+
* [#215](https://github.com/clojure-emacs/inf-clojure/pull/215) Add support to `clojure-ts-mode`, a Clojure major mode that uses tree-sitter. For more details on `clojure-ts-mode`, consult its [repository](https://github.com/clojure-emacs/clojure-ts-mode).
1010

1111
## 3.2.1 (2022-07-22)
1212

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ If the installation doesn't work try refreshing the package list:
9898
`M-x inf-clojure`. You can disable this behavior by setting `inf-clojure-auto-mode` to
9999
`nil`.
100100

101+
**Note:** `inf-clojure` supports `clojure-ts-mode`, the Clojure major mode that uses
102+
tree-sitter. In order to use it, replace `clojure-mode` by `clojure-ts-mode` in all
103+
instructions below.
104+
101105
You can also add the following to your Emacs config to enable
102106
`inf-clojure-minor-mode` for Clojure source buffers, regardless of whether there's an `inf-clojure` REPL running:
103107

inf-clojure.el

+12-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
;;; Code:
6565

6666
(require 'comint)
67-
(require 'clojure-mode)
67+
(require 'clojure-mode nil 'no-error)
68+
(require 'clojure-ts-mode nil 'no-error)
6869
(require 'eldoc)
6970
(require 'thingatpt)
7071
(require 'ansi-color)
@@ -616,17 +617,25 @@ All buffers in `clojure-mode' will automatically be in
616617
:safe #'booleanp
617618
:package-version '(inf-clojure . "3.1.0"))
618619

620+
(defun inf-clojure--clojure-buffer-p ()
621+
"Return t if the current buffer is derived from `clojure-mode' or `clojure-ts-mode'."
622+
(or (derived-mode-p 'clojure-mode)
623+
(derived-mode-p 'clojure-ts-mode)))
624+
619625
(defun inf-clojure--clojure-buffers ()
620626
"Return a list of all existing `clojure-mode' buffers."
621627
(cl-remove-if-not
622-
(lambda (buffer) (with-current-buffer buffer (derived-mode-p 'clojure-mode)))
628+
(lambda (buffer) (with-current-buffer buffer (inf-clojure--clojure-buffer-p)))
623629
(buffer-list)))
624630

625631
(defun inf-clojure-enable-on-existing-clojure-buffers ()
626632
"Enable inf-clojure's minor mode on existing Clojure buffers.
627633
See command `inf-clojure-minor-mode'."
628634
(interactive)
629-
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)
635+
(when (featurep 'clojure-mode)
636+
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode))
637+
(when (featurep 'clojure-ts-mode)
638+
(add-hook 'clojure-ts-mode-hook #'inf-clojure-minor-mode))
630639
(dolist (buffer (inf-clojure--clojure-buffers))
631640
(with-current-buffer buffer
632641
(inf-clojure-minor-mode +1))))

0 commit comments

Comments
 (0)