Open torgeir opened 8 years ago
It feels like this functionality really belongs to ob-restclient and should be implemented through some sort of header flag like :noheaders. So you'd better ask @alf :)
There's C-c C-r command in actual restclient major mode that will leave headers on top as they are in response, but it won't help you.
Feel free to open an issue. It's a good feature request and I agree with pashky that it belongs in ob-restclient.
@alf wow, that was quick :) in fact, i looked at my code around so called "prettifying" and felt shame. it must be changed to make it work for ob-restclient. i'll try to cobble together something and perhaps send a pr to you, if i have some spare time this week.
For others wanting this behavior, here is a snippet from my config that does just this, but only when the status code is 200:
(add-hook 'restclient-response-loaded-hook
(defun jordon-restclient-delete-headers-when-ok ()
(when (equal major-mode 'js-mode)
(save-excursion
(goto-char (point-max))
(when (and (search-backward "200 OK" nil t)
(search-backward "}" nil t))
(forward-char 1)
(delete-region (point) (point-max))
(json-mode))))))
Nice.
Is there a way to perform requests resulting in json responses without including request/response info in comments in the results buffer?
That is, a way to not show responses like this:
But rather like this:
Specifically I'm in emacs org mode with babel and ob-restclient, wanting to parse the resulting json for further use within other code blocks.