Created
November 11, 2011 11:06
-
-
Save buzztaiki/1357754 to your computer and use it in GitHub Desktop.
emacs+python夢のコラボ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ex. M-x atnd-list-events google | |
(require 'pymacs) | |
(defun pymacs-send (pyobj method &rest args) | |
(apply (pymacs-call "getattr" pyobj method) args)) | |
(pymacs-load "urllib" "pyurllib-") | |
(defun atnd-json (keyword) | |
(let ((url (format "http://api.atnd.org/events/?keyword=%s&format=json" keyword))) | |
(json-read-from-string | |
(mapconcat 'identity (pymacs-send (pyurllib-urlopen url) "readlines") "\n")))) | |
(defun atnd-events (json) | |
(cdr (assq 'events json))) | |
(defun atnd-list-events (keyword) | |
(interactive "skeyword: ") | |
(with-current-buffer (get-buffer-create "*atnd*") | |
(erase-buffer) | |
(loop for event across (atnd-events (atnd-json "google")) | |
do (insert (cdr (assq 'title event)) "\n" | |
" " (cdr (assq 'url event)) "\n")) | |
(goto-char (point-min)) | |
(display-buffer (current-buffer)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment