summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl X. Su <bcbcarl@gmail.com>2016-04-14 23:37:17 +0800
committerCarl X. Su <bcbcarl@gmail.com>2016-04-14 23:37:17 +0800
commit760110f7dedaf29e7848609f4f36b80442d6c994 (patch)
treea1b509ee4e61897e341319c063136743e719ef92
parentffa0fb67e913845ae4c1b639495c944fa321aff6 (diff)
parent00e21fcd204d6817fa4f1076673bc45b96a640ec (diff)
Merge pull request #6 from pashky/master
Added local keymap
-rw-r--r--README.md2
-rw-r--r--wttrin.el7
2 files changed, 9 insertions, 0 deletions
diff --git a/README.md b/README.md
index 762cd26..ca18128 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,8 @@ Set a default cities list for completion:
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.
+
![screenshot]
## LICENSE
diff --git a/wttrin.el b/wttrin.el
index b44554d..a8d9b85 100644
--- a/wttrin.el
+++ b/wttrin.el
@@ -36,6 +36,10 @@
(lambda (status) (switch-to-buffer (current-buffer))))
(decode-coding-string (buffer-string) 'utf-8))))
+(defun wttrin-exit ()
+ (interactive)
+ (quit-window t))
+
(defun wttrin-query (city-name)
"Query weather of CITY-NAME via wttrin, and display the result in new buffer."
(let ((raw-string (wttrin-fetch-raw-string city-name)))
@@ -49,6 +53,9 @@
(goto-char (point-min))
(re-search-forward "^$")
(delete-region (point-min) (1+ (point)))
+ (use-local-map (make-sparse-keymap))
+ (local-set-key "q" 'wttrin-exit)
+ (local-set-key "g" 'wttrin)
(setq buffer-read-only t)))))
;;;###autoload