emacs-wttrin
emacs-wttrin copied to clipboard
Raw html instad of wttrin
I setup wttrin as follows:
(use-package wttrin
:init
(setq wttrin-default-cities '("Heidelberg" "Tel-Aviv")
wttrin-default-accept-language '("Accept-Language" . "en-US")))
I am using GNU Emacs 26.3
When I run wttrin and pick the city, I get a raw html file instead of a rendered page https://pastebin.com/aTcvQvj3
I am sure I am missing something essential here. Thanks in advance!
soloved url-request-extra-headers '(("User-Agent" . "curl")))) cannot override url-user-agent , change to the following code
(defun wttrin-fetch-raw-string (query)
"Get the weather information based on your QUERY."
(let ((url-user-agent "curl"))
This does not fix it for me.
@SodaLover https://github.com/bcbcarl/emacs-wttrin/pull/17/commits/ed569277e0cfa5e5c1534a5ea2b404dec2ef0183
(defun wttrin-fetch-raw-string (query)
"Get the weather information based on your QUERY."
(let ((url-request-extra-headers '(("User-Agent" . "curl"))))
change to
(defun wttrin-fetch-raw-string (query)
"Get the weather information based on your QUERY."
(let ((url-user-agent "curl"))
then byte-compile the .el file
This worked for me. Step by step clarification, in case someone else like me finds this:
- Go to the directory where your packages are kept (mine are under ~/.emacs.d/elpa/wttrin*
- Edit the wttrin.el as emacle wrote above, replacing the line (let ((url-request-extra-headers...) with the (let ((url-user agent...) statement.
- move or delete the file that ends in .elc
- If you're using use-package for your config, just relaunch emacs. There are probably other ways, but was the easiest for me. It will recreate the .elc file that you moved/deleted using the newly modified .el file.
Thank you for the fix emacle!
I was experiencing the html display problem as well (GNU Emacs 26.3) but the above suggestions did not fix the problem. However, making the above changes and adding a flag to the wttrin url call specifying text format did the trick for me. Here are the changes to wttrin.el that worked for me.
Change:
(defun wttrin-fetch-raw-string (query) "Get the weather information based on your QUERY." (let ((url-request-extra-headers '(("User-Agent" . "curl"))))
To:
(defun wttrin-fetch-raw-string (query) "Get the weather information based on your QUERY." (let ((url-user-agent "curl"))
Change:
(concat "http://wttr.in/" query)
To:
(concat "http://wttr.in/" query "?A")
I too have GNU emacs 26.3. It is on Mac OS 10.15.
I followed @brannala's recommendation and it worked!
Try this one, it worked for me.
;; fix wttrin buffer render issue (advice-remove 'wttrin-query 'render-wttrin-buffer) (defun render-wttrin-buffer (ignore-args) "Render the wtrrin buffer." (read-only-mode -1) (shr-render-region (point-min) (point-max)) (delete-trailing-whitespace) (read-only-mode t)) (advice-add 'wttrin-query :after 'render-wttrin-buffer)
@beacoder I tried your advice but for some reason there were no colours shown. Then I used brannala's guide and it worked with colours.
@beacoder I tried your advice but for some reason there were no colours shown. Then I used brannala's guide and it worked with colours.
I basicaly used emacs in terminal mode, so failed to see the color. anyway, good to hear that other guy's solution worked.
Using emacs 27.1 on Mac @brannala's recommendation worked. THANKS!
I've created a pull request with @brannala 's change: https://github.com/bcbcarl/emacs-wttrin/pull/20
Hopefully one day it can be merged :) and in the meanwhile feel free to use that branch.
I setup wttrin as follows:
(use-package wttrin :init (setq wttrin-default-cities '("Heidelberg" "Tel-Aviv") wttrin-default-accept-language '("Accept-Language" . "en-US")))
I am using GNU Emacs 26.3 ... I am sure I am missing something essential here. Thanks in advance!
Try to customize a bit:
M-x
, customize-variable
, url-user-agent
write there: curl
Press the button Apply and Save
Or add '(url-user-agent "curl")
to your customization file.
Or try to modify your code like this:
(use-package wttrin
:custom
(wttrin-default-cities '("Heidelberg" "Tel-Aviv"))
(wttrin-default-accept-language '("Accept-Language" . "en-US")
(url-user-agent "curl")))