From 0ffea5fd6df212de4b1f0a22bcfd625c91f55224 Mon Sep 17 00:00:00 2001 From: bg66 Date: Mon, 15 Jan 2007 04:53:31 +0000 Subject: [PATCH] * mixi.el (mixi-bbs-p): Simplify. (mixi-message-box-p): Ditto. (mixi-news-category-p): Ditto. (mixi-news-sort-list): New constant. (mixi-news-sort-p): New macro. (mixi-news-sort-id): New function. (mixi-news-list-page): Add SORT argument. (mixi-get-news): Ditto. * sb-mixi.el (shimbun-mixi-group-alist): Follow the change above. --- ChangeLog | 13 ++++++++++ mixi.el | 38 +++++++++++++++++++--------- sb-mixi.el | 83 +++++++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 93 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab448ce..256137e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-01-15 OHASHI Akira + + * mixi.el (mixi-bbs-p): Simplify. + (mixi-message-box-p): Ditto. + (mixi-news-category-p): Ditto. + (mixi-news-sort-list): New constant. + (mixi-news-sort-p): New macro. + (mixi-news-sort-id): New function. + (mixi-news-list-page): Add SORT argument. + (mixi-get-news): Ditto. + + * sb-mixi.el (shimbun-mixi-group-alist): Follow the change above. + 2007-01-14 OHASHI Akira * sb-mixi.el (shimbun-mixi-group-alist): Add news groups. diff --git a/mixi.el b/mixi.el index d19d6a7..0011d90 100644 --- a/mixi.el +++ b/mixi.el @@ -2025,8 +2025,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-bbs-list '(mixi-topic mixi-event)) (defmacro mixi-bbs-p (object) - `(when (memq (mixi-object-class ,object) mixi-bbs-list) - t)) + `(memq (mixi-object-class ,object) mixi-bbs-list)) (defun mixi-bbs-community (object) "Return the community of OBJECT." @@ -2333,8 +2332,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-message-box-list '(inbox outbox savebox thrash)) ; thrash? (defmacro mixi-message-box-p (box) - `(when (memq ,box mixi-message-box-list) - t)) + `(memq ,box mixi-message-box-list)) (defun mixi-message-box-name (box) "Return the name of BOX." @@ -2758,8 +2756,7 @@ Increase this value when unexpected error frequently occurs." sports entertainment IT)) (defmacro mixi-news-category-p (category) - `(when (memq ,category mixi-news-category-list) - t)) + `(memq ,category mixi-news-category-list)) (defun mixi-news-category-id (category) "Return the id of CATEGORY." @@ -2769,9 +2766,24 @@ Increase this value when unexpected error frequently occurs." (1+ (- (length mixi-news-category-list) (length (memq category mixi-news-category-list)))))) -(defmacro mixi-news-list-page (category) - `(concat "http://news.mixi.jp/list_news_category.pl?page=%d&sort=1" - (concat "&id=" (mixi-news-category-id category) "&type=bn"))) +(defconst mixi-news-sort-list '(newest pickup)) + +(defmacro mixi-news-sort-p (sort) + `(memq ,sort mixi-news-sort-list)) + +(defun mixi-news-sort-id (sort) + "Return the id of SORT." + (unless (mixi-news-sort-p sort) + (signal 'wrong-type-argument (list 'mixi-news-sort-p sort))) + (number-to-string + (- (length mixi-news-sort-list) + (length (memq sort mixi-news-sort-list))))) + +(defmacro mixi-news-list-page (category sort) + `(concat "http://news.mixi.jp/list_news_category.pl?page=%d" + "&sort=" (mixi-news-sort-id ,sort) + "&id=" (mixi-news-category-id ,category) + "&type=bn")) (defconst mixi-news-list-regexp " @@ -2783,11 +2795,13 @@ Increase this value when unexpected error frequently occurs." \\(.+\\) \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)") -(defun mixi-get-news (category &optional range) - "Get news of CATEGORY." +(defun mixi-get-news (category sort &optional range) + "Get news of CATEGORY and SORT." (unless (mixi-news-category-p category) (signal 'wrong-type-argument (list 'mixi-news-category-p category))) - (let ((items (mixi-get-matched-items (mixi-news-list-page category) + (unless (mixi-news-sort-p sort) + (signal 'wrong-type-argument (list 'mixi-news-sort-p sort))) + (let ((items (mixi-get-matched-items (mixi-news-list-page category sort) mixi-news-list-regexp range)) (year (nth 5 (decode-time (current-time)))) diff --git a/sb-mixi.el b/sb-mixi.el index 8769c64..b9ae226 100644 --- a/sb-mixi.el +++ b/sb-mixi.el @@ -36,35 +36,60 @@ (luna-define-class shimbun-mixi (shimbun) (comment-cache)) (luna-define-internal-accessors 'shimbun-mixi)) -(defcustom shimbun-mixi-group-alist '(("new-diaries" . mixi-get-new-diaries) - ("new-comments" . mixi-get-new-comments) - ("new-bbses" . mixi-get-new-bbses) - ("messages" . mixi-get-messages) - ("my-diaries" . "/home.pl") - ("news.domestic" . - (lambda (range) - (mixi-get-news 'domestic range))) - ("news.politics" . - (lambda (range) - (mixi-get-news 'politics range))) - ("news.economy" . - (lambda (range) - (mixi-get-news 'economy range))) - ("news.area" . - (lambda (range) - (mixi-get-news 'area range))) - ("news.abroad" . - (lambda (range) - (mixi-get-news 'abroad range))) - ("news.sports" . - (lambda (range) - (mixi-get-news 'sports range))) - ("news.entertainment" . - (lambda (range) - (mixi-get-news 'entertainment range))) - ("news.it" . - (lambda (range) - (mixi-get-news 'IT range)))) +(defcustom shimbun-mixi-group-alist + '(("new-diaries" . mixi-get-new-diaries) + ("new-comments" . mixi-get-new-comments) + ("new-bbses" . mixi-get-new-bbses) + ("messages" . mixi-get-messages) + ("my-diaries" . "/home.pl") + ("news.newest.domestic" . + (lambda (range) + (mixi-get-news 'domestic 'newest range))) + ("news.newest.politics" . + (lambda (range) + (mixi-get-news 'politics 'newest range))) + ("news.newest.economy" . + (lambda (range) + (mixi-get-news 'economy 'newest range))) + ("news.newest.area" . + (lambda (range) + (mixi-get-news 'area 'newest range))) + ("news.newest.abroad" . + (lambda (range) + (mixi-get-news 'abroad 'newest range))) + ("news.newest.sports" . + (lambda (range) + (mixi-get-news 'sports 'newest range))) + ("news.newest.entertainment" . + (lambda (range) + (mixi-get-news 'entertainment 'newest range))) + ("news.newest.it" . + (lambda (range) + (mixi-get-news 'IT 'newest range))) + ("news.pickup.domestic" . + (lambda (range) + (mixi-get-news 'domestic 'pickup range))) + ("news.pickup.politics" . + (lambda (range) + (mixi-get-news 'politics 'pickup range))) + ("news.pickup.economy" . + (lambda (range) + (mixi-get-news 'economy 'pickup range))) + ("news.pickup.area" . + (lambda (range) + (mixi-get-news 'area 'pickup range))) + ("news.pickup.abroad" . + (lambda (range) + (mixi-get-news 'abroad 'pickup range))) + ("news.pickup.sports" . + (lambda (range) + (mixi-get-news 'sports 'pickup range))) + ("news.pickup.entertainment" . + (lambda (range) + (mixi-get-news 'entertainment 'pickup range))) + ("news.pickup.it" . + (lambda (range) + (mixi-get-news 'IT 'pickup range)))) "*An alist of mixi shimbun group definition. Each element looks like (NAME . URL) or (NAME . FUNCTION). NAME is a shimbun group name. -- 1.7.10.4