Skip to content

Commit b2ed775

Browse files
committed
Support joker
This patch introduces the defcustoms necessary for supporting joker.
1 parent 975e580 commit b2ed775

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

inf-clojure.el

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
;; * Support connecting to socket REPLs
4949
;; * Support for Lumo
5050
;; * Support for Planck
51+
;; * Support for Joker
5152
;;
5253
;; For a more powerful/full-featured solution see https://github.com/clojure-emacs/cider.
5354
;;
@@ -276,6 +277,16 @@ often connecting to a remote REPL process."
276277
:safe #'stringp
277278
:package-version '(inf-clojure . "2.0.0"))
278279

280+
;;;; Joker
281+
;;;; ====
282+
283+
(defcustom inf-clojure--joker-repl-form
284+
"(find-ns 'joker.repl)"
285+
"Form to invoke in order to verify that we launched a Planck REPL."
286+
:type 'string
287+
:safe #'stringp
288+
:package-version '(inf-clojure . "2.2.0"))
289+
279290
(defvar-local inf-clojure-repl-type nil
280291
"Symbol to define your REPL type.
281292
Its root binding is nil and it can be further customized using
@@ -292,6 +303,7 @@ See http://blog.jorgenschaefer.de/2014/05/race-conditions-in-emacs-process-filte
292303
(cond
293304
((inf-clojure--some-response-p proc inf-clojure--lumo-repl-form) 'lumo)
294305
((inf-clojure--some-response-p proc inf-clojure--planck-repl-form) 'planck)
306+
((inf-clojure--some-response-p proc inf-clojure--joker-repl-form) 'joker)
295307
(t 'clojure)))))
296308

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

389+
(defcustom inf-clojure-load-form-joker "(load-file \"%s\")"
390+
"Joker format-string for building a Clojure expression to load a file.
391+
This format string should use `%s' to substitute a file name and
392+
should result in a Clojure form that will be sent to the inferior
393+
Clojure to load that file."
394+
:type 'string
395+
:safe #'stringp
396+
:package-version '(inf-clojure . "2.2.0"))
397+
377398
(defun inf-clojure-load-form (proc)
378399
"Return the form to query the Inf-Clojure PROC for var's documentation.
379400
If you are using REPL types, it will pickup the most appropriate
380401
`inf-clojure-var-doc-form` variant."
381402
(pcase (inf-clojure--set-repl-type proc)
382403
(`lumo inf-clojure-load-form-lumo)
383404
(`planck inf-clojure-load-form-planck)
405+
(`joker inf-clojure-load-form-joker)
384406
(_ inf-clojure-load-form)))
385407

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

838+
(defcustom inf-clojure-var-doc-form-joker
839+
"(joker.repl/doc %s)"
840+
"Joker form to query inferior Clojure for a var's documentation."
841+
:type 'string
842+
:safe #'stringp
843+
:package-version '(inf-clojure . "2.2.0"))
844+
816845
(defun inf-clojure-var-doc-form (proc)
817846
"Return the form to query the Inf-Clojure PROC for a var's documentation.
818847
If you are using REPL types, it will pickup the most appropriate
@@ -821,6 +850,7 @@ If you are using REPL types, it will pickup the most appropriate
821850
(pcase (inf-clojure--set-repl-type proc)
822851
(`lumo inf-clojure-var-doc-form-lumo)
823852
(`planck inf-clojure-var-doc-form-planck)
853+
(`joker inf-clojure-var-doc-form-joker)
824854
(_ inf-clojure-var-doc-form))))
825855

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

877+
(defcustom inf-clojure-var-source-form-joker
878+
""
879+
"Joker form to query inferior Clojure for a var's source."
880+
:type 'string
881+
:safe #'stringp
882+
:package-version '(inf-clojure . "2.2.0"))
883+
847884
(defun inf-clojure-var-source-form (proc)
848885
"Return the form to query the Inf-Clojure PROC for a var's source.
849886
If you are using REPL types, it will pickup the most appropriate
@@ -852,6 +889,7 @@ If you are using REPL types, it will pickup the most appropriate
852889
(pcase (inf-clojure--set-repl-type proc)
853890
(`lumo inf-clojure-var-source-form-lumo)
854891
(`planck inf-clojure-var-source-form-planck)
892+
(`joker inf-clojure-var-source-form-joker)
855893
(_ inf-clojure-var-source-form))))
856894

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

928+
(defcustom inf-clojure-arglists-form-joker
929+
"(try
930+
(:arglists
931+
(joker.core/meta
932+
(joker.core/resolve
933+
(joker.core/read-string \"%s\"))))
934+
(catch Error _ nil))"
935+
"Joker form to query inferior Clojure for a function's arglists."
936+
:type 'string
937+
:safe #'stringp
938+
:package-version '(inf-clojure . "2.2.0"))
939+
890940
(defun inf-clojure-arglists-form (proc)
891941
"Return the form to query the Inf-Clojure PROC for arglists of a var.
892942
If you are using REPL types, it will pickup the most appropriate
@@ -895,6 +945,7 @@ If you are using REPL types, it will pickup the most appropriate
895945
(pcase (inf-clojure--set-repl-type proc)
896946
(`lumo inf-clojure-arglists-form-lumo)
897947
(`planck inf-clojure-arglists-form-planck)
948+
(`joker inf-clojure-arglists-form-joker)
898949
(_ inf-clojure-arglists-form))))
899950

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

977+
(defcustom inf-clojure-completion-form-joker
978+
""
979+
"Joker form to query inferior Clojure for completion candidates."
980+
:type 'string
981+
:safe #'stringp
982+
:package-version '(inf-clojure . "2.2.0"))
983+
926984
(defun inf-clojure-completion-form (proc)
927985
"Return the form to query the Inf-Clojure PROC for completions.
928986
If you are using REPL types, it will pickup the most appropriate
@@ -931,6 +989,7 @@ If you are using REPL types, it will pickup the most appropriate
931989
(pcase (inf-clojure--set-repl-type proc)
932990
(`lumo inf-clojure-completion-form-lumo)
933991
(`planck inf-clojure-completion-form-planck)
992+
(`joker inf-clojure-completion-form-joker)
934993
(_ inf-clojure-completion-form))))
935994

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

1016+
(defcustom inf-clojure-ns-vars-form-joker
1017+
""
1018+
"Joker form to show the public vars in a namespace."
1019+
:type 'string
1020+
:safe #'stringp
1021+
:package-version '(inf-clojure . "2.2.0"))
1022+
9571023
(defun inf-clojure-ns-vars-form (proc)
9581024
"Return the form to query the Inf-Clojure PROC for public vars in a namespace.
9591025
If you are using REPL types, it will pickup the most appropriate
@@ -962,6 +1028,7 @@ If you are using REPL types, it will pickup the most appropriate
9621028
(pcase (inf-clojure--set-repl-type proc)
9631029
(`lumo inf-clojure-ns-vars-form-lumo)
9641030
(`planck inf-clojure-ns-vars-form-planck)
1031+
(`joker inf-clojure-ns-vars-form-joker)
9651032
(_ inf-clojure-ns-vars-form))))
9661033

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

1057+
(defcustom inf-clojure-set-ns-form-joker
1058+
"(in-ns '%s)"
1059+
"Joker form to set the namespace of the inferior Clojure process."
1060+
:type 'string
1061+
:safe #'stringp
1062+
:package-version '(inf-clojure . "2.2.0"))
1063+
9901064
(defun inf-clojure-set-ns-form (proc)
9911065
"Return the form to set the namespace of the Inf-Clojure PROC.
9921066
If you are using REPL types, it will pickup the most appropriate
9931067
`inf-clojure-set-ns-form` variant."
9941068
(pcase (inf-clojure--set-repl-type proc)
9951069
(`planck inf-clojure-set-ns-form-planck)
9961070
(`lumo inf-clojure-set-ns-form-lumo)
1071+
(`joker inf-clojure-set-ns-form-joker)
9971072
(_ inf-clojure-set-ns-form)))
9981073

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

1099+
(defcustom inf-clojure-apropos-form-joker
1100+
""
1101+
"Joker form to invoke apropos."
1102+
:type 'string
1103+
:safe #'stringp
1104+
:package-version '(inf-clojure . "2.2.0"))
1105+
10241106
(defun inf-clojure-apropos-form (proc)
10251107
"Return the form to query the Inf-Clojure PROC for a var's apropos.
10261108
If you are using REPL types, it will pickup the most appropriate
@@ -1029,6 +1111,7 @@ If you are using REPL types, it will pickup the most appropriate
10291111
(pcase (inf-clojure--set-repl-type proc)
10301112
(`lumo inf-clojure-apropos-form-lumo)
10311113
(`planck inf-clojure-apropos-form-planck)
1114+
(`joker inf-clojure-apropos-form-joker)
10321115
(_ inf-clojure-apropos-form))))
10331116

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

1140+
(defcustom inf-clojure-macroexpand-form-joker
1141+
"(macroexpand '%s)"
1142+
"Joker form to invoke macroexpand."
1143+
:type 'string
1144+
:safe #'stringp
1145+
:package-version '(inf-clojure . "2.2.0"))
1146+
10571147
(defun inf-clojure-macroexpand-form (proc)
10581148
"Return the form for macroexpansion in the Inf-Clojure PROC.
10591149
If you are using REPL types, it will pickup the most appropriate
@@ -1062,6 +1152,7 @@ If you are using REPL types, it will pickup the most appropriate
10621152
(pcase (inf-clojure--set-repl-type proc)
10631153
(`lumo inf-clojure-macroexpand-form-lumo)
10641154
(`planck inf-clojure-macroexpand-form-planck)
1155+
(`joker inf-clojure-macroexpand-form-joker)
10651156
(_ inf-clojure-macroexpand-form))))
10661157

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

1181+
(defcustom inf-clojure-macroexpand-1-form-joker
1182+
"(macroexpand-1 '%s)"
1183+
"Joker form to invoke macroexpand-1."
1184+
:type 'string
1185+
:safe #'stringp
1186+
:package-version '(inf-clojure . "2.2.0"))
1187+
10901188
(defun inf-clojure-macroexpand-1-form (proc)
10911189
"Return the form for macroexpand-1 in the Inf-Clojure PROC.
10921190
If you are using REPL types, it will pickup the most appropriate
@@ -1095,6 +1193,7 @@ If you are using REPL types, it will pickup the most appropriate
10951193
(pcase (inf-clojure--set-repl-type proc)
10961194
(`lumo inf-clojure-macroexpand-1-form-lumo)
10971195
(`planck inf-clojure-macroexpand-1-form-planck)
1196+
(`joker inf-clojure-macroexpand-1-form-joker)
10981197
(_ inf-clojure-macroexpand-1-form))))
10991198

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

0 commit comments

Comments
 (0)