From cd60c445f11f390b13a8c96ca19826af1112ac79 Mon Sep 17 00:00:00 2001 From: Takashi Masuda Date: Mon, 3 May 2010 15:37:24 +0900 Subject: [PATCH] =?UTF-8?q?*=20twittering-mode.el:=20Tweet=20=E3=81=99?= =?UTF-8?q?=E3=82=8B=E6=99=82=E3=81=AB=20y-or-n-p=20=E3=81=A7=E5=95=8F?= =?UTF-8?q?=E3=81=84=E5=90=88=E3=82=8F=E3=81=9B=E3=82=92=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E3=82=8B=20=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88=E3=81=AF?= =?UTF-8?q?=E8=81=9E=E3=81=8B=E3=82=8C=E3=81=AA=E3=81=84=E3=80=82=20(twitt?= =?UTF-8?q?ering-ask-post):=20new=20variable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 4 +++ twittering-mode.el | 69 +++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c8823e5..05a04108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-05-03 Takashi Masuda + * 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 に追加。 diff --git a/twittering-mode.el b/twittering-mode.el index 01f373d8..30a79e3c 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -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 ;;; @@ -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)