はてブコメント表示 (xyttr Advent Calendar 18日目)
この記事はxyttr Advent Calendar 2011の記事です。
時間がなくなった為また小ネタ。
カーソル下のURLに付けられたはてなブックマークのコメントを表示します。
(in-package :xyttr) (defun show-hatebu-comments () (interactive) (whenlet url (expand-focused-url) (xhr:with-xhr-get-async ("http://b.hatena.ne.jp/entry/jsonlite/" :query `(:url ,url) :encoding *encoding-utf8n* :key #'xhr:xhr-response-values) (on :success (res status header) (w/popupbuf ((format nil "*comments on ~A*" url) t) (if (string= res "null") (format t "No bookmarks on ~A" url) (w/json (count bookmarks title) (json:json-decode res) (format t "~A - ~A user~%~A~%~%" title count url) (dolist (e bookmarks) (w/json (user tags comment) e (format t "~&~A: ~{[~A]~}~:[~% ~A~;~]" user tags (string= "" comment) comment)))))) (refresh-screen)) (on :failure (&rest a) (msgbox "[hatebu] error: ~S" a))))) (define-key *xyttr-timeline-keymap* #\B #'show-hatebu-comments)
w/popupbufマクロはconfig.lサンプルのフォルダ(~/site-lisp/xyttr/dot_xyttr_example)にあるwindow.lで定義されているので、~/.xyttrにコピーしてload-pluginする等してロードしておいてください。