@@ -1318,19 +1318,38 @@ you might want to use in your customization."
13181318 :safe #'functionp
13191319 :package-version '(inf-clojure . " 2.1.0" ))
13201320
1321- (defconst inf-clojure-clojure-expr-break-chars " \t\n\"\' `><,;|&{()[]@\\ ^" )
1321+ (defconst inf-clojure-clojure-expr-break-chars " ^[] \" '`><,;|&{()[@\\ ^]"
1322+ " Regexp are hard.
1323+
1324+ This regex has been built in order to match the first of the
1325+ listed chars. There are a couple of quirks to consider:
1326+
1327+ - the ] is always a special in elisp regex so you have to put it
1328+ directly AFTER [ if you want to match it as literal.
1329+ - The ^ needs to be escaped with \\ ^.
1330+
1331+ Tests and `re-builder' are your friends." )
1332+
1333+ (defun inf-clojure--kw-to-symbol (kw )
1334+ " Convert the keyword KW to a symbol.
1335+
1336+ This guy was taken from CIDER, thanks folks."
1337+ (when kw
1338+ (replace-regexp-in-string " \\ `:+" " " kw)))
13221339
13231340(defun inf-clojure-completion-bounds-of-expr-at-point ()
13241341 " Return bounds of expression at point to complete."
13251342 (when (not (memq (char-syntax (following-char )) '(?w ?_ )))
13261343 (save-excursion
1327- (let ((end (point )))
1328- (skip-chars-backward (concat " ^" inf-clojure-clojure-expr-break-chars))
1329- (let ((chars (thing-at-point 'symbol )))
1330- (when (> (length chars) 0 )
1331- (let ((first-char (substring-no-properties chars 0 1 )))
1332- (when (string-match-p " [^0-9]" first-char)
1333- (cons (point ) end)))))))))
1344+ (let* ((end (point ))
1345+ (skipped-back (skip-chars-backward inf-clojure-clojure-expr-break-chars))
1346+ (start (+ end skipped-back))
1347+ (chars (or (thing-at-point 'symbol )
1348+ (inf-clojure--kw-to-symbol (buffer-substring start end)))))
1349+ (when (> (length chars) 0 )
1350+ (let ((first-char (substring-no-properties chars 0 1 )))
1351+ (when (string-match-p " [^0-9]" first-char)
1352+ (cons (point ) end))))))))
13341353
13351354(defun inf-clojure-completion-expr-at-point ()
13361355 " Return expression at point to complete."
0 commit comments