summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl X. Su <bcbcarl@gmail.com>2016-03-06 00:54:12 +0800
committerCarl X. Su <bcbcarl@gmail.com>2016-03-06 00:54:12 +0800
commit99ba22f0333e9ff72cf1803af49225a99273bca1 (patch)
tree79636c8ef4564c5a0a60629ffbf2c45716968bf0
Initial commit
-rw-r--r--LICENSE21
-rw-r--r--README.md25
-rw-r--r--wttrin.el47
-rw-r--r--wttrin.pngbin0 -> 113837 bytes
4 files changed, 93 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b9d0bb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Carl X. Su
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..65c0616
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# wttrin.el
+
+Emacs frontend for weather web service [wttr.in].
+
+wttrin.el provides the weather information from wttr.in based on your
+query condition.
+
+## Usage
+
+Set variable `wttrin-query`:
+
+```elisp
+(defvar wttrin-query "Taipei")
+```
+
+Run `M-x wttrin-exec` to get the information:
+
+![screenshot]
+
+## LICENSE
+
+MIT
+
+[wttr.in]: http://wttr.in/
+[screenshot]: wttrin.png \ No newline at end of file
diff --git a/wttrin.el b/wttrin.el
new file mode 100644
index 0000000..b2a3d97
--- /dev/null
+++ b/wttrin.el
@@ -0,0 +1,47 @@
+;;; wttrin.el --- Emacs frontend for weather web service wttr.in
+;; Copyright (C) 2016 Carl X. Su
+
+;; Author: Carl X. Su <bcbcarl@gmail.com>
+;; Version: 0.1.0
+;; Package-Requires: ((emacs "24.4") (xterm-color "20150823.646"))
+;; Keywords: comm, weather, wttrin
+;; URL: https://github.com/bcbcarl/emacs-wttrin
+
+;;; Commentary:
+
+;; Provides the weather information from wttr.in based on your query condition.
+
+;;; Code:
+
+(defgroup wttrin nil
+ "Emacs frontend for weather web service wttr.in."
+ :prefix "wttrin-"
+ :group 'comm)
+
+(defcustom wttrin-query "Taipei"
+ "Specify a query condition to get the weather information."
+ :group 'wttrin
+ :type 'string)
+
+(defun wttrin-fetch (query)
+ "Get the weather information based on your QUERY."
+ (let ((url-request-extra-headers '(("User-Agent" . "curl"))))
+ (with-current-buffer
+ (url-retrieve-synchronously
+ (concat "http://wttr.in/" query)
+ (lambda (status) (switch-to-buffer (current-buffer))))
+ (decode-coding-string (buffer-string) 'utf-8))))
+
+(require 'xterm-color)
+(defun wttrin-exec ()
+ "Display weather information."
+ (interactive)
+ (let* ((title) (name (generate-new-buffer-name (concat "wttr.in - " wttrin-query)))
+ (buf (get-buffer-create name)))
+ (switch-to-buffer buf))
+ (insert (xterm-color-filter (wttrin-fetch wttrin-query)))
+ (setq buffer-read-only t))
+
+(provide 'wttrin)
+
+;;; wttrin.el ends here
diff --git a/wttrin.png b/wttrin.png
new file mode 100644
index 0000000..027c858
--- /dev/null
+++ b/wttrin.png
Binary files differ