2009/09/27

Enhancing twit.el

I've been using twit.el as a client for Twitter because it works on Emacs, my favorite editor. But there are some rooms to be extended, so I added few lines to ameliorate twit.el.

These are my configuration for twit.el written in .emacs.el.

1. Access an url written in a tweet (requires emacs-w3m.)
P.S. Oh, I noticed that twit.el already has the function `twit-visit-link' by hitting `v' key!

2. Show messages while updating recent-tweets because the process takes some time.
3. Add a confirmation just before posting a tweet.



;;; twitter
(require 'twit)
;(twit-show-recent-tweets)
;(twit-follow-recent-tweets)

(define-key twit-status-mode-map "\C-m"
'(lambda ()
(interactive)
(let ((url (w3m-active-region-or-url-at-point nil)))
(if url
(browse-url url)))))

(defadvice twit-show-recent-tweets (before message-before)
(message "Accessing Twitter now..."))

(defadvice twit-show-recent-tweets (after message-after)
(message "Updated!"))

(ad-activate 'twit-show-recent-tweets)


(defadvice twit-post-status (around twit-post-confirmation)
(if (y-or-n-p "Do you really want to post the tweet?")
ad-do-it))

(ad-activate 'twit-post-status)