Function: verb--setup-temp-request-buffer

verb--setup-temp-request-buffer is a natively compiled function defined in verb.el.

Signature

(verb--setup-temp-request-buffer RS SOURCE-WINDOW VERB-VARIABLES WHERE)

Documentation

Setup and show a temporary buffer for editing a request spec.

Argument RS indicates the request specification to edit. SOURCE-WINDOW indicates which window should be selected when the request is sent. VERB-VARIABLES should contain the Verb user-defined variables set in the buffer displayed by SOURCE-WINDOW. WHERE describes where the response should be shown in (see verb-send-request-on-point for a complete description).

After the user has finished modifying the buffer, they can press C-c C-c (org-ctrl-c-ctrl-c) to send the request.

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(defun verb--setup-temp-request-buffer (rs source-window verb-variables where)
  "Setup and show a temporary buffer for editing a request spec.
Argument RS indicates the request specification to edit.
SOURCE-WINDOW indicates which window should be selected when the
request is sent.  VERB-VARIABLES should contain the Verb user-defined
variables set in the buffer displayed by SOURCE-WINDOW.  WHERE
describes where the response should be shown in (see
`verb-send-request-on-point' for a complete description).

After the user has finished modifying the buffer, they can press
\\<org-mode-map>\\[org-ctrl-c-ctrl-c] to send the request."
  (switch-to-buffer-other-window (get-buffer-create "*Edit HTTP Request*"))
  ;; "Reset" the buffer in case it wasn't killed correctly.
  (erase-buffer)
  (verb--ensure-org-mode)
  (verb--ensure-verb-mode)

  ;; Don't require tagging for this temp buffer.
  (set (make-local-variable 'verb-tag) t)

  ;; Copy over Verb variables.
  (setq verb--vars verb-variables)

  ;; Insert the request spec.
  (insert "* Press 'C-c C-c' to send the request.\n")

  (when-let ((metadata (oref rs metadata)))
    (insert ":properties:\n")
    (dolist (element metadata)
      (insert (format ":%s: %s\n" (car element) (cdr element))))
    (insert ":end:\n"))

  (insert "# You can also press 'C-c C-k' to cancel.\n"
          "# Note that any changes made here won't be saved.\n"
          (verb-request-spec-to-string rs))

  ;; Use a copy of Org mode's keymap as the local keymap, so
  ;; that we can rebind C-c C-c freely.
  (use-local-map (copy-keymap org-mode-map))

  ;; Unbind keys for verb-send-request-on-point-* commands.
  (dolist (cmd '(verb-send-request-on-point
                 verb-send-request-on-point-other-window
                 verb-send-request-on-point-display
                 verb-send-request-on-point-no-window))
    (when-let ((key (where-is-internal cmd nil t)))
      (local-unset-key key)))

  ;; Rebind C-c C-c to send the request.
  ;; This will override `org-ctrl-c-ctrl-c-hook'.
  (local-set-key (kbd "C-c C-c")
                 (lambda ()
                   "Send the request specified in the current buffer."
                   (interactive)
                   (verb--send-temp-request-on-point source-window
                                                     where)))
  (local-set-key (kbd "C-c C-k") #'verb-kill-buffer-and-window))