federicotdn / verb

Organize and send HTTP requests from Emacs
https://melpa.org/#/verb
GNU General Public License v3.0
540 stars 20 forks source link

Question: bable source block postprocessing #52

Closed agzam closed 1 year ago

agzam commented 1 year ago

I would like to perform some post-processing of the data retrieved.

With the normal verb block (in a heading) I can use verb-post-response-hook. For example, this is how I automatically convert response from json to edn.

(defun verb-post-response-h ()
  "automatically transform json to edn"
  (with-current-buffer (current-buffer)
  (when (eq major-mode 'json-mode)
    (goto-char (point-min))
    (clojure-edn-json-transform)
    (clojure-mode)
    (verb-response-body-mode +1)
    (deactivate-mark))))

(add-hook 'verb-post-response-hook #'verb-post-response-h)

you can find the implementation of (clojure-edn-json-transform) over here

I would like to do something similar with results of verb source blocks. Is that possible?

agzam commented 1 year ago

Oh, wait. I got it all wrong. verb-post-response-hook it seems, works in both cases. That's so awesome.