Skip to content

Commit

Permalink
applying outstanding patches
Browse files Browse the repository at this point in the history
This fork has the following patches applied (still outstanding in bcbcarl/emacs-wttrin):
- patch for selecting the unit system: bcbcarl#10
- patch for url request to return ascii rather than html bcbcarl#18
- patch to use https instead of http: bcbcarl#15
  • Loading branch information
cjennings committed Aug 25, 2021
1 parent 121c59e commit 58104cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

Emacs frontend for weather web service [wttr.in].

This fork has the following patches applied (still outstanding in bcbcarl/emacs-wttrin):
- patch for selecting the unit system: https://github.com/bcbcarl/emacs-wttrin/pull/10
- patch for url request to return ascii rather than html https://github.com/bcbcarl/emacs-wttrin/pull/18
- patch to use https instead of http: https://github.com/bcbcarl/emacs-wttrin/pull/15

## Usage

Set a default cities list for completion:
Expand All @@ -20,7 +25,11 @@ You can also specify default HTTP request Header for Accept-Language:
```elisp
(setq wttrin-default-accept-language '("Accept-Language" . "zh-TW"))
```
As well as the unit system, "m" for metric and "u" for USCS/imperial (the default is to choose based on your location):

```elisp
(setq wttrin-unit-system "m")
```
Then run `M-x wttrin` to get the information.

When the weather is displayed you can press `q` to quit the buffer or `g` to query for another city.
Expand Down
15 changes: 14 additions & 1 deletion wttrin.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@
:type '(list)
)

(defcustom wttrin-unit-system nil
"Specify the units. use 'm' for 'metric', 'u' for 'USCS, or
nil for location based units (the default)"
:group 'wttrin
:type 'string
)

(defun wttrin-additional-url-params ()
"Concatenate any extra stuff into the URL here."
(concat "?" wttrin-unit-system)
)


(defun wttrin-fetch-raw-string (query)
"Get the weather information based on your QUERY."
(let ((url-user-agent "curl"))
(add-to-list 'url-request-extra-headers wttrin-default-accept-language)
(with-current-buffer
(url-retrieve-synchronously
(concat "https://wttr.in/" query "?A")
(concat "http://wttr.in/" query (wttrin-additional-url-params))
(lambda (status) (switch-to-buffer (current-buffer))))
(decode-coding-string (buffer-string) 'utf-8))))

Expand Down

0 comments on commit 58104cc

Please sign in to comment.