Function: verb-restclient--parse

verb-restclient--parse is a natively compiled function defined in verb-restclient.el.

Signature

(verb-restclient--parse BUF)

Documentation

Parse restclient.el requests from BUF.

Return a list of verb-restclient--request structures.

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb-restclient.el
(defun verb-restclient--parse (buf)
  "Parse restclient.el requests from BUF.
Return a list of `verb-restclient--request' structures."
  (with-current-buffer buf
    (save-excursion
      (goto-char (point-min))
      (when (re-search-forward "#.+mode:\\s-*restclient" (line-end-position) t)
        (end-of-line)
        (forward-char))

      (let (requests comments-start comments-end comments body done)
        (catch 'end
          (while t
            (setq comments-start (point)
                  done nil)
            ;; Go over comments
            (while (re-search-forward "^#.*$" (line-end-position) t)
              (end-of-line)
              (if (eobp) (throw 'end nil) (forward-char)))
            (setq comments-end (point))
            ;; Go over the actual request
            (while (and (not done)
                        (re-search-forward "^\\(?:[^#].*\\)?$"
                                           (line-end-position) t))
              (end-of-line)
              (if (or (eobp)
                        (string-empty-p (string-trim
                                         (buffer-substring (point)
                                                           (point-max)))))
                  (setq done t)
                (forward-char)))

            (setq comments (buffer-substring comments-start comments-end)
                  body (buffer-substring comments-end (point)))

            (push (verb-restclient--build-request comments body) requests)
            (when done (throw 'end nil))))
        (nreverse requests)))))