Skip to content

Instantly share code, notes, and snippets.

@masutaka
Forked from naota/twinstall.el
Created October 20, 2011 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save masutaka/1300477 to your computer and use it in GitHub Desktop.
Save masutaka/1300477 to your computer and use it in GitHub Desktop.
(defvar twinstall-curl-program (executable-find "curl"))
(defvar twinstall-last-url "")
(defvar twinstall-hash-tags "#emacsjp #twinstall")
(defun twinstall-tweet-url (url)
(let* ((name (file-name-nondirectory url))
(text (cond
((string= (concat auto-install-emacswiki-base-url name) url)
(format "EmacsWikiから%sをインストールしました。 %s %s"
name twinstall-hash-tags url))
(t
(format "%sをインストールしました。 %s %s"
name twinstall-hash-tags url)))))
(twittering-call-api
'update-status
`((status . ,text)))))
(defadvice auto-install-download (after twinstall-push-url activate)
(setq twinstall-last-url (ad-get-arg 0)))
(defadvice auto-install-from-url (after twinstall-tweet-url activate)
(twinstall-tweet-url auto-install-last-url))
(defadvice auto-install-from-emacswiki (after twinstall-tweet-emacswiki activate)
(twinstall-tweet-url twinstall-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)))
@masutaka
Copy link
Author

M-x auto-install-from-emacswiki でも tweet するようにしてみました。
M-x auto-install-batch の対応は面倒ですね。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment