@@ -361,11 +361,11 @@ Clojure to load that file."
361
361
:safe #'stringp
362
362
:package-version '(inf-clojure . " 2.0.0" ))
363
363
364
- (defun inf-clojure-load-form ()
365
- " Return the form to query inferior Clojure for a var's documentation.
364
+ (defun inf-clojure-load-form (proc )
365
+ " Return the form to query the Inf- Clojure PROC for var's documentation.
366
366
If you are using REPL types, it will pickup the most appropriate
367
367
`inf-clojure-var-doc-form` variant."
368
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
368
+ (pcase (inf-clojure--set-repl-type proc)
369
369
(`lumo inf-clojure-load-form-lumo)
370
370
(`planck inf-clojure-load-form-planck)
371
371
(_ inf-clojure-load-form)))
@@ -684,15 +684,15 @@ Used by this command to determine defaults."
684
684
685
685
The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the file is loaded or not."
686
686
(interactive " P" )
687
- (let ((file-name (or file-name
687
+ (let ((proc (inf-clojure-proc))
688
+ (file-name (or file-name
688
689
(car (comint-get-source " Load Clojure file: " inf-clojure-prev-l/c-dir/file
689
690
; ; nil because doesn't need an exact name
690
691
inf-clojure-source-modes nil )))))
691
692
(comint-check-source file-name) ; Check to see if buffer needs saved.
692
693
(setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
693
694
(file-name-nondirectory file-name)))
694
- (inf-clojure--send-string (inf-clojure-proc)
695
- (format (inf-clojure-load-form) file-name))
695
+ (inf-clojure--send-string proc (format (inf-clojure-load-form proc) file-name))
696
696
(when switch-to-repl
697
697
(inf-clojure-switch-to-repl t ))))
698
698
@@ -731,12 +731,12 @@ The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the
731
731
:safe #'stringp
732
732
:package-version '(inf-clojure . " 2.0.0" ))
733
733
734
- (defun inf-clojure-var-doc-form ()
735
- " Return the form to query inferior Clojure for a var's documentation.
734
+ (defun inf-clojure-var-doc-form (proc )
735
+ " Return the form to query the Inf- Clojure PROC for a var's documentation.
736
736
If you are using REPL types, it will pickup the most approapriate
737
737
`inf-clojure-var-doc-form` variant."
738
738
(inf-clojure--sanitize-command
739
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
739
+ (pcase (inf-clojure--set-repl-type proc)
740
740
(`lumo inf-clojure-var-doc-form-lumo)
741
741
(`planck inf-clojure-var-doc-form-planck)
742
742
(_ inf-clojure-var-doc-form))))
@@ -762,12 +762,12 @@ If you are using REPL types, it will pickup the most approapriate
762
762
:safe #'stringp
763
763
:package-version '(inf-clojure . " 2.0.0" ))
764
764
765
- (defun inf-clojure-var-source-form ()
766
- " Return the form to query inferior Clojure for a var's source.
765
+ (defun inf-clojure-var-source-form (proc )
766
+ " Return the form to query the Inf- Clojure PROC for a var's source.
767
767
If you are using REPL types, it will pickup the most approapriate
768
768
`inf-clojure-var-source-form` variant."
769
769
(inf-clojure--sanitize-command
770
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
770
+ (pcase (inf-clojure--set-repl-type proc)
771
771
(`lumo inf-clojure-var-source-form-lumo)
772
772
(`planck inf-clojure-var-source-form-planck)
773
773
(_ inf-clojure-var-source-form))))
@@ -805,12 +805,12 @@ If you are using REPL types, it will pickup the most approapriate
805
805
:safe #'stringp
806
806
:package-version '(inf-clojure . " 2.1.0" ))
807
807
808
- (defun inf-clojure-arglists-form ()
809
- " Return the form to query inferior Clojure for arglists of a var.
808
+ (defun inf-clojure-arglists-form (proc )
809
+ " Return the form to query the Inf- Clojure PROC for arglists of a var.
810
810
If you are using REPL types, it will pickup the most approapriate
811
811
`inf-clojure-arglists-form` variant."
812
812
(inf-clojure--sanitize-command
813
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
813
+ (pcase (inf-clojure--set-repl-type proc)
814
814
(`lumo inf-clojure-arglists-form-lumo)
815
815
(`planck inf-clojure-arglists-form-planck)
816
816
(_ inf-clojure-arglists-form))))
@@ -841,12 +841,12 @@ If you are using REPL types, it will pickup the most approapriate
841
841
:safe #'stringp
842
842
:package-version '(inf-clojure . " 2.0.0" ))
843
843
844
- (defun inf-clojure-completion-form ()
845
- " Return the form to query inferior Clojure for a var's documentation .
844
+ (defun inf-clojure-completion-form (proc )
845
+ " Return the form to query the Inf- Clojure PROC for completions .
846
846
If you are using REPL types, it will pickup the most approapriate
847
847
`inf-clojure-completion-form` variant."
848
848
(inf-clojure--sanitize-command
849
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
849
+ (pcase (inf-clojure--set-repl-type proc)
850
850
(`lumo inf-clojure-completion-form-lumo)
851
851
(`planck inf-clojure-completion-form-planck)
852
852
(_ inf-clojure-completion-form))))
@@ -872,12 +872,12 @@ If you are using REPL types, it will pickup the most approapriate
872
872
:safe #'stringp
873
873
:package-version '(inf-clojure . " 2.0.0" ))
874
874
875
- (defun inf-clojure-ns-vars-form ()
876
- " Return the form to query inferior Clojure for public vars in a namespace.
875
+ (defun inf-clojure-ns-vars-form (proc )
876
+ " Return the form to query the Inf- Clojure PROC for public vars in a namespace.
877
877
If you are using REPL types, it will pickup the most approapriate
878
878
`inf-clojure-ns-vars-form` variant."
879
879
(inf-clojure--sanitize-command
880
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
880
+ (pcase (inf-clojure--set-repl-type proc)
881
881
(`lumo inf-clojure-ns-vars-form-lumo)
882
882
(`planck inf-clojure-ns-vars-form-planck)
883
883
(_ inf-clojure-ns-vars-form))))
@@ -905,11 +905,11 @@ If you are using REPL types, it will pickup the most approapriate
905
905
:safe #'stringp
906
906
:package-version '(inf-clojure . " 2.0.0" ))
907
907
908
- (defun inf-clojure-set-ns-form ()
909
- " Return the form to set the ns of the inferior Clojure process .
908
+ (defun inf-clojure-set-ns-form (proc )
909
+ " Return the form to set the namespace of the Inf- Clojure PROC .
910
910
If you are using REPL types, it will pickup the most approapriate
911
911
`inf-clojure-set-ns-form` variant."
912
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
912
+ (pcase (inf-clojure--set-repl-type proc)
913
913
(`planck inf-clojure-set-ns-form-planck)
914
914
(`lumo inf-clojure-set-ns-form-lumo)
915
915
(_ inf-clojure-set-ns-form)))
@@ -939,12 +939,12 @@ If you are using REPL types, it will pickup the most approapriate
939
939
:safe #'stringp
940
940
:package-version '(inf-clojure . " 2.0.0" ))
941
941
942
- (defun inf-clojure-apropos-form ()
943
- " Return the form to query inferior Clojure for public vars in a namespace .
942
+ (defun inf-clojure-apropos-form (proc )
943
+ " Return the form to query the Inf- Clojure PROC for a var's apropos .
944
944
If you are using REPL types, it will pickup the most approapriate
945
- `inf-clojure-ns-vars -form` variant."
945
+ `inf-clojure-apropos -form` variant."
946
946
(inf-clojure--sanitize-command
947
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
947
+ (pcase (inf-clojure--set-repl-type proc)
948
948
(`lumo inf-clojure-apropos-form-lumo)
949
949
(`planck inf-clojure-apropos-form-planck)
950
950
(_ inf-clojure-apropos-form))))
@@ -965,12 +965,12 @@ If you are using REPL types, it will pickup the most approapriate
965
965
:safe #'stringp
966
966
:package-version '(inf-clojure . " 2.0.0" ))
967
967
968
- (defun inf-clojure-macroexpand-form ()
969
- " Return the form for macroexpansion in the inferior Clojure process .
968
+ (defun inf-clojure-macroexpand-form (proc )
969
+ " Return the form for macroexpansion in the Inf- Clojure PROC .
970
970
If you are using REPL types, it will pickup the most approapriate
971
971
`inf-clojure-macroexpand-form` variant."
972
972
(inf-clojure--sanitize-command
973
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
973
+ (pcase (inf-clojure--set-repl-type proc)
974
974
(`planck inf-clojure-macroexpand-form-planck)
975
975
(_ inf-clojure-macroexpand-form))))
976
976
@@ -990,12 +990,12 @@ If you are using REPL types, it will pickup the most approapriate
990
990
:safe #'stringp
991
991
:package-version '(inf-clojure . " 2.0.0" ))
992
992
993
- (defun inf-clojure-macroexpand-1-form ()
994
- " Return the form for macroexpand-1 in the inferior Clojure process .
993
+ (defun inf-clojure-macroexpand-1-form (proc )
994
+ " Return the form for macroexpand-1 in the Inf- Clojure PROC .
995
995
If you are using REPL types, it will pickup the most approapriate
996
996
`inf-clojure-macroexpand-1-form` variant."
997
997
(inf-clojure--sanitize-command
998
- (pcase (inf-clojure--set-repl-type (inf-clojure- proc) )
998
+ (pcase (inf-clojure--set-repl-type proc)
999
999
(`planck inf-clojure-macroexpand-1-form-planck)
1000
1000
(_ inf-clojure-macroexpand-1-form))))
1001
1001
@@ -1039,20 +1039,22 @@ The value is nil if it can't find one."
1039
1039
See function `inf-clojure-var-doc-form' . When invoked with a
1040
1040
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1041
1041
(interactive " P" )
1042
- (let ((var (if prompt-for-symbol
1043
- (car (inf-clojure-symprompt " Var doc" (inf-clojure-symbol-at-point)))
1044
- (inf-clojure-symbol-at-point))))
1045
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-var-doc-form) var))))
1042
+ (let ((proc (inf-clojure-proc))
1043
+ (var (if prompt-for-symbol
1044
+ (car (inf-clojure-symprompt " Var doc" (inf-clojure-symbol-at-point)))
1045
+ (inf-clojure-symbol-at-point))))
1046
+ (inf-clojure--send-string proc (format (inf-clojure-var-doc-form proc) var))))
1046
1047
1047
1048
(defun inf-clojure-show-var-source (prompt-for-symbol )
1048
1049
" Send a command to the inferior Clojure to give source for VAR.
1049
1050
See variable `inf-clojure-var-source-form' . When invoked with a
1050
1051
prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1051
1052
(interactive " P" )
1052
- (let ((var (if prompt-for-symbol
1053
+ (let ((proc (inf-clojure-proc))
1054
+ (var (if prompt-for-symbol
1053
1055
(car (inf-clojure-symprompt " Var source" (inf-clojure-symbol-at-point)))
1054
1056
(inf-clojure-symbol-at-point))))
1055
- (inf-clojure--send-string (inf-clojure- proc) (format (inf-clojure-var-source-form) var))))
1057
+ (inf-clojure--send-string proc (format (inf-clojure-var-source-form proc ) var))))
1056
1058
1057
1059
; ;;; Response parsing
1058
1060
; ;;; ================
@@ -1182,10 +1184,11 @@ for evaluation, therefore FORM should not include it."
1182
1184
(defun inf-clojure-arglists (fn )
1183
1185
" Send a query to the inferior Clojure for the arglists for function FN.
1184
1186
See variable `inf-clojure-arglists-form' ."
1185
- (thread-first
1186
- (format (inf-clojure-arglists-form) fn)
1187
- (inf-clojure--process-response (inf-clojure-proc) " (" " )" )
1188
- (inf-clojure--some)))
1187
+ (when-let ((proc (inf-clojure-proc 'no-error )))
1188
+ (thread-first
1189
+ (format (inf-clojure-arglists-form proc) fn)
1190
+ (inf-clojure--process-response proc " (" " )" )
1191
+ (inf-clojure--some))))
1189
1192
1190
1193
(defun inf-clojure-show-arglists (prompt-for-symbol )
1191
1194
" Show the arglists for function FN in the mini-buffer.
@@ -1204,51 +1207,54 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1204
1207
See variable `inf-clojure-ns-vars-form' . When invoked with a
1205
1208
prefix argument PROMPT-FOR-NS, it prompts for a namespace name."
1206
1209
(interactive " P" )
1207
- (let ((ns (if prompt-for-ns
1208
- (car (inf-clojure-symprompt " Ns vars" (clojure-find-ns)))
1209
- (clojure-find-ns))))
1210
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-ns-vars-form) ns))))
1210
+ (let ((proc (inf-clojure-proc))
1211
+ (ns (if prompt-for-ns
1212
+ (car (inf-clojure-symprompt " Ns vars" (clojure-find-ns)))
1213
+ (clojure-find-ns))))
1214
+ (inf-clojure--send-string proc (format (inf-clojure-ns-vars-form proc) ns))))
1211
1215
1212
1216
(defun inf-clojure-set-ns (prompt-for-ns )
1213
1217
" Set the ns of the inferior Clojure process to NS.
1214
1218
See variable `inf-clojure-set-ns-form' . It defaults to the ns of
1215
1219
the current buffer. When invoked with a prefix argument
1216
1220
PROMPT-FOR-NS, it prompts for a namespace name."
1217
1221
(interactive " P" )
1218
- (let ((ns (if prompt-for-ns
1222
+ (let ((proc (inf-clojure-proc))
1223
+ (ns (if prompt-for-ns
1219
1224
(car (inf-clojure-symprompt " Set ns to" (clojure-find-ns)))
1220
1225
(clojure-find-ns))))
1221
1226
(when (or (not ns) (equal ns " " ))
1222
1227
(user-error " No namespace selected" ))
1223
- (inf-clojure--send-string (inf-clojure- proc) (format (inf-clojure-set-ns-form) ns))))
1228
+ (inf-clojure--send-string proc (format (inf-clojure-set-ns-form proc ) ns))))
1224
1229
1225
1230
(defun inf-clojure-apropos (var )
1226
1231
" Send a form to the inferior Clojure to give apropos for VAR.
1227
1232
See variable `inf-clojure-apropos-form' ."
1228
1233
(interactive (inf-clojure-symprompt " Var apropos" (inf-clojure-symbol-at-point)))
1229
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-apropos-form) var)))
1234
+ (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-apropos-form proc ) var)))
1230
1235
1231
1236
(defun inf-clojure-macroexpand (&optional macro-1 )
1232
1237
" Send a form to the inferior Clojure to give apropos for VAR.
1233
1238
See variable `inf-clojure-macroexpand-form' .
1234
1239
With a prefix arg MACRO-1 uses `inf-clojure-macroexpand-1-form' ."
1235
1240
(interactive " P" )
1236
- (let ((last-sexp (buffer-substring-no-properties (save-excursion (backward-sexp ) (point )) (point ))))
1241
+ (let ((proc (inf-clojure-proc))
1242
+ (last-sexp (buffer-substring-no-properties (save-excursion (backward-sexp ) (point )) (point ))))
1237
1243
(inf-clojure--send-string
1238
- (inf-clojure- proc)
1244
+ proc
1239
1245
(format (if macro-1
1240
- (inf-clojure-macroexpand-1-form)
1241
- (inf-clojure-macroexpand-form))
1246
+ (inf-clojure-macroexpand-1-form proc )
1247
+ (inf-clojure-macroexpand-form proc ))
1242
1248
last-sexp))))
1243
1249
1244
-
1245
- (defun inf-clojure-proc ()
1250
+ (defun inf-clojure-proc (&optional no-error )
1246
1251
" Return the current inferior Clojure process.
1247
- See variable `inf-clojure-buffer' ."
1248
- (let ((proc (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
1249
- (current-buffer )
1250
- inf-clojure-buffer))))
1251
- (or proc
1252
+ When NO-ERROR is non-nil, don't throw an error when no connection
1253
+ has been found. See also variable `inf-clojure-buffer' ."
1254
+ (or (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
1255
+ (current-buffer )
1256
+ inf-clojure-buffer))
1257
+ (unless no-error
1252
1258
(error " No Clojure subprocess; see variable `inf-clojure-buffer' " ))))
1253
1259
1254
1260
(defun inf-clojure--list-or-nil (data )
@@ -1271,11 +1277,11 @@ every other EXPR will be discarded and nil will be returned."
1271
1277
Under the hood it calls the function
1272
1278
\\ [inf-clojure-completions-fn] passing in the result of
1273
1279
evaluating \\ [inf-clojure-completion-form] at the REPL."
1274
- (when ( not ( string-blank-p expr ))
1275
- (let (( proc (inf-clojure-proc ))
1276
- ( completion-form (format (inf-clojure-completion-form) (substring-no-properties expr))))
1277
- (funcall inf-clojure-completions-fn
1278
- (inf-clojure--process-response completion-form proc " (" " )" )))))
1280
+ (let ((proc (inf-clojure-proc 'no-error ) ))
1281
+ (when ( and proc (not ( string-blank-p expr) ))
1282
+ ( let (( completion-form (format (inf-clojure-completion-form proc ) (substring-no-properties expr))))
1283
+ (funcall inf-clojure-completions-fn
1284
+ (inf-clojure--process-response completion-form proc " (" " )" ) )))))
1279
1285
1280
1286
(defcustom inf-clojure-completions-fn 'inf-clojure-list-completions
1281
1287
" The function that parses completion results.
0 commit comments