@@ -595,12 +595,12 @@ Prefix argument AND-GO means switch to the Clojure buffer afterwards."
595
595
(let ((str (replace-regexp-in-string
596
596
" [\n ]+\\ '" " "
597
597
(buffer-substring-no-properties start end))))
598
- (inf-clojure--send-string (inf-clojure-proc) str))
598
+ (inf-clojure--send-string (inf-clojure-- proc-or-error ) str))
599
599
(when and-go (inf-clojure-switch-to-repl t )))
600
600
601
601
(defun inf-clojure-eval-string (code )
602
602
" Send the string CODE to the inferior Clojure process to be executed."
603
- (inf-clojure--send-string (inf-clojure-proc) code))
603
+ (inf-clojure--send-string (inf-clojure-- proc-or-error ) code))
604
604
605
605
(defun inf-clojure-eval-defun (&optional and-go )
606
606
" Send the current defun to the inferior Clojure process.
@@ -691,7 +691,7 @@ The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the
691
691
(comint-check-source file-name) ; Check to see if buffer needs saved.
692
692
(setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
693
693
(file-name-nondirectory file-name)))
694
- (inf-clojure--send-string (inf-clojure-proc)
694
+ (inf-clojure--send-string (inf-clojure-- proc-or-error )
695
695
(format (inf-clojure-load-form) file-name))
696
696
(when switch-to-repl
697
697
(inf-clojure-switch-to-repl t ))))
@@ -995,7 +995,7 @@ If you are using REPL types, it will pickup the most approapriate
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 (inf-clojure-- proc-or-error ))
999
999
(`planck inf-clojure-macroexpand-1-form-planck)
1000
1000
(_ inf-clojure-macroexpand-1-form))))
1001
1001
@@ -1042,7 +1042,7 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1042
1042
(let ((var (if prompt-for-symbol
1043
1043
(car (inf-clojure-symprompt " Var doc" (inf-clojure-symbol-at-point)))
1044
1044
(inf-clojure-symbol-at-point))))
1045
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-var-doc-form) var))))
1045
+ (inf-clojure--send-string (inf-clojure-- proc-or-error ) (format (inf-clojure-var-doc-form) var))))
1046
1046
1047
1047
(defun inf-clojure-show-var-source (prompt-for-symbol )
1048
1048
" Send a command to the inferior Clojure to give source for VAR.
@@ -1052,7 +1052,7 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
1052
1052
(let ((var (if prompt-for-symbol
1053
1053
(car (inf-clojure-symprompt " Var source" (inf-clojure-symbol-at-point)))
1054
1054
(inf-clojure-symbol-at-point))))
1055
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-var-source-form) var))))
1055
+ (inf-clojure--send-string (inf-clojure-- proc-or-error ) (format (inf-clojure-var-source-form) var))))
1056
1056
1057
1057
; ;;; Response parsing
1058
1058
; ;;; ================
@@ -1182,10 +1182,11 @@ for evaluation, therefore FORM should not include it."
1182
1182
(defun inf-clojure-arglists (fn )
1183
1183
" Send a query to the inferior Clojure for the arglists for function FN.
1184
1184
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)))
1185
+ (when-let ((proc (inf-clojure-proc)))
1186
+ (thread-first
1187
+ (format (inf-clojure-arglists-form) fn)
1188
+ (inf-clojure--process-response proc " (" " )" )
1189
+ (inf-clojure--some))))
1189
1190
1190
1191
(defun inf-clojure-show-arglists (prompt-for-symbol )
1191
1192
" Show the arglists for function FN in the mini-buffer.
@@ -1207,7 +1208,7 @@ prefix argument PROMPT-FOR-NS, it prompts for a namespace name."
1207
1208
(let ((ns (if prompt-for-ns
1208
1209
(car (inf-clojure-symprompt " Ns vars" (clojure-find-ns)))
1209
1210
(clojure-find-ns))))
1210
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-ns-vars-form) ns))))
1211
+ (inf-clojure--send-string (inf-clojure-proc--or-error ) (format (inf-clojure-ns-vars-form) ns))))
1211
1212
1212
1213
(defun inf-clojure-set-ns (prompt-for-ns )
1213
1214
" Set the ns of the inferior Clojure process to NS.
@@ -1220,13 +1221,13 @@ PROMPT-FOR-NS, it prompts for a namespace name."
1220
1221
(clojure-find-ns))))
1221
1222
(when (or (not ns) (equal ns " " ))
1222
1223
(user-error " No namespace selected" ))
1223
- (inf-clojure--send-string (inf-clojure-proc) (format (inf-clojure-set-ns-form) ns))))
1224
+ (inf-clojure--send-string (inf-clojure-proc--or-error ) (format (inf-clojure-set-ns-form) ns))))
1224
1225
1225
1226
(defun inf-clojure-apropos (var )
1226
1227
" Send a form to the inferior Clojure to give apropos for VAR.
1227
1228
See variable `inf-clojure-apropos-form' ."
1228
1229
(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)))
1230
+ (inf-clojure--send-string (inf-clojure-- proc-or-error ) (format (inf-clojure-apropos-form) var)))
1230
1231
1231
1232
(defun inf-clojure-macroexpand (&optional macro-1 )
1232
1233
" Send a form to the inferior Clojure to give apropos for VAR.
@@ -1235,21 +1236,23 @@ With a prefix arg MACRO-1 uses `inf-clojure-macroexpand-1-form'."
1235
1236
(interactive " P" )
1236
1237
(let ((last-sexp (buffer-substring-no-properties (save-excursion (backward-sexp ) (point )) (point ))))
1237
1238
(inf-clojure--send-string
1238
- (inf-clojure-proc)
1239
+ (inf-clojure-- proc-or-error )
1239
1240
(format (if macro-1
1240
1241
(inf-clojure-macroexpand-1-form)
1241
1242
(inf-clojure-macroexpand-form))
1242
1243
last-sexp))))
1243
1244
1244
-
1245
1245
(defun inf-clojure-proc ()
1246
1246
" Return the current inferior Clojure process.
1247
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
- (error " No Clojure subprocess; see variable `inf-clojure-buffer' " ))))
1248
+ (get-buffer-process (if (derived-mode-p 'inf-clojure-mode )
1249
+ (current-buffer )
1250
+ inf-clojure-buffer)))
1251
+
1252
+ (defun inf-clojure--proc-or-error ()
1253
+ " Return the current inferior Clojure process.
1254
+ See variable `inf-clojure-buffer' ."
1255
+ (or (inf-clojure-proc) (error " No Clojure subprocess; see variable `inf-clojure-buffer' " )))
1253
1256
1254
1257
(defun inf-clojure--list-or-nil (data )
1255
1258
" Return DATA if and only if it is a list."
@@ -1271,11 +1274,11 @@ every other EXPR will be discarded and nil will be returned."
1271
1274
Under the hood it calls the function
1272
1275
\\ [inf-clojure-completions-fn] passing in the result of
1273
1276
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 " (" " )" )))))
1277
+ (let ((proc (inf-clojure-proc) ))
1278
+ (when ( and proc (not ( string-blank-p expr) ))
1279
+ ( let ( (completion-form (format (inf-clojure-completion-form) (substring-no-properties expr))))
1280
+ (funcall inf-clojure-completions-fn
1281
+ (inf-clojure--process-response completion-form proc " (" " )" ) )))))
1279
1282
1280
1283
(defcustom inf-clojure-completions-fn 'inf-clojure-list-completions
1281
1284
" The function that parses completion results.
0 commit comments