Skip to content

Instantly share code, notes, and snippets.

@buzztaiki
Created November 11, 2011 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buzztaiki/1357754 to your computer and use it in GitHub Desktop.
Save buzztaiki/1357754 to your computer and use it in GitHub Desktop.
emacs+python夢のコラボ
;; 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