diff --git a/README.md b/README.md index f67b6bd..8e1e3e5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ You can also specify default HTTP request Header for Accept-Language: (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. diff --git a/wttrin.el b/wttrin.el index 512b6a7..3a34ea0 100644 --- a/wttrin.el +++ b/wttrin.el @@ -33,13 +33,25 @@ :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-request-extra-headers '(("User-Agent" . "curl")))) (add-to-list 'url-request-extra-headers wttrin-default-accept-language) (with-current-buffer (url-retrieve-synchronously - (concat "http://wttr.in/" query) + (concat "http://wttr.in/" query (wttrin-additional-url-params)) (lambda (status) (switch-to-buffer (current-buffer)))) (decode-coding-string (buffer-string) 'utf-8))))