[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure 94f440e 192/313: Extract keyword words for com
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure 94f440e 192/313: Extract keyword words for completion |
Date: |
Wed, 11 Aug 2021 10:00:14 -0400 (EDT) |
branch: elpa/inf-clojure
commit 94f440e141c4dbe1293d90c2297c9d9239ff56bd
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Extract keyword words for completion
The patch copies functionality from cider so that now inf-clojure can detect
and extract keywords (colons included) when a symbol at point is not found.
---
inf-clojure.el | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/inf-clojure.el b/inf-clojure.el
index 127ff9c..382f223 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -1344,19 +1344,38 @@ you might want to use in your customization."
:safe #'functionp
:package-version '(inf-clojure . "2.1.0"))
-(defconst inf-clojure-clojure-expr-break-chars " \t\n\"\'`><,;|&{()[]@\\^")
+(defconst inf-clojure-clojure-expr-break-chars "^[] \"'`><,;|&{()[@\\^]"
+ "Regexp are hard.
+
+This regex has been built in order to match the first of the
+listed chars. There are a couple of quirks to consider:
+
+- the ] is always a special in elisp regex so you have to put it
+ directly AFTER [ if you want to match it as literal.
+- The ^ needs to be escaped with \\^.
+
+Tests and `re-builder' are your friends.")
+
+(defun inf-clojure--kw-to-symbol (kw)
+ "Convert the keyword KW to a symbol.
+
+This guy was taken from CIDER, thanks folks."
+ (when kw
+ (replace-regexp-in-string "\\`:+" "" kw)))
(defun inf-clojure-completion-bounds-of-expr-at-point ()
"Return bounds of expression at point to complete."
(when (not (memq (char-syntax (following-char)) '(?w ?_)))
(save-excursion
- (let ((end (point)))
- (skip-chars-backward (concat "^" inf-clojure-clojure-expr-break-chars))
- (let ((chars (thing-at-point 'symbol)))
- (when (> (length chars) 0)
- (let ((first-char (substring-no-properties chars 0 1)))
- (when (string-match-p "[^0-9]" first-char)
- (cons (point) end)))))))))
+ (let* ((end (point))
+ (skipped-back (skip-chars-backward
inf-clojure-clojure-expr-break-chars))
+ (start (+ end skipped-back))
+ (chars (or (thing-at-point 'symbol)
+ (inf-clojure--kw-to-symbol (buffer-substring start
end)))))
+ (when (> (length chars) 0)
+ (let ((first-char (substring-no-properties chars 0 1)))
+ (when (string-match-p "[^0-9]" first-char)
+ (cons (point) end))))))))
(defun inf-clojure-completion-expr-at-point ()
"Return expression at point to complete."
- [nongnu] elpa/inf-clojure 1e93db8 237/313: Bump the development version, (continued)
- [nongnu] elpa/inf-clojure 1e93db8 237/313: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c590c65 240/313: Remove projects from inf-clojure except to serve as project root, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 8fb1929 254/313: Set REPL type from startup form, prompt, or defcustom at startup, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure f298612 259/313: [Fix #173] Use clojure-mode project detection (#176), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 380528f 078/313: Bump the clojure-mode dependency, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 24463b4 105/313: [Fix #26] Make switching to the REPL optional on, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b357856 112/313: Rename defcustoms to `inf-clojure-*-form` where appropriate, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 64162aa 138/313: Fix a formatting issue in the README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 9d2d143 144/313: Make sure tabs would never sneak in, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c08d8bb 165/313: Split the only when-let for backward compatibility, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 94f440e 192/313: Extract keyword words for completion,
ELPA Syncer <=
- [nongnu] elpa/inf-clojure da88c8c 205/313: Require seq library. Fixes https://github.com/clojure-emacs/inf-clojure/issues/141, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure feca1cc 201/313: Send string even when empty, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 3d72305 208/313: README: Add section describing how to start and connect to a socket server., ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 0fc2350 225/313: Fix for eldoc-mode for ClojureCLR, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure a61dd84 232/313: Insert top level defun into repl, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure bcd806a 251/313: Unify references to the term REPL, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure a7f07a0 245/313: Set artificial to true on comint-send-input, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure e291da3 274/313: Update README.md, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 787400f 264/313: [Fix #178] Ensure there is a directory for comint (thanks mcphailm), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 6cb8e43 277/313: Update the CI images, ELPA Syncer, 2021/08/11