Skip to content

Commit 2304a4a

Browse files
committed
Update Capf performance
1 parent b05eaa5 commit 2304a4a

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

ejc-capf.el

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,28 @@
2626
collection)))
2727

2828
(defun ejc-capf-get-annotation (cand)
29-
(let* ((on-point (ejc-get-prefix-word))
30-
(my-data (list (list "ansi sql" (ejc-get-ansi-sql-words))
31-
(list "keyword" (ejc-get-keywords))
32-
(list "owner" (ejc-owners-candidates))
33-
(list "table" (ejc-tables-candidates))
34-
(list "view" (ejc-views-candidates))
35-
(when on-point
36-
(list "column" (ejc-colomns-candidates)))))
37-
;; Find which lists contain the candidate
38-
(matches (ejc-find-lists-containing cand my-data)))
39-
(when matches
40-
(format " [%s]" (mapconcat #'identity matches ", ")))))
29+
(format " [%s]" (get-text-property 0 'meta-category cand)))
4130

4231
(defun ejc-capf ()
4332
"SQL completion-at-point function."
4433
(let ((bds (bounds-of-thing-at-point 'symbol))
4534
(on-point (ejc-get-prefix-word)))
4635
(when bds
4736
(list (car bds) (cdr bds)
48-
(append (ejc-get-ansi-sql-words)
49-
(ejc-get-keywords)
50-
(ejc-owners-candidates)
51-
(ejc-tables-candidates)
52-
(ejc-views-candidates)
37+
(append (mapcar (lambda (w) (propertize w 'meta-category "ansi sql"))
38+
(ejc-get-ansi-sql-words))
39+
(mapcar (lambda (w) (propertize w 'meta-category "keyword"))
40+
(seq-difference (ejc-get-keywords)
41+
(ejc-get-ansi-sql-words)))
42+
(mapcar (lambda (w) (propertize w 'meta-category "owner"))
43+
(ejc-owners-candidates))
44+
(mapcar (lambda (w) (propertize w 'meta-category "table"))
45+
(ejc-tables-candidates))
46+
(mapcar (lambda (w) (propertize w 'meta-category "view"))
47+
(ejc-views-candidates))
5348
(when on-point
54-
(ejc-colomns-candidates)))
49+
(mapcar (lambda (w) (propertize w 'meta-category "column"))
50+
(ejc-colomns-candidates))))
5551
:exclusive 'yes
5652
:annotation-function #'ejc-capf-get-annotation))))
5753

0 commit comments

Comments
 (0)