Function: bazel-current-target-name
bazel-current-target-name is a natively compiled function defined in
bazel.el.
Signature
(bazel-current-target-name)
Documentation
Return the name of the Bazel rule target defined at point.
Return nil if not inside a Bazel rule target definition.
Aliases
bazel-mode-current-rule-name (obsolete since 2026-04-16)
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel-current-target-name ()
"Return the name of the Bazel rule target defined at point.
Return nil if not inside a Bazel rule target definition."
(declare (ftype (function () (or string null))))
(let ((case-fold-search nil)
(search-spaces-regexp nil)
(bound (save-excursion (python-nav-end-of-statement) (point))))
(save-excursion
(python-nav-beginning-of-statement)
(cl-block nil
(while (re-search-forward
;; The target pattern isn’t the same as
;; https://bazel.build/concepts/labels#target-names (we don’t
;; allow quotation marks in target names), but should be good
;; enough here.
(rx symbol-start "name" (* blank) ?= (* blank)
(group (any ?\" ?'))
(group (+ (any "a-z" "A-Z" "0-9"
?- "!%@^_` #$&()*+,;<=>?[]{|}~/.")))
(backref 1))
bound t)
(let ((name (match-string-no-properties 2)))
(unless (python-syntax-comment-or-string-p)
(cl-return name))))))))