dakrone / es-mode

An Emacs major mode for interacting with Elasticsearch
GNU General Public License v3.0
196 stars 34 forks source link

Add hook es-response-functions #8

Closed ahwatts closed 10 years ago

ahwatts commented 10 years ago

This adds the hook es-response-functions, which is run with the response body on 2xx requests.

dakrone commented 10 years ago

I thought that the standard was to name hooks based ending with -hook, so es-response-hook, is this correct?

Also, why is the es-response-functions "abnormal"? It seems that it would only be called when the result of a request is successful, what do you think about calling it es-successful-response-hook instead? (And maybe adding one for es-failed-response-hook)

dakrone commented 10 years ago

Ahh okay, I see your comment in the other thread about the standard for non-normal hooks to be -functions. That makes more sense then.

What do you think about making it es-successful-response-functions and es-failed-response-functions?

ahwatts commented 10 years ago

That's a good idea. Then I could write a separate function on that hook that turns ES's sometimes-esoteric error messages in to something more readable.

dakrone commented 10 years ago

Sounds good, I'm planning on writing something to transform ES responses into org-mode tables so I can graph numeric fields, hooks/functions would be a great way to do it.

dakrone commented 10 years ago

+1, this looks good to me. I'm going to merge and we can have a separate refactor PR for the 3-option header elision.

dakrone commented 10 years ago

Actually, I noticed an issue with cadadr not requiring cl. During merge I'll add (require 'cl-lib) and change it to (cl-cadadr ...)

dakrone commented 10 years ago

Thanks for this feature @ahwatts ! :)

ahwatts commented 10 years ago

Woot!