Skip to content

Instantly share code, notes, and snippets.

@naota
Created October 12, 2011 14:15
Show Gist options
  • Save naota/1281331 to your computer and use it in GitHub Desktop.
Save naota/1281331 to your computer and use it in GitHub Desktop.
(defvar twinstall-curl-program (executable-find "curl"))
(defun twinstall-tweet (url)
(let* ((name (file-name-nondirectory url))
(text (format "%sをインストールしました。 #emacsjp #twinstall %s"
name url)))
(twittering-call-api
'update-status
`((status . ,text)))))
(defadvice auto-install-from-url (after twinstall-tweet-url activate)
(twinstall-tweet auto-install-last-url))
(defun twinstall-from-tweet ()
(interactive)
(let ((text (get-text-property (point) 'text)))
(when (string-match " #emacsjp #twinstall \\(http://t\\.co/.*\\)$" text)
(twinstall-from-tco (match-string 1 text)))))
(defun twinstall-tco (tco-url)
(when (string-match "\\`http://t\\.co/" tco-url)
(let ((url (twinstall-expand-url tco-url)))
(auto-install-from-url url))))
(defun twinstall-expand-url (url)
(with-temp-buffer
(call-process twinstall-curl-program nil t nil "-v" url)
(goto-char (point-min))
(if (re-search-forward "^< Location: \\(.*\\)\r$" nil t)
(match-string 1)
url)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment