Function: bazel--target-package-completion-table-1
bazel--target-package-completion-table-1 is a natively compiled
function defined in bazel.el.
Signature
(bazel--target-package-completion-table-1 DIRECTORY)
Documentation
Return a completion table for Bazel packages found in DIRECTORY.
This is a helper function for
‘bazel--target-package-completion-table’.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--target-package-completion-table-1 (directory)
"Return a completion table for Bazel packages found in DIRECTORY.
This is a helper function for
‘bazel--target-package-completion-table’."
(declare (ftype (function (string) t)))
(cl-check-type directory string)
(lambda (string predicate action)
(cl-check-type string string)
(cl-check-type predicate (or null function))
(let ((completion-regexp-list
;; Restrict completions to valid package names.
(cons (rx bos (+ (any "A-Z" "a-z" "0-9" ?_ ?- ?.)) eos)
completion-regexp-list)))
(bazel--make-conjunction predicate candidate
(bazel--target-completion-directory-p candidate))
(ignore-error file-error
;; ‘file-name-completion’ and ‘file-name-all-completions’ always
;; return directories as directory names. Since a directory name
;; isn’t a valid package name, and we don’t want to give the user the
;; impression that they can’t enter a colon, strip the trailing slash.
(pcase action
('nil
(when-let* ((res (file-name-completion string directory predicate)))
(bazel--remove-slash res)))
('t
(cl-loop for cand in (file-name-all-completions string directory)
when (funcall predicate cand)
collect (bazel--remove-slash cand)))
('lambda
;; We complete target patterns, not packages! In particular, a
;; valid target pattern can’t end in a slash.
(and (not (string-empty-p string))
(not (directory-name-p string))
(file-accessible-directory-p
(expand-file-name string directory))
(funcall predicate directory)))
(`(boundaries . ,suffix)
`(boundaries 0 . ,(string-match-p (rx (any ?/ ?:)) suffix))))))))