From 98fb6e49db8bcf46c71f659603dd1c410a32285a Mon Sep 17 00:00:00 2001 From: Tadashi MATSUO Date: Sun, 20 Dec 2009 20:17:18 +0900 Subject: [PATCH] 'twittering-read-list-name' is added. --- ChangeLog | 7 +++++++ twittering-mode.el | 50 ++++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9dc9b97..ad2db5a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -262,6 +262,13 @@ (twittering-http-get-default-sentinel): Invokes `twittering-add-timeline-history' to update history when retrieving tweets successfully. + (twittering-other-user-list-interactive): The codes for retrieving + list index synchronously are extracted as the new function + `twittering-get-list-sync'. + (twittering-get-list-index-sync): Add new function for retrieving + list synchronously. + (twittering-read-list-name): Add new function for reading a list + name from the minibuffer. 2009-12-20 Yuto Hayamizu diff --git a/twittering-mode.el b/twittering-mode.el index f61c97ed..adbf7e4d 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -1628,6 +1628,20 @@ following symbols; t nil 'twittering-http-get-list-index-sentinel)) +(defun twittering-get-list-index-sync (username) + (setq twittering-list-index-retrieved nil) + (twittering-get-list-index username) + (while (not twittering-list-index-retrieved) + (sit-for 0.1)) + (cond + ((stringp twittering-list-index-retrieved) + (if (string= "" twittering-list-index-retrieved) + (message (concat username " has no list")) + (message twittering-list-index-retrieved)) + nil) + ((listp twittering-list-index-retrieved) + twittering-list-index-retrieved))) + (defun twittering-manage-friendships (method username) (twittering-http-post "twitter.com" (concat "friendships/" method) @@ -2026,25 +2040,11 @@ following symbols; "whose list: " (get-text-property (point) 'username) 'twittering-user-history))) - (if (> (length username) 0) - (progn - (setq twittering-list-index-retrieved nil) - (twittering-get-list-index username) - (while (not twittering-list-index-retrieved) - (sit-for 0.1)) - (cond - ((listp twittering-list-index-retrieved) - (let ((choice (completing-read - (concat username "'s list: ") - twittering-list-index-retrieved - nil t ""))) - (when (and choice (not (string= "" choice))) - (twittering-get-list username choice)))) - ((stringp twittering-list-index-retrieved) - (if (string= "" twittering-list-index-retrieved) - (message (concat username " have no list")) - (message twittering-list-index-retrieved))))) - (message "No user selected")))) + (if (string= "" username) + (message "No user selected") + (let ((list-name (twittering-read-list-name username))) + (when list-name + (twittering-get-list username list-name)))))) (defun twittering-direct-message () (interactive) @@ -2070,6 +2070,18 @@ following symbols; twittering-user-history) nil nil init-user history)) +(defun twittering-read-list-name (username &optional list-index) + (let* ((list-index (or list-index + (twittering-get-list-index-sync username))) + (prompt (concat username "'s list: ")) + (listname + (if list-index + (completing-read prompt list-index nil t nil) + nil))) + (if (string= "" listname) + nil + listname))) + (defun twittering-get-username () (or twittering-username-active (setq twittering-username-active (read-string "your twitter username: "))))