松尾です。
ATOM形式でsearch APIを使うパッチを作ってみました。
search-mode branchのHEAD
65cd7682eb721fc138f940f6cc4452551c79d776
へのパッチです。
%Sも取得でき、json.elも必要なくなります。
どうでしょうか。
---
松尾 直志
>From cd069329b8eda93c3e01442dabbdab823f118b60 Mon Sep 17 00:00:00 2001
From: Tadashi MATSUO
Date: Fri, 5 Feb 2010 02:14:27 +0900
Subject: [PATCH] `twittering-format-status' replaces null property by empty
strings.
* twittering-mode.el (twittering-format-status): replace a lacked
property by an empty string.
---
ChangeLog |5 +
twittering-mode.el |4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 484452b..38b872f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-05 Tadashi MATSUO
+
+ * twittering-mode.el (twittering-format-status): replace a lacked
+ property by an empty string.
+
2010-02-04 Tadashi MATSUO
* twittering-mode.el (twittering-status-to-status-datum): assign a
diff --git a/twittering-mode.el b/twittering-mode.el
index 19dfc10..974527b 100644
--- a/twittering-mode.el
+++ b/twittering-mode.el
@@ -2270,7 +2270,7 @@ following symbols;
Specification of format-str is described in the document for the
variable `twittering-status-format'"
(flet ((attr (key)
- (assocref key status))
+ (or (assocref key status) ""))
(profile-image
()
(let ((profile-image-url (attr 'user-profile-image-url))
@@ -2401,7 +2401,7 @@ variable `twittering-status-format'"
in-reply-to-string url))
("R" .
,(let ((retweeted-by (attr 'original-user-screen-name)))
- (if retweeted-by
+ (if (not (string= "" retweeted-by))
(concat " (retweeted by " retweeted-by ")")
"")))
--
1.5.6.5
>From 7806145b8307d0ef5c3262330434eddc61d2cd61 Mon Sep 17 00:00:00 2001
From: Tadashi MATSUO
Date: Fri, 5 Feb 2010 02:14:43 +0900
Subject: [PATCH] Use ATOM for retrieving "search" timeline instead of JSON.
* twittering-mode.el (twittering-get-status-from-http-response):
use ATOM format instead of JSON format.
(twittering-atom-xmltree-to-status-datum): new function for
converting an entry of ATOM into a status alist.
(twittering-atom-xmltree-to-status): new function for converting a
XML tree of ATOM into a list of status alists.
(twittering-json-to-status-datum): removed.
(twittering-json-to-status): removed.
(twittering-get-tweets): retrieve "search" timeline in ATOM format
instead of JSON format.
(twittering-get-and-render-timeline): remove dependence on
`json.el'.
(twittering-search): likewise.
---
ChangeLog | 14
twittering-mode.el | 173 +++
2 files changed, 79 insertions(+), 108 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38b872f..8871615 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,20 @@
* twittering-mode.el (twittering-format-status): replace a lacked
property by an empty string.
+ * twittering-mode.el (twittering-get-status-from-http-response):
+ use ATOM format instead of JSON format.
+ (twittering-atom-xmltree-to-status-datum): new function for
+ converting an entry of ATOM into a status alist.
+ (twittering-atom-xmltree-to-status): new function for converting a
+ XML tree of ATOM into a list of status alists.
+ (twittering-json-to-status-datum): removed.
+ (twittering-json-to-status): removed.
+ (twittering-get-tweets): retrieve "search" timeline in ATOM format
+ instead of JSON format.
+ (twittering-get-and-render-timeline): remove dependence on
+ `json.el'.
+ (twittering-search): likewise.
+
2010-02-04 Tadashi MATSUO
* twittering-mode.el (twittering-status-to-status-datum): assign a
diff --git a/twittering-mode.el b/twittering-mode.el
index 974527b..7304e7c 100644
--- a/twittering-mode.el
+++ b/twittering-mode.el
@@ -1713,10 +1713,9 @@ Return nil when parse failed.
`buffer' may be a buffer or the name of an existing buffer. "
(cond
((eq 'search (car spec))
-(let ((body-string (twittering-get-response-body buffer)))
- (when body-string
- (let ((json-data (json-read-from-string body-string)))
- (reverse (twittering-json-to-status json-data))
+(let ((body (twittering-get-response-body buffer 'xml-parse-region)))
+ (when body
+ (reverse (twittering-atom-xmltree-to-status body)
(t
(let ((body (twittering-get-response-body buffer 'xml-parse-region)))
(when body
@@ -1743,94 +1742,58 @@ If ID of STATUS-DATUM is already in ID-TABLE, return
nil. If not, return t."
(puthash source-id t id-table))
t)))
-(defun twittering-json-to-status-datum (status)
- (flet ((assq-get (item seq)
- (cdr (assq item seq
-(let* (id text source created-at truncated
- in-reply-to-status-id
-