Closed andrelaszlo closed 6 years ago
Thanks for reporting this, I'll take a look!
After doing some research on this and playing around, I think maybe switching to request might be the easiest solution here. I'll play around with it (shouldn't be too hard to switch)
Looks like a really nice lib, what are you using now?
what are you using now?
Right now I used Emacs' built-in url.el to execute the request
@andrelaszlo I pushed a branch (switch-to-request
) that switches to using request.el and also fixes this unicode issue for .es
files. I need to switch ob-elasticsearch.el (org babel) to use it as it still has the unicode issue, but when I do then I'll push a new version.
Feel free to check it out and make sure it works for you!
@dakrone hello, I thought I'd post here instead of creating a new issue!
After the switch to request.el, requests containing unicode payload work fine. However, the response is not displayed correctly. I've tried to look into it a bit. It turns out that request.el specifies (set-process-coding-system proc 'binary 'binary)
before issuing the request to curl (see here). If you remove this line, the output gets parsed correctly. However I think we might want the coding system of the request to actually be set to 'binary
.
It turns out that we can handle this inside es-mode.el. I gave it a shot as a proof of concept and it seems to work. However my elisp skills are mediocre at best and that's why I'm not actually opening a PR.
The relevant change is in function es--execute-string
. Similarly to the :data
handler, we can change the :complete
handler to:
(cl-function
(lambda (&key data response error-thrown &allow-other-keys)
(with-current-buffer results-buffer
(let ((utf-data (decode-coding-string data 'utf-8)))
(es-result--handle-response utf-data response error-thrown)))))
and the response gets parsed correctly!
Let me know if I can do anything more to help - including opening a PR. Oh, and thanks for your great work on this plugin!
Hi @greenonion, definitely opening a PR would be great!
Great, will do!
When I submit the following query, that works in Sense:
I get this error:
I'm using GNU Emacs 25.1.1, ES