From b83b14bcb0dc787259866869f6e7ec9ab193e6f1 Mon Sep 17 00:00:00 2001 From: Tadashi MATSUO Date: Sat, 26 Nov 2011 23:36:21 +0900 Subject: [PATCH] `twittering-call-api' receives `format' for `retrieve-timeline'. * twittering-mode.el: `twittering-call-api' receives `format' as an argument for the command `retrieve-timeline'. (twittering-http-get-default-sentinel): refer to `format' in `connection-info' for parsing the retrieved content. (twittering-call-api): receive `format' as an argument for the command `retrieve-timeline'. The `format' is automatically added to the last of `additional-info' for `twittering-http-get'. --- ChangeLog | 8 ++++++++ twittering-mode.el | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a07252f6..38b3c56c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,14 @@ (twittering-call-api): receive `sentinel' as an argument for the command `retrieve-timeline'. + * twittering-mode.el: `twittering-call-api' receives `format' as + an argument for the command `retrieve-timeline'. + (twittering-http-get-default-sentinel): refer to `format' in + `connection-info' for parsing the retrieved content. + (twittering-call-api): receive `format' as an argument for the + command `retrieve-timeline'. The `format' is automatically added + to the last of `additional-info' for `twittering-http-get'. + 2011-11-13 Tadashi MATSUO * twittering-mode.el: Fix the bug that unconditionally adds diff --git a/twittering-mode.el b/twittering-mode.el index 1730e087..eb486587 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -2222,16 +2222,21 @@ the server when the HTTP status code equals to 400 or 403." (decode-coding-region (point-min) (point-max) 'utf-8))) (let* ((spec (cdr (assq 'timeline-spec connection-info))) (spec-string (cdr (assq 'timeline-spec-string connection-info))) + (format (cdr (assq 'format connection-info))) (statuses - (let ((xmltree - (twittering-xml-parse-region (point-min) (point-max)))) - (cond - ((null xmltree) - nil) - ((eq 'search (car spec)) - (twittering-atom-xmltree-to-status xmltree)) - (t - (twittering-xmltree-to-status xmltree)))))) + (cond + ((eq format 'xml) + (let ((xmltree + (twittering-xml-parse-region (point-min) (point-max)))) + (when xmltree + (twittering-xmltree-to-status xmltree)))) + ((eq format 'atom) + (let ((xmltree + (twittering-xml-parse-region (point-min) (point-max)))) + (when xmltree + (twittering-atom-xmltree-to-status xmltree)))) + (t + nil)))) (when statuses (let ((new-statuses (twittering-add-statuses-to-timeline-data statuses spec)) @@ -4065,6 +4070,7 @@ retrieve-timeline -- Retrieve a timeline. Valid key symbols in ARGS-ALIST: timeline-spec -- the timeline spec to be retrieved. timeline-spec-string -- the string representation of the timeline spec. + format -- (optional) the symbol specifying the format. number -- (optional) how many tweets are retrieved. It must be an integer. If nil, `twittering-number-of-tweets-on-retrieval' is used instead. The maximum for search timeline is 100, and that for other timelines is @@ -4235,9 +4241,16 @@ get-service-configuration -- Get the configuration of the server. ;; retweets_of_me `(("include_entities" . "true") ("count" . ,number-str)))))))) - (format (if (eq spec-type 'search) - "atom" - "xml")) + (format + (let ((format (cdr (assq 'format args-alist)))) + (cond + ((and format (symbolp format)) + format) + ((eq spec-type 'search) + 'atom) + (t + 'xml)))) + (format-str (symbol-name format)) (simple-spec-list '((direct_messages . "direct_messages") (direct_messages_sent . "direct_messages/sent") @@ -4271,9 +4284,10 @@ get-service-configuration -- Get the configuration of the server. (twittering-api-path (cdr (assq spec-type simple-spec-list)))) (t nil))) (sentinel (cdr (assq 'sentinel args-alist))) - (clean-up-sentinel (cdr (assq 'clean-up-sentinel args-alist)))) + (clean-up-sentinel (cdr (assq 'clean-up-sentinel args-alist))) + (additional-info `(,@additional-info (format . ,format)))) (if (and host method) - (twittering-http-get host method parameters format + (twittering-http-get host method parameters format-str additional-info sentinel clean-up-sentinel) (error "Invalid timeline spec")))) ((eq command 'get-list-index)