@@ -1210,7 +1210,7 @@ prefix argument PROMPT-FOR-NS, it prompts for a namespace name."
1210
1210
1211
1211
(defun inf-clojure-set-ns (prompt-for-ns )
1212
1212
" Set the ns of the inferior Clojure process to NS.
1213
- See variable `inf-clojure-set-ns-form` . It defaults to the ns of
1213
+ See variable `inf-clojure-set-ns-form' . It defaults to the ns of
1214
1214
the current buffer. When invoked with a prefix argument
1215
1215
PROMPT-FOR-NS, it prompts for a namespace name."
1216
1216
(interactive " P" )
@@ -1254,15 +1254,43 @@ See variable `inf-clojure-buffer'."
1254
1254
" Return DATA if and only if it is a list."
1255
1255
(when (listp data) data))
1256
1256
1257
- (defun inf-clojure-completions (expr )
1258
- " Return a list of completions for the Clojure expression starting with EXPR."
1257
+ (defun inf-clojure-list-completions (expr )
1258
+ " Return completions for the Clojure expression starting with EXPR.
1259
+
1260
+ Its only ability is to parse a list of candidate strings, every
1261
+ other EXPR will be discarded and nil will be returned."
1259
1262
(when (not (string-blank-p expr))
1260
1263
(thread-first
1261
1264
(format (inf-clojure-completion-form) (substring-no-properties expr))
1262
1265
(inf-clojure--process-response (inf-clojure-proc) " (" " )" )
1263
1266
(inf-clojure--read-or-nil)
1264
1267
(inf-clojure--list-or-nil))))
1265
1268
1269
+ (defcustom inf-clojure-completions 'inf-clojure-list-completions
1270
+ " The function that parses completion results.
1271
+
1272
+ It is a single-arity function that will receive the REPL
1273
+ evaluation result of \\ [inf-clojure-completion-form] as string and
1274
+ should return elisp data compatible with your completion mode.
1275
+
1276
+ The easiest possible data passed in input is a list of
1277
+ candidates (e.g.: (\" def\" \" defn\" )) but more complex libraries
1278
+ like `alexander-yakushev/compliment' can return other things like
1279
+ edn.
1280
+
1281
+ The expected return depends on the mode that you use for
1282
+ completion: `company-mode' for instance allows metadata along
1283
+ with the candidates completion. See \\ [completion-table-dynamic]
1284
+ for more details.
1285
+
1286
+ The default value is the `inf-clojure-list-completions' function,
1287
+ which is able to parse results in list form only. You can peek
1288
+ at its implementation for getting to know some utility functions
1289
+ you might want to use in your customization."
1290
+ :type 'function
1291
+ :safe #'functionp
1292
+ :package-version '(inf-clojure . " 2.1.0" ))
1293
+
1266
1294
(defconst inf-clojure-clojure-expr-break-chars " \t\n\"\' `><,;|&{()[]" )
1267
1295
1268
1296
(defun inf-clojure-completion-bounds-of-expr-at-point ()
@@ -1288,8 +1316,8 @@ Returns the selected completion or nil."
1288
1316
(when bounds
1289
1317
(list (car bounds) (cdr bounds)
1290
1318
(if (fboundp 'completion-table-with-cache )
1291
- (completion-table-with-cache # ' inf-clojure-completions )
1292
- (completion-table-dynamic # ' inf-clojure-completions ))))))
1319
+ (completion-table-with-cache inf-clojure-completions)
1320
+ (completion-table-dynamic inf-clojure-completions))))))
1293
1321
1294
1322
; ;;; ElDoc
1295
1323
; ;;; =====
0 commit comments