Skip to content

Commit

Permalink
Add clojure-ts-mode support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Andre0991 committed Nov 20, 2023
1 parent 9aea501 commit 12e9c9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* [#202](https://github.com/clojure-emacs/inf-clojure/issues/202): Add ClojureCLR support.
* [#204](https://github.com/clojure-emacs/inf-clojure/issues/204): Scroll repl buffer on insert commands
* [#208](https://github.com/clojure-emacs/inf-clojure/pull/208) Display message after setting repl.
* [#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.

* [#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.
* [#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).

## 3.2.1 (2022-07-22)

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ If the installation doesn't work try refreshing the package list:
`M-x inf-clojure`. You can disable this behavior by setting `inf-clojure-auto-mode` to
`nil`.

**Note:** `inf-clojure` supports `clojure-ts-mode`, the Clojure major mode that uses
tree-sitter. In order to use it, replace `clojure-mode` by `clojure-ts-mode` in all
instructions below.

You can also add the following to your Emacs config to enable
`inf-clojure-minor-mode` for Clojure source buffers, regardless of whether there's an `inf-clojure` REPL running:

Expand Down
15 changes: 12 additions & 3 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
;;; Code:

(require 'comint)
(require 'clojure-mode)
(require 'clojure-mode nil 'no-error)
(require 'clojure-ts-mode nil 'no-error)
(require 'eldoc)
(require 'thingatpt)
(require 'ansi-color)
Expand Down Expand Up @@ -616,17 +617,25 @@ All buffers in `clojure-mode' will automatically be in
:safe #'booleanp
:package-version '(inf-clojure . "3.1.0"))

(defun inf-clojure--clojure-buffer-p ()
"Return t if the current buffer is derived from `clojure-mode' or `clojure-ts-mode'."
(or (derived-mode-p 'clojure-mode)
(derived-mode-p 'clojure-ts-mode)))

(defun inf-clojure--clojure-buffers ()
"Return a list of all existing `clojure-mode' buffers."
(cl-remove-if-not
(lambda (buffer) (with-current-buffer buffer (derived-mode-p 'clojure-mode)))
(lambda (buffer) (with-current-buffer buffer (inf-clojure--clojure-buffer-p)))
(buffer-list)))

(defun inf-clojure-enable-on-existing-clojure-buffers ()
"Enable inf-clojure's minor mode on existing Clojure buffers.
See command `inf-clojure-minor-mode'."
(interactive)
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)
(when (featurep 'clojure-mode)
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode))
(when (featurep 'clojure-ts-mode)
(add-hook 'clojure-ts-mode-hook #'inf-clojure-minor-mode))
(dolist (buffer (inf-clojure--clojure-buffers))
(with-current-buffer buffer
(inf-clojure-minor-mode +1))))
Expand Down

0 comments on commit 12e9c9d

Please sign in to comment.