Function: bazel--add-visibility
bazel--add-visibility is a natively compiled function defined in
bazel.el.
Signature
(bazel--add-visibility ROOT SOURCE DESTINATION BEGIN END ASK)
Documentation
Make SOURCE visible to DESTINATION.
SOURCE and DESTINATION should be absolute Bazel labels. ROOT identifies the root directory of the current repository. The current buffer should contain Bazel compilation outputs. If ASK is non-nil, prompt the user first using ‘y-or-n-p’, and temporarily highlight the region between BEGIN and END in the current buffer. Use Buildozer (the ‘bazel-buildozer-command’) to change the visibility of the affected BUILD file.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--add-visibility (root source destination begin end ask)
"Make SOURCE visible to DESTINATION.
SOURCE and DESTINATION should be absolute Bazel labels. ROOT
identifies the root directory of the current repository. The
current buffer should contain Bazel compilation outputs. If ASK
is non-nil, prompt the user first using ‘y-or-n-p’, and
temporarily highlight the region between BEGIN and END in the
current buffer. Use Buildozer (the ‘bazel-buildozer-command’) to
change the visibility of the affected BUILD file."
(declare (ftype (function (string string string integer integer t) null)))
(cl-check-type root string)
(cl-check-type source string)
(cl-check-type destination string)
(cl-check-type begin natnum)
(cl-check-type end natnum)
(pcase (bazel--parse-label source)
(`(,src-repository ,(and (pred stringp) src-package) ,_)
(pcase (bazel--parse-label destination)
(`(,(and (or 'nil "") dest-repository)
,(and (pred stringp) dest-package) ,_)
(let ((value (bazel--canonical src-repository src-package "__pkg__")))
(when (or (not ask)
(progn
(pulse-momentary-highlight-region begin end)
(y-or-n-p (format-message "Make %s visible to %s? "
value destination))))
;; We need to save the BUILD file first so that Buildozer doesn’t
;; stomp over unsaved changes.
(bazel--save-build-file root dest-repository dest-package)
(let ((output (get-buffer-create "*Buildozer*"))
(command `(,@bazel-buildozer-command
"--" ,(concat "add visibility " value)
,destination)))
(if (eq 0 (apply #'process-file
(car command) nil output nil (cdr command)))
(message "Made %s visible to %s" value destination)
(temp-buffer-window-show output)))))))))
nil)