@@ -363,11 +363,11 @@ Clojure to load that file."
363
363
:safe #'stringp
364
364
:package-version '(inf-clojure . " 2.0.0" ))
365
365
366
- (defun inf-clojure-load-form ()
367
- " Return the form to query inferior Clojure for a var's documentation.
366
+ (defun inf-clojure-load-form (proc )
367
+ " Return the form to query the Inf- Clojure PROC for var's documentation.
368
368
If you are using REPL types, it will pickup the most appropriate
369
369
`inf-clojure-var-doc-form` variant."
370
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
370
+ (pcase (inf-clojure--set-repl-type proc)
371
371
(`lumo inf-clojure-load-form-lumo)
372
372
(`planck inf-clojure-load-form-planck)
373
373
(_ inf-clojure-load-form)))
@@ -689,15 +689,15 @@ The prefix argument SWITCH-TO-REPL controls whether to switch to
689
689
REPL after the file is loaded or not. If the argument FILE-NAME
690
690
is present it will be used instead of the current file."
691
691
(interactive " P" )
692
- (let ((file-name (or file-name
692
+ (let ((proc (inf-clojure-proc))
693
+ (file-name (or file-name
693
694
(car (comint-get-source " Load Clojure file: " inf-clojure-prev-l/c-dir/file
694
695
; ; nil because doesn't need an exact name
695
696
inf-clojure-source-modes nil )))))
696
697
(comint-check-source file-name) ; Check to see if buffer needs saved.
697
698
(setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
698
699
(file-name-nondirectory file-name)))
699
- (inf-clojure--send-string (inf-clojure-proc)
700
- (format (inf-clojure-load-form) file-name))
700
+ (inf-clojure--send-string proc (format (inf-clojure-load-form proc) file-name))
701
701
(when switch-to-repl
702
702
(inf-clojure-switch-to-repl t ))))
703
703
@@ -736,12 +736,12 @@ is present it will be used instead of the current file."
736
736
:safe #'stringp
737
737
:package-version '(inf-clojure . " 2.0.0" ))
738
738
739
- (defun inf-clojure-var-doc-form ()
740
- " Return the form to query inferior Clojure for a var's documentation.
739
+ (defun inf-clojure-var-doc-form (proc )
740
+ " Return the form to query the Inf- Clojure PROC for a var's documentation.
741
741
If you are using REPL types, it will pickup the most approapriate
742
742
`inf-clojure-var-doc-form` variant."
743
743
(inf-clojure--sanitize-command
744
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
744
+ (pcase (inf-clojure--set-repl-type proc)
745
745
(`lumo inf-clojure-var-doc-form-lumo)
746
746
(`planck inf-clojure-var-doc-form-planck)
747
747
(_ inf-clojure-var-doc-form))))
@@ -767,12 +767,12 @@ If you are using REPL types, it will pickup the most approapriate
767
767
:safe #'stringp
768
768
:package-version '(inf-clojure . " 2.0.0" ))
769
769
770
- (defun inf-clojure-var-source-form ()
771
- " Return the form to query inferior Clojure for a var's source.
770
+ (defun inf-clojure-var-source-form (proc )
771
+ " Return the form to query the Inf- Clojure PROC for a var's source.
772
772
If you are using REPL types, it will pickup the most approapriate
773
773
`inf-clojure-var-source-form` variant."
774
774
(inf-clojure--sanitize-command
775
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
775
+ (pcase (inf-clojure--set-repl-type proc)
776
776
(`lumo inf-clojure-var-source-form-lumo)
777
777
(`planck inf-clojure-var-source-form-planck)
778
778
(_ inf-clojure-var-source-form))))
@@ -810,12 +810,12 @@ If you are using REPL types, it will pickup the most approapriate
810
810
:safe #'stringp
811
811
:package-version '(inf-clojure . " 2.1.0" ))
812
812
813
- (defun inf-clojure-arglists-form ()
814
- " Return the form to query inferior Clojure for arglists of a var.
813
+ (defun inf-clojure-arglists-form (proc )
814
+ " Return the form to query the Inf- Clojure PROC for arglists of a var.
815
815
If you are using REPL types, it will pickup the most approapriate
816
816
`inf-clojure-arglists-form` variant."
817
817
(inf-clojure--sanitize-command
818
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
818
+ (pcase (inf-clojure--set-repl-type proc)
819
819
(`lumo inf-clojure-arglists-form-lumo)
820
820
(`planck inf-clojure-arglists-form-planck)
821
821
(_ inf-clojure-arglists-form))))
@@ -846,12 +846,12 @@ If you are using REPL types, it will pickup the most approapriate
846
846
:safe #'stringp
847
847
:package-version '(inf-clojure . " 2.0.0" ))
848
848
849
- (defun inf-clojure-completion-form ()
850
- " Return the form to query inferior Clojure for a var's documentation .
849
+ (defun inf-clojure-completion-form (proc )
850
+ " Return the form to query the Inf- Clojure PROC for completions .
851
851
If you are using REPL types, it will pickup the most approapriate
852
852
`inf-clojure-completion-form` variant."
853
853
(inf-clojure--sanitize-command
854
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
854
+ (pcase (inf-clojure--set-repl-type proc)
855
855
(`lumo inf-clojure-completion-form-lumo)
856
856
(`planck inf-clojure-completion-form-planck)
857
857
(_ inf-clojure-completion-form))))
@@ -877,12 +877,12 @@ If you are using REPL types, it will pickup the most approapriate
877
877
:safe #'stringp
878
878
:package-version '(inf-clojure . " 2.0.0" ))
879
879
880
- (defun inf-clojure-ns-vars-form ()
881
- " Return the form to query inferior Clojure for public vars in a namespace.
880
+ (defun inf-clojure-ns-vars-form (proc )
881
+ " Return the form to query the Inf- Clojure PROC for public vars in a namespace.
882
882
If you are using REPL types, it will pickup the most approapriate
883
883
`inf-clojure-ns-vars-form` variant."
884
884
(inf-clojure--sanitize-command
885
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
885
+ (pcase (inf-clojure--set-repl-type proc)
886
886
(`lumo inf-clojure-ns-vars-form-lumo)
887
887
(`planck inf-clojure-ns-vars-form-planck)
888
888
(_ inf-clojure-ns-vars-form))))
@@ -910,11 +910,11 @@ If you are using REPL types, it will pickup the most approapriate
910
910
:safe #'stringp
911
911
:package-version '(inf-clojure . " 2.0.0" ))
912
912
913
- (defun inf-clojure-set-ns-form ()
914
- " Return the form to set the ns of the inferior Clojure process .
913
+ (defun inf-clojure-set-ns-form (proc )
914
+ " Return the form to set the namespace of the Inf- Clojure PROC .
915
915
If you are using REPL types, it will pickup the most approapriate
916
916
`inf-clojure-set-ns-form` variant."
917
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
917
+ (pcase (inf-clojure--set-repl-type proc)
918
918
(`planck inf-clojure-set-ns-form-planck)
919
919
(`lumo inf-clojure-set-ns-form-lumo)
920
920
(_ inf-clojure-set-ns-form)))
@@ -944,12 +944,12 @@ If you are using REPL types, it will pickup the most approapriate
944
944
:safe #'stringp
945
945
:package-version '(inf-clojure . " 2.0.0" ))
946
946
947
- (defun inf-clojure-apropos-form ()
948
- " Return the form to query inferior Clojure for public vars in a namespace .
947
+ (defun inf-clojure-apropos-form (proc )
948
+ " Return the form to query the Inf- Clojure PROC for a var's apropos .
949
949
If you are using REPL types, it will pickup the most approapriate
950
- `inf-clojure-ns-vars -form` variant."
950
+ `inf-clojure-apropos -form` variant."
951
951
(inf-clojure--sanitize-command
952
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
952
+ (pcase (inf-clojure--set-repl-type proc)
953
953
(`lumo inf-clojure-apropos-form-lumo)
954
954
(`planck inf-clojure-apropos-form-planck)
955
955
(_ inf-clojure-apropos-form))))
@@ -970,12 +970,12 @@ If you are using REPL types, it will pickup the most approapriate
970
970
:safe #'stringp
971
971
:package-version '(inf-clojure . " 2.0.0" ))
972
972
973
- (defun inf-clojure-macroexpand-form ()
974
- " Return the form for macroexpansion in the inferior Clojure process .
973
+ (defun inf-clojure-macroexpand-form (proc )
974
+ " Return the form for macroexpansion in the Inf- Clojure PROC .
975
975
If you are using REPL types, it will pickup the most approapriate
976
976
`inf-clojure-macroexpand-form` variant."
977
977
(inf-clojure--sanitize-command
978
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
978
+ (pcase (inf-clojure--set-repl-type proc)
979
979
(`planck inf-clojure-macroexpand-form-planck)
980
980
(_ inf-clojure-macroexpand-form))))
981
981
@@ -995,12 +995,12 @@ If you are using REPL types, it will pickup the most approapriate
995
995
:safe #'stringp
996
996
:package-version '(inf-clojure . " 2.0.0" ))
997
997
998
- (defun inf-clojure-macroexpand-1-form ()
999
- " Return the form for macroexpand-1 in the inferior Clojure process .
998
+ (defun inf-clojure-macroexpand-1-form (proc )
999
+ " Return the form for macroexpand-1 in the Inf- Clojure PROC .
1000
1000
If you are using REPL types, it will pickup the most approapriate
1001
1001
`inf-clojure-macroexpand-1-form` variant."
1002
1002
(inf-clojure--sanitize-command
1003
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
1003
+ (pcase (inf-clojure--set-repl-type proc)
1004
1004
(`planck inf-clojure-macroexpand-1-form-planck)
1005
1005
(_ inf-clojure-macroexpand-1-form))))
1006
1006
@@ -1047,20 +1047,22 @@ The value is nil if it can't find one."
1047
1047
See function `inf-clojure-var-doc-form' . When invoked with a
1048
1048
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1049
1049
(interactive " P" )
1050
- (let ((var (if prompt-for-symbol
1051
- (car (inf-clojure-symprompt " Var doc" (inf-clojure-symbol-at-point)))
1052
- (inf-clojure-symbol-at-point))))
1053
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-var-doc-form) var))))
1050
+ (let ((proc (inf-clojure-proc))
1051
+ (var (if prompt-for-symbol
1052
+ (car (inf-clojure-symprompt " Var doc" (inf-clojure-symbol-at-point)))
1053
+ (inf-clojure-symbol-at-point))))
1054
+ (inf-clojure--send-string proc (format (inf-clojure-var-doc-form proc) var))))
1054
1055
1055
1056
(defun inf-clojure-show-var-source (prompt-for-symbol )
1056
1057
" Send a command to the inferior Clojure to give source for VAR.
1057
1058
See variable `inf-clojure-var-source-form' . When invoked with a
1058
1059
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1059
1060
(interactive " P" )
1060
- (let ((var (if prompt-for-symbol
1061
+ (let ((proc (inf-clojure-proc))
1062
+ (var (if prompt-for-symbol
1061
1063
(car (inf-clojure-symprompt " Var source" (inf-clojure-symbol-at-point)))
1062
1064
(inf-clojure-symbol-at-point))))
1063
- (inf-clojure--send-string (inf-clojure- proc) (format (inf-clojure-var-source-form) var))))
1065
+ (inf-clojure--send-string proc (format (inf-clojure-var-source-form proc ) var))))
1064
1066
1065
1067
; ;;; Response parsing
1066
1068
; ;;; ================
@@ -1190,10 +1192,11 @@ for evaluation, therefore FORM should not include it."
1190
1192
(defun inf-clojure-arglists (fn )
1191
1193
" Send a query to the inferior Clojure for the arglists for function FN.
1192
1194
See variable `inf-clojure-arglists-form' ."
1193
- (thread-first
1194
- (format (inf-clojure-arglists-form) fn)
1195
- (inf-clojure--process-response (inf-clojure-proc) " (" " )" )
1196
- (inf-clojure--some)))
1195
+ (when-let ((proc (inf-clojure-proc 'no-error )))
1196
+ (thread-first
1197
+ (format (inf-clojure-arglists-form proc) fn)
1198
+ (inf-clojure--process-response proc " (" " )" )
1199
+ (inf-clojure--some))))
1197
1200
1198
1201
(defun inf-clojure-show-arglists (prompt-for-symbol )
1199
1202
" Show the arglists for function FN in the mini-buffer.
@@ -1212,52 +1215,56 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1212
1215
See variable `inf-clojure-ns-vars-form' . When invoked with a
1213
1216
prefix argument PROMPT-FOR-NS, it prompts for a namespace name."
1214
1217
(interactive " P" )
1215
- (let ((ns (if prompt-for-ns
1216
- (car (inf-clojure-symprompt " Ns vars" (clojure-find-ns)))
1217
- (clojure-find-ns))))
1218
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-ns-vars-form) ns))))
1218
+ (let ((proc (inf-clojure-proc))
1219
+ (ns (if prompt-for-ns
1220
+ (car (inf-clojure-symprompt " Ns vars" (clojure-find-ns)))
1221
+ (clojure-find-ns))))
1222
+ (inf-clojure--send-string proc (format (inf-clojure-ns-vars-form proc) ns))))
1219
1223
1220
1224
(defun inf-clojure-set-ns (prompt-for-ns )
1221
1225
" Set the ns of the inferior Clojure process to NS.
1222
1226
See variable `inf-clojure-set-ns-form' . It defaults to the ns of
1223
1227
the current buffer. When invoked with a prefix argument
1224
1228
PROMPT-FOR-NS, it prompts for a namespace name."
1225
1229
(interactive " P" )
1226
- (let ((ns (if prompt-for-ns
1230
+ (let ((proc (inf-clojure-proc))
1231
+ (ns (if prompt-for-ns
1227
1232
(car (inf-clojure-symprompt " Set ns to" (clojure-find-ns)))
1228
1233
(clojure-find-ns))))
1229
1234
(when (or (not ns) (equal ns " " ))
1230
1235
(user-error " No namespace selected" ))
1231
- (inf-clojure--send-string (inf-clojure- proc) (format (inf-clojure-set-ns-form) ns))))
1236
+ (inf-clojure--send-string proc (format (inf-clojure-set-ns-form proc ) ns))))
1232
1237
1233
1238
(defun inf-clojure-apropos (expr )
1234
1239
" Send an expression to the inferior Clojure for apropos.
1235
1240
EXPR can be either a regular expression or a stringable
1236
1241
thing. See variable `inf-clojure-apropos-form' ."
1237
1242
(interactive (inf-clojure-symprompt " Var apropos" (inf-clojure-symbol-at-point)))
1238
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-apropos-form) expr)))
1243
+ (let ((proc (inf-clojure-proc)))
1244
+ (inf-clojure--send-string proc (format (inf-clojure-apropos-form proc) expr))))
1239
1245
1240
1246
(defun inf-clojure-macroexpand (&optional macro-1 )
1241
1247
" Send a form to the inferior Clojure for macro expansion.
1242
1248
See variable `inf-clojure-macroexpand-form' .
1243
1249
With a prefix arg MACRO-1 uses function `inf-clojure-macroexpand-1-form' ."
1244
1250
(interactive " P" )
1245
- (let ((last-sexp (buffer-substring-no-properties (save-excursion (backward-sexp ) (point )) (point ))))
1251
+ (let ((proc (inf-clojure-proc))
1252
+ (last-sexp (buffer-substring-no-properties (save-excursion (backward-sexp ) (point )) (point ))))
1246
1253
(inf-clojure--send-string
1247
- (inf-clojure- proc)
1254
+ proc
1248
1255
(format (if macro-1
1249
- (inf-clojure-macroexpand-1-form)
1250
- (inf-clojure-macroexpand-form))
1256
+ (inf-clojure-macroexpand-1-form proc )
1257
+ (inf-clojure-macroexpand-form proc ))
1251
1258
last-sexp))))
1252
1259
1253
-
1254
- (defun inf-clojure-proc ()
1260
+ (defun inf-clojure-proc (&optional no-error )
1255
1261
" Return the current inferior Clojure process.
1256
- See variable `inf-clojure-buffer' ."
1257
- (let ((proc (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
1258
- (current-buffer )
1259
- inf-clojure-buffer))))
1260
- (or proc
1262
+ When NO-ERROR is non-nil, don't throw an error when no connection
1263
+ has been found. See also variable `inf-clojure-buffer' ."
1264
+ (or (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
1265
+ (current-buffer )
1266
+ inf-clojure-buffer))
1267
+ (unless no-error
1261
1268
(error " No Clojure subprocess; see variable `inf-clojure-buffer' " ))))
1262
1269
1263
1270
(defun inf-clojure--list-or-nil (data )
@@ -1280,11 +1287,11 @@ every other EXPR will be discarded and nil will be returned."
1280
1287
Under the hood it calls the function
1281
1288
\\ [inf-clojure-completions-fn] passing in the result of
1282
1289
evaluating \\ [inf-clojure-completion-form] at the REPL."
1283
- (when ( not ( string-blank-p expr ))
1284
- (let (( proc (inf-clojure-proc ))
1285
- ( completion-form (format (inf-clojure-completion-form) (substring-no-properties expr))))
1286
- (funcall inf-clojure-completions-fn
1287
- (inf-clojure--process-response completion-form proc " (" " )" )))))
1290
+ (let ((proc (inf-clojure-proc 'no-error ) ))
1291
+ (when ( and proc (not ( string-blank-p expr) ))
1292
+ ( let (( completion-form (format (inf-clojure-completion-form proc ) (substring-no-properties expr))))
1293
+ (funcall inf-clojure-completions-fn
1294
+ (inf-clojure--process-response completion-form proc " (" " )" ) )))))
1288
1295
1289
1296
(defcustom inf-clojure-completions-fn 'inf-clojure-list-completions
1290
1297
" The function that parses completion results.
0 commit comments