X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-twitter.el;h=d82841296529a9ffc9424db39e30302d0b7c8303;hb=9fab6517fc217311d3741753fd4e3c1f33e8c74a;hp=6212ff0c6dc8118c62d0f5be6280778d4bfe520f;hpb=156131f7ee2c6887049318652292f49d05cc7279;p=elisp%2Friece.git diff --git a/lisp/riece-twitter.el b/lisp/riece-twitter.el index 6212ff0..d828412 100644 --- a/lisp/riece-twitter.el +++ b/lisp/riece-twitter.el @@ -38,10 +38,11 @@ :group 'riece-twitter :type 'string) -(if (fboundp 'clear-string) - (defalias 'riece-twitter-clear-string 'clear-string) - (defun riece-twitter-clear-string (string) - (fillarray string ?\x0))) +(eval-and-compile + (if (fboundp 'clear-string) + (defalias 'riece-twitter-clear-string 'clear-string) + (defun riece-twitter-clear-string (string) + (fillarray string ?\0)))) (defun riece-twitter-set-credential (credential) "Set your credential used to login to Twitter." @@ -49,28 +50,43 @@ (let ((username (read-string "Username: ")) password) (unwind-protect - (setq password (read-passwd "Password: ")) + (list (concat username ":" + (setq password (read-passwd "Password: ")))) (if password (riece-twitter-clear-string password)) - (setq password nil)) - (list (concat username ":" password)))) + (setq password nil)))) (setq riece-twitter-credential credential)) (defun riece-twitter-update (status) "Update your status." - (interactive "sStatus: ") - (start-process - "curl" nil "curl" - "-H" "X-Twitter-Client: Riece" - "-H" (concat "X-Twitter-Client-Version: " riece-version-number) - "-H" "X-Twitter-Client-URL: http://riece.nongnu.org/twitter.xml" - "-u" credential - "-d" "source=riece" - "-d" (concat "status=" - (riece-twitter-escape-string - (encode-coding-string status 'utf-8))) - "-s" - "http://twitter.com/statuses/update.json")) + (interactive + (progn + (unless riece-twitter-credential + (error "%s" + (substitute-command-keys + "\\[riece-twitter-set-credential] to set your credential"))) + (list (read-string "Status: ")))) + (message "Sending to Twitter...") + (let ((process + (start-process + "curl" nil "curl" + "-H" "X-Twitter-Client: Riece" + "-H" (concat "X-Twitter-Client-Version: " riece-version-number) + "-H" "X-Twitter-Client-URL: http://riece.nongnu.org/twitter.xml" + "-u" riece-twitter-credential + "-d" "source=riece" + "-d" (concat "status=" + (riece-twitter-escape-string + (encode-coding-string status 'utf-8))) + "-s" + "http://twitter.com/statuses/update.json"))) + (set-process-sentinel process #'riece-twitter-sentinel))) + +(defun riece-twitter-sentinel (process status) + (if (equal status "finished\n") + (message "Sending to Twitter...done") + (message "Sending to Twitter...failed: %s" + (substring status 0 (1- (length status)))))) (defun riece-twitter-message-filter (message) (if (and (riece-message-own-p message)