@@ -1344,19 +1344,38 @@ you might want to use in your customization."
1344
1344
:safe #'functionp
1345
1345
:package-version '(inf-clojure . " 2.1.0" ))
1346
1346
1347
- (defconst inf-clojure-clojure-expr-break-chars " \t\n\"\' `><,;|&{()[]@\\ ^" )
1347
+ (defconst inf-clojure-clojure-expr-break-chars " ^[] \" '`><,;|&{()[@\\ ^]"
1348
+ " Regexp are hard.
1349
+
1350
+ This regex has been built in order to match the first of the
1351
+ listed chars. There are a couple of quirks to consider:
1352
+
1353
+ - the ] is always a special in elisp regex so you have to put it
1354
+ directly AFTER [ if you want to match it as literal.
1355
+ - The ^ needs to be escaped with \\ ^.
1356
+
1357
+ Tests and `re-builder' are your friends." )
1358
+
1359
+ (defun inf-clojure--kw-to-symbol (kw )
1360
+ " Convert the keyword KW to a symbol.
1361
+
1362
+ This guy was taken from CIDER, thanks folks."
1363
+ (when kw
1364
+ (replace-regexp-in-string " \\ `:+" " " kw)))
1348
1365
1349
1366
(defun inf-clojure-completion-bounds-of-expr-at-point ()
1350
1367
" Return bounds of expression at point to complete."
1351
1368
(when (not (memq (char-syntax (following-char )) '(?w ?_ )))
1352
1369
(save-excursion
1353
- (let ((end (point )))
1354
- (skip-chars-backward (concat " ^" inf-clojure-clojure-expr-break-chars))
1355
- (let ((chars (thing-at-point 'symbol )))
1356
- (when (> (length chars) 0 )
1357
- (let ((first-char (substring-no-properties chars 0 1 )))
1358
- (when (string-match-p " [^0-9]" first-char)
1359
- (cons (point ) end)))))))))
1370
+ (let* ((end (point ))
1371
+ (skipped-back (skip-chars-backward inf-clojure-clojure-expr-break-chars))
1372
+ (start (+ end skipped-back))
1373
+ (chars (or (thing-at-point 'symbol )
1374
+ (inf-clojure--kw-to-symbol (buffer-substring start end)))))
1375
+ (when (> (length chars) 0 )
1376
+ (let ((first-char (substring-no-properties chars 0 1 )))
1377
+ (when (string-match-p " [^0-9]" first-char)
1378
+ (cons (point ) end))))))))
1360
1379
1361
1380
(defun inf-clojure-completion-expr-at-point ()
1362
1381
" Return expression at point to complete."
0 commit comments