Function: combobulate-query-builder-completion-at-point-function
combobulate-query-builder-completion-at-point-function is a natively
compiled function defined in combobulate-query.el.
Signature
(combobulate-query-builder-completion-at-point-function)
Documentation
Completion function for combobulate-query-mode.
This function is used by completion-at-point-functions to provide
completion candidates for the current point.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-query.el
(defun combobulate-query-builder-completion-at-point-function ()
"Completion function for `combobulate-query-mode'.
This function is used by `completion-at-point-functions' to provide
completion candidates for the current point."
(cl-flet* ((get-symbol () (thing-at-point 'symbol t))
(go-up () (ignore-errors (backward-up-list 1)))
(go-down () (ignore-errors (down-list)))
(at-char-p (s) (looking-back s 1))
(skip-syntax (direction &optional syntax)
(if (eq direction 'forward)
(skip-syntax-forward (or syntax "w_"))
(skip-syntax-backward (or syntax "w_")))))
(save-excursion
(let* ((start) (end (point))
;; Note this moves point as a side-effect of each check. The
;; order is therefore important.
(has-prefix-text (prog1
(> (skip-syntax-backward "w_") 0)
(setq start (point))))
;; Are we at the start of a form?
(at-form-start (at-char-p "("))
;; Are we at the start of a match group?
(at-match-group-start (at-char-p "@"))
;; Move to the end of the current text.
(has-postfix-text (prog1
(> (skip-syntax-forward "w_") 0)
(setq end (point))))
;; Are we now at the end of a form?
(at-form-end (at-char-p ")"))
;; Use `syntax-ppss' to tell us if we're inside a
;; string or not.
(inside-string (nth 3 (syntax-ppss)))
(parent-rule-name (save-excursion
;; Move up out of the current form.
;; (parent (chi|ld)) -> (parent |(child))
(go-up)
;; Move up out of of the parent form
;; (parent (child)) -> |(parent (child))
(go-up)
;; go back down again to get at the parent
;; (parent (child)) -> (|parent (child))
(go-down)
(get-symbol)))
(parent-field-name (save-excursion
(go-up)
(skip-syntax 'backward " ")
(when (string-suffix-p ":" (get-symbol))
(string-trim (or (get-symbol) "") nil ":"))))
;; (at-field-name (save-excursion
;; (and (get-symbol) (string-suffix-p (or (get-symbol) "") ":"))))
(current-rule-name (save-excursion
(go-up)
(go-down)
(get-symbol))))
(list start end
(cond
;; it's a string - do nothing.
(inside-string nil)
;; it's a match group
(at-match-group-start (map-keys combobulate-query-match-face-alist))
;; it's a rule name
((or has-prefix-text at-form-start has-postfix-text at-form-end)
(append (if-let (rule (assoc parent-rule-name combobulate-query-builder-rules))
(flatten-list
(cons (if parent-field-name
(or (plist-get (cadr rule) (intern (concat ":" parent-field-name)))
combobulate-query-builder-rule-names)
(map-values (cadr rule)))
nil))
combobulate-query-builder-rule-names)
(copy-tree combobulate-query-builder-predicate-names)))
;; it's a field name
((and (not at-form-start) (not at-form-end))
(when-let (rule (assoc current-rule-name combobulate-query-builder-rules))
(mapcar #'combobulate-query-builder-prop-name-to-field-name
(seq-remove (lambda (prop) (equal prop :*unnamed*))
(map-keys (cadr rule))))))
(t nil)))))))