Skip to content

Commit

Permalink
* twittering-mode.el: Tweet する時に y-or-n-p で問い合わせを出来る
Browse files Browse the repository at this point in the history
ようにした。デフォルトは聞かれない。
(twittering-ask-post): new variable
  • Loading branch information
masutaka authored and cvmat committed May 3, 2010
1 parent 81d82ef commit cd60c44
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,5 +1,9 @@
2010-05-03 Takashi Masuda <masutaka@nifty.com>

* twittering-mode.el: Tweet する時に y-or-n-p で問い合わせを出来る
ようにした。デフォルトは聞かれない。
(twittering-ask-post): new variable

* twittering-mode.el: `V' の補完対象に :direct_messages や :home を
追加した。
(twittering-read-timeline-spec-with-completion): dummy-hist に追加。
Expand Down
69 changes: 37 additions & 32 deletions twittering-mode.el
Expand Up @@ -306,6 +306,9 @@ Twittering-mode provides two functions for updating status:
* `twittering-update-status-from-minibuffer': edit tweets in minibuffer
* `twittering-update-status-from-pop-up-buffer': edit tweets in pop-up buffer")

(defvar twittering-ask-post nil
"*If *non-nil*, ask whether or not you really want to post the tweet.")

;;;
;;; Proxy setting / functions
;;;
Expand Down Expand Up @@ -2250,40 +2253,42 @@ been initialized yet."

(defun twittering-edit-post-status ()
(interactive)
(let ((status (twittering-edit-extract-status))
(reply-to-id (nth 0 twittering-reply-recipient))
(username (nth 1 twittering-reply-recipient))
(spec (nth 2 twittering-reply-recipient)))
(cond
((not (twittering-status-not-blank-p status))
(message "Empty tweet!"))
((< 140 (length status))
(message "Too long tweet!"))
(t
(setq twittering-edit-history
(cons status twittering-edit-history))
(when (and twittering-ask-post
(y-or-n-p "Send this tweet? "))
(let ((status (twittering-edit-extract-status))
(reply-to-id (nth 0 twittering-reply-recipient))
(username (nth 1 twittering-reply-recipient))
(spec (nth 2 twittering-reply-recipient)))
(cond
((twittering-timeline-spec-is-direct-messages-p spec)
(if username
(let ((parameters `(("user" . ,username)
("text" . ,status))))
(twittering-http-post twittering-api-host "1/direct_messages/new"
parameters))
(message "No username specified")))
((not (twittering-status-not-blank-p status))
(message "Empty tweet!"))
((< 140 (length status))
(message "Too long tweet!"))
(t
(let ((parameters `(("status" . ,status))))
;; Add in_reply_to_status_id only when a posting status
;; begins with @username.
(when (and reply-to-id
(string-match
(concat "^@" username "\\(?:[\n\r \t]+\\)*")
status))
(add-to-list 'parameters
`("in_reply_to_status_id" .
,(format "%s" reply-to-id))))
(twittering-http-post twittering-api-host "1/statuses/update"
parameters))))
(twittering-edit-close)))))
(setq twittering-edit-history
(cons status twittering-edit-history))
(cond
((twittering-timeline-spec-is-direct-messages-p spec)
(if username
(let ((parameters `(("user" . ,username)
("text" . ,status))))
(twittering-http-post twittering-api-host "1/direct_messages/new"
parameters))
(message "No username specified")))
(t
(let ((parameters `(("status" . ,status))))
;; Add in_reply_to_status_id only when a posting status
;; begins with @username.
(when (and reply-to-id
(string-match
(concat "^@" username "\\(?:[\n\r \t]+\\)*")
status))
(add-to-list 'parameters
`("in_reply_to_status_id" .
,(format "%s" reply-to-id))))
(twittering-http-post twittering-api-host "1/statuses/update"
parameters))))
(twittering-edit-close))))))

(defun twittering-edit-cancel-status ()
(interactive)
Expand Down

0 comments on commit cd60c44

Please sign in to comment.