Function: bazel-insert-http-archive

bazel-insert-http-archive is an interactive and natively compiled function defined in bazel.el.

Signature

(bazel-insert-http-archive &optional STR ARG)

Documentation

Insert an “http_archive” statement at point.

See URL ‘https://bazel.build/rules/lib/repo/http#http_archive’ for a description of “http_archive”. Interactively, prompt for an archive URL. Attempt to detect repository name and prefix. Also add the date when the archive was likely last modified as a comment.

This is a skeleton command (see skeleton-insert). Normally the skeleton text is inserted at point, with nothing "inside". If there is a highlighted region, the skeleton text is wrapped around the region text.

A prefix argument ARG says to wrap the skeleton around the next ARG words. A prefix argument of -1 says to wrap around region, even if not highlighted. A prefix argument of zero says to wrap around zero words---that is, nothing. This is a way of overriding the use of a highlighted region.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(define-skeleton bazel-insert-http-archive
  "Insert an “http_archive” statement at point.
See URL ‘https://bazel.build/rules/lib/repo/http#http_archive’
for a description of “http_archive”.  Interactively, prompt for
an archive URL.  Attempt to detect repository name and prefix.
Also add the date when the archive was likely last modified as a
comment."
  "Archive download URL: "
  '(eval str t)                                 ; force prompt now
  '(setq v1 (bazel--download-http-archive str)) ; (name hash prefix time)
  "http_archive(" \n
  "name = \"" (or (nth 0 v1) '_) "\"," \n
  "integrity = \"" (nth 1 v1) "\"," \n
  (let ((prefix (nth 2 v1)))
    (unless (string-empty-p prefix)
      `(nil "strip_prefix = \"" ,prefix "\"," \n)))
  "urls = [" \n
  ?\" str "\",  # " (format-time-string "%F" (nth 3 v1) t) \n
  "]," > \n
  ?\) >)