As discussed in !59, this PR adds the ability for users to define a VERB-MAP-RESPONSE (respecting verb--metadata-prefix) property to apply a function to the response object.
It also adds:
The function verb--fn-form that takes care of returning a function object from a form, or signaling errors if it couldn't parse it as a function object (previously this was done in verb--request-spec-post-process, but now we need the same behaviour in two different places). It also checks for if the arglist for the parsed function object expects exactly one argument. This could be tweaked in the future, but for now since this function is internal to the library and we're only using it to map requests and responses I guess it makes sens to keep this check.
The variable verb--response-original-buffer (I'm accpeting naming suggestions) to store the buffer from where the request was made. It's a permanent local variable. It could either be the current-buffer when the request was made with Org babel and the response goes into the same buffer, or the response buffer generated by verb--generate-response-buffer.
I'm using it to allow users to call verb-set-var (and change other buffer local values) in the VERB-MAP-RESPONSE callback and have the variables set to the right buffer, without having to resort to getting the buffer from other window like in my personal solution, since users might tweak their display-buffer-alist among other things.
As discussed in !59, this PR adds the ability for users to define a
VERB-MAP-RESPONSE
(respectingverb--metadata-prefix
) property to apply a function to the response object.It also adds:
The function
verb--fn-form
that takes care of returning a function object from a form, or signaling errors if it couldn't parse it as a function object (previously this was done inverb--request-spec-post-process
, but now we need the same behaviour in two different places). It also checks for if the arglist for the parsed function object expects exactly one argument. This could be tweaked in the future, but for now since this function is internal to the library and we're only using it to map requests and responses I guess it makes sens to keep this check.The variable
verb--response-original-buffer
(I'm accpeting naming suggestions) to store the buffer from where the request was made. It's a permanent local variable. It could either be thecurrent-buffer
when the request was made with Org babel and the response goes into the same buffer, or the response buffer generated byverb--generate-response-buffer
.I'm using it to allow users to call
verb-set-var
(and change other buffer local values) in theVERB-MAP-RESPONSE
callback and have the variables set to the right buffer, without having to resort to getting the buffer from other window like in my personal solution, since users might tweak theirdisplay-buffer-alist
among other things.