Skip to content

Support joker #160

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master (unreleased)

* [#160](https://github.com/clojure-emacs/inf-clojure/pull/160): Support [Joker](https://joker-lang.org/).
* [#135](https://github.com/clojure-emacs/inf-clojure/pull/135): Improve command sanitation code.

## 2.1.0 (2018-01-02)
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Clojure(Script) development:
* Macroexpansion
* Require `:reload`/`:reload-all`
* Support connecting to socket REPLs
* Support for Lumo
* Support for Planck
* Support for [Lumo](https://github.com/anmonteiro/lumo)
* Support for [Planck](http://planck-repl.org/)
* Support for [Joker](https://joker-lang.org/)

For a more powerful/full-featured solution see [CIDER](https://github.com/clojure-emacs/cider).

Expand Down Expand Up @@ -267,9 +268,9 @@ You can see all the configuration options available using the command
An `inf-clojure` REPL can be of different types: Clojure, ClojureScript, Lumo
and Planck are all potentially valid options.

At the moment, the default Clojure REPL, the Lumo REPL and the Planck REPL are
supported (standard ClojureScript is lacking mostly because some features
require to access the compiler state,
At the moment, the default Clojure REPL, the Lumo REPL, the Planck REPL and the
Joker REPL are supported (standard ClojureScript is lacking mostly because some
features require to access the compiler state,
[cljs-tooling](https://github.com/clojure-emacs/cljs-tooling) is a good
candidate for enabling support).

Expand Down Expand Up @@ -311,10 +312,11 @@ You can leave it enabled, it just won't show anything in the echo area.
#### Code Completion

Code completion is particularly open to customization. Not only you can `setq`
the customary `inf-clojure-completion-form`, `inf-clojure-completion-form-lumo`
and `inf-clojure-completion-form-planck` - the form to send to the REPL - but
you can also use `inf-clojure-completions-fn` for specifying a function that
given the REPL response should return elisp data compatible with
the customary `inf-clojure-completion-form`,
`inf-clojure-completion-form-lumo`, `inf-clojure-completion-form-planck` and
`inf-clojure-completion-form-joker` - the form to send to the REPL - but you
can also use `inf-clojure-completions-fn` for specifying a function that given
the REPL response should return elisp data compatible with
[`completion-at-point-functions`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion-in-Buffers.html).
For more info run `M-x describe-variable RET inf-clojure-completions-fn`.
Another option is to have a look at
Expand Down
99 changes: 99 additions & 0 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
;; * Support connecting to socket REPLs
;; * Support for Lumo
;; * Support for Planck
;; * Support for Joker
;;
;; For a more powerful/full-featured solution see https://github.com/clojure-emacs/cider.
;;
Expand Down Expand Up @@ -276,6 +277,16 @@ often connecting to a remote REPL process."
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

;;;; Joker
;;;; ====

(defcustom inf-clojure--joker-repl-form
"(find-ns 'joker.repl)"
"Form to invoke in order to verify that we launched a Planck REPL."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defvar-local inf-clojure-repl-type nil
"Symbol to define your REPL type.
Its root binding is nil and it can be further customized using
Expand All @@ -292,6 +303,7 @@ See http://blog.jorgenschaefer.de/2014/05/race-conditions-in-emacs-process-filte
(cond
((inf-clojure--some-response-p proc inf-clojure--lumo-repl-form) 'lumo)
((inf-clojure--some-response-p proc inf-clojure--planck-repl-form) 'planck)
((inf-clojure--some-response-p proc inf-clojure--joker-repl-form) 'joker)
(t 'clojure)))))

(defun inf-clojure--set-repl-type (proc)
Expand Down Expand Up @@ -374,13 +386,23 @@ Clojure to load that file."
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-load-form-joker "(load-file \"%s\")"
"Joker format-string for building a Clojure expression to load a file.
This format string should use `%s' to substitute a file name and
should result in a Clojure form that will be sent to the inferior
Clojure to load that file."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-load-form (proc)
"Return the form to query the Inf-Clojure PROC for var's documentation.
If you are using REPL types, it will pickup the most appropriate
`inf-clojure-var-doc-form` variant."
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-load-form-lumo)
(`planck inf-clojure-load-form-planck)
(`joker inf-clojure-load-form-joker)
(_ inf-clojure-load-form)))

(defcustom inf-clojure-reload-form "(require '%s :reload)"
Expand Down Expand Up @@ -813,6 +835,13 @@ The prefix argument ARG can change the behavior of the command:
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-var-doc-form-joker
"(joker.repl/doc %s)"
"Joker form to query inferior Clojure for a var's documentation."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-var-doc-form (proc)
"Return the form to query the Inf-Clojure PROC for a var's documentation.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -821,6 +850,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-var-doc-form-lumo)
(`planck inf-clojure-var-doc-form-planck)
(`joker inf-clojure-var-doc-form-joker)
(_ inf-clojure-var-doc-form))))

(defcustom inf-clojure-var-source-form
Expand All @@ -844,6 +874,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-var-source-form-joker
""
"Joker form to query inferior Clojure for a var's source."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-var-source-form (proc)
"Return the form to query the Inf-Clojure PROC for a var's source.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -852,6 +889,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-var-source-form-lumo)
(`planck inf-clojure-var-source-form-planck)
(`joker inf-clojure-var-source-form-joker)
(_ inf-clojure-var-source-form))))

(define-obsolete-variable-alias 'inf-clojure-var-source-command 'inf-clojure-var-source-form "2.0.0")
Expand Down Expand Up @@ -887,6 +925,18 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.1.0"))

(defcustom inf-clojure-arglists-form-joker
"(try
(:arglists
(joker.core/meta
(joker.core/resolve
(joker.core/read-string \"%s\"))))
(catch Error _ nil))"
"Joker form to query inferior Clojure for a function's arglists."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-arglists-form (proc)
"Return the form to query the Inf-Clojure PROC for arglists of a var.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -895,6 +945,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-arglists-form-lumo)
(`planck inf-clojure-arglists-form-planck)
(`joker inf-clojure-arglists-form-joker)
(_ inf-clojure-arglists-form))))

(defcustom inf-clojure-completion-form
Expand Down Expand Up @@ -923,6 +974,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-completion-form-joker
""
"Joker form to query inferior Clojure for completion candidates."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-completion-form (proc)
"Return the form to query the Inf-Clojure PROC for completions.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -931,6 +989,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-completion-form-lumo)
(`planck inf-clojure-completion-form-planck)
(`joker inf-clojure-completion-form-joker)
(_ inf-clojure-completion-form))))

(defcustom inf-clojure-ns-vars-form
Expand All @@ -954,6 +1013,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-ns-vars-form-joker
""
"Joker form to show the public vars in a namespace."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-ns-vars-form (proc)
"Return the form to query the Inf-Clojure PROC for public vars in a namespace.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -962,6 +1028,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-ns-vars-form-lumo)
(`planck inf-clojure-ns-vars-form-planck)
(`joker inf-clojure-ns-vars-form-joker)
(_ inf-clojure-ns-vars-form))))

(define-obsolete-variable-alias 'inf-clojure-ns-vars-command 'inf-clojure-ns-vars-form "2.0.0")
Expand All @@ -987,13 +1054,21 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-set-ns-form-joker
"(in-ns '%s)"
"Joker form to set the namespace of the inferior Clojure process."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-set-ns-form (proc)
"Return the form to set the namespace of the Inf-Clojure PROC.
If you are using REPL types, it will pickup the most appropriate
`inf-clojure-set-ns-form` variant."
(pcase (inf-clojure--set-repl-type proc)
(`planck inf-clojure-set-ns-form-planck)
(`lumo inf-clojure-set-ns-form-lumo)
(`joker inf-clojure-set-ns-form-joker)
(_ inf-clojure-set-ns-form)))

(define-obsolete-variable-alias 'inf-clojure-set-ns-command 'inf-clojure-set-ns-form "2.0.0")
Expand Down Expand Up @@ -1021,6 +1096,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.0.0"))

(defcustom inf-clojure-apropos-form-joker
""
"Joker form to invoke apropos."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-apropos-form (proc)
"Return the form to query the Inf-Clojure PROC for a var's apropos.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -1029,6 +1111,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-apropos-form-lumo)
(`planck inf-clojure-apropos-form-planck)
(`joker inf-clojure-apropos-form-joker)
(_ inf-clojure-apropos-form))))

(define-obsolete-variable-alias 'inf-clojure-apropos-command 'inf-clojure-apropos-form "2.0.0")
Expand All @@ -1054,6 +1137,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defcustom inf-clojure-macroexpand-form-joker
"(macroexpand '%s)"
"Joker form to invoke macroexpand."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-macroexpand-form (proc)
"Return the form for macroexpansion in the Inf-Clojure PROC.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -1062,6 +1152,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-macroexpand-form-lumo)
(`planck inf-clojure-macroexpand-form-planck)
(`joker inf-clojure-macroexpand-form-joker)
(_ inf-clojure-macroexpand-form))))

(define-obsolete-variable-alias 'inf-clojure-macroexpand-command 'inf-clojure-macroexpand-form "2.0.0")
Expand All @@ -1087,6 +1178,13 @@ If you are using REPL types, it will pickup the most appropriate
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defcustom inf-clojure-macroexpand-1-form-joker
"(macroexpand-1 '%s)"
"Joker form to invoke macroexpand-1."
:type 'string
:safe #'stringp
:package-version '(inf-clojure . "2.2.0"))

(defun inf-clojure-macroexpand-1-form (proc)
"Return the form for macroexpand-1 in the Inf-Clojure PROC.
If you are using REPL types, it will pickup the most appropriate
Expand All @@ -1095,6 +1193,7 @@ If you are using REPL types, it will pickup the most appropriate
(pcase (inf-clojure--set-repl-type proc)
(`lumo inf-clojure-macroexpand-1-form-lumo)
(`planck inf-clojure-macroexpand-1-form-planck)
(`joker inf-clojure-macroexpand-1-form-joker)
(_ inf-clojure-macroexpand-1-form))))

(define-obsolete-variable-alias 'inf-clojure-macroexpand-1-command 'inf-clojure-macroexpand-1-form "2.0.0")
Expand Down