Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomoya/1160308 to your computer and use it in GitHub Desktop.
Save tomoya/1160308 to your computer and use it in GitHub Desktop.
popup-hatena-profile-image.el
;; popup-hatena-profile-image.el
;; カーソル位置のはてなユーザーのプロフィール画像をポップアップで表示します.
;; idコールする前に,idが合ってるか確認するのに使えます.
(require 'cl)
(require 'url)
(require 'deferred)
(require 'popwin)
(defun popup-hatena-profile-image ()
(interactive)
(lexical-let ((current-word (thing-at-point 'word)))
(when current-word
(deferred:$
(deferred:url-retrieve (format "http://www.st-hatena.com/users/%s/profile.gif" current-word))
(deferred:nextc it
(lambda (buf)
(let ((image-buf (get-buffer-create "*image*")))
(progn
(with-current-buffer image-buf
(view-mode -1)
(erase-buffer)
(insert-string (concat current-word "\n"))
(insert-image
(create-image
(let ((data (with-current-buffer buf (buffer-string))))
(substring data (+ (string-match "\n\n" data) 2)))
'gif t))
(view-mode 1))
(popwin:popup-buffer image-buf)
(kill-buffer buf)))))))))
(provide 'popup-hatena-profile-image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment