From: bg66 Date: Sat, 13 Jan 2007 22:27:59 +0000 (+0000) Subject: Fix the last change. X-Git-Tag: mixi-el-1_0_0~109 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ab4c7b77739c3c4c8304ff37f48d450e0d30c5;p=elisp%2Fmixi.git Fix the last change. --- diff --git a/ChangeLog b/ChangeLog index 4039cdb..cc4743c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,14 +8,17 @@ (mixi-news-p): New macro. (mixi-news-page): Ditto. (mixi-news-title-regexp): New regexp. - (mixi-news-time-regexp): Ditto. + (mixi-news-media-regexp): Ditto. + (mixi-news-media-time-regexp): Ditto. (mixi-news-content-regexp): Ditto. (mixi-realize-news): New function. (mixi-news-media-id): New accessor method. (mixi-news-id): Ditto. + (mixi-news-media): Ditto. (mixi-news-time): Ditto. (mixi-news-title): Ditto. (mixi-news-content): Ditto. + (mixi-news-set-media): Ditto. (mixi-news-set-time): Ditto. (mixi-news-set-title): Ditto. (mixi-news-set-content): Ditto. diff --git a/mixi.el b/mixi.el index 13d0b7b..7c29177 100644 --- a/mixi.el +++ b/mixi.el @@ -41,6 +41,7 @@ ;; * mixi-get-new-comments ;; * mixi-get-messages ;; * mixi-get-introductions +;; * mixi-get-news ;; ;; API for posting: ;; @@ -2622,10 +2623,10 @@ Increase this value when unexpected error frequently occurs." ;; News object. (defvar mixi-news-cache (make-hash-table :test 'equal)) -(defun mixi-make-news (media-id id &optional time title content) +(defun mixi-make-news (media-id id &optional media time title content) "Return a news object." (mixi-make-cache (list media-id id) - (cons 'mixi-news (vector nil media-id id time title + (cons 'mixi-news (vector nil media-id id media time title content)) mixi-news-cache)) @@ -2648,8 +2649,8 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-news-title-regexp "\\(.+\\)") -(defconst mixi-news-time-regexp - "(.+ - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\))") +(defconst mixi-news-media-time-regexp + "(\\(.+\\) - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\))") (defconst mixi-news-content-regexp " @@ -2667,18 +2668,20 @@ Increase this value when unexpected error frequently occurs." (if (string-match mixi-news-title-regexp buffer) (mixi-news-set-title news (match-string 1 buffer)) (mixi-realization-error 'cannot-find-title news)) - (if (string-match mixi-news-time-regexp buffer) - (let ((year (nth 5 (decode-time (current-time)))) - (month (nth 4 (decode-time (current-time)))) - (month-of-item (string-to-number (match-string 1 buffer)))) - (when (> month-of-item month) - (decf year)) - (mixi-news-set-time - news (encode-time 0 (string-to-number (match-string 4 buffer)) - (string-to-number (match-string 3 buffer)) - (string-to-number (match-string 2 buffer)) - month year))) - (mixi-realization-error 'cannot-find-time news)) + (if (string-match mixi-news-media-time-regexp buffer) + (progn + (mixi-news-set-media news (match-string 1 buffer)) + (let ((year (nth 5 (decode-time (current-time)))) + (month (nth 4 (decode-time (current-time)))) + (month-of-item (string-to-number (match-string 2 buffer)))) + (when (> month-of-item month) + (decf year)) + (mixi-news-set-time + news (encode-time 0 (string-to-number (match-string 5 buffer)) + (string-to-number (match-string 4 buffer)) + (string-to-number (match-string 3 buffer)) + month year)))) + (mixi-realization-error 'cannot-find-media-time news)) (if (string-match mixi-news-content-regexp buffer) (mixi-news-set-content news (match-string 1 buffer)) (mixi-realization-error 'cannot-find-content news))) @@ -2696,46 +2699,60 @@ Increase this value when unexpected error frequently occurs." (signal 'wrong-type-argument (list 'mixi-news-p news))) (aref (cdr news) 2)) -(defun mixi-news-time (news) - "Return the time of NEWS." +(defun mixi-news-media (news) + "Return the media of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) (unless (aref (cdr news) 3) (mixi-realize-news news)) (aref (cdr news) 3)) -(defun mixi-news-title (news) - "Return the title of NEWS." +(defun mixi-news-time (news) + "Return the time of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) (unless (aref (cdr news) 4) (mixi-realize-news news)) (aref (cdr news) 4)) +(defun mixi-news-title (news) + "Return the title of NEWS." + (unless (mixi-news-p news) + (signal 'wrong-type-argument (list 'mixi-news-p news))) + (unless (aref (cdr news) 5) + (mixi-realize-news news)) + (aref (cdr news) 5)) + (defun mixi-news-content (news) "Return the content of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) (mixi-realize-news news) - (aref (cdr news) 5)) + (aref (cdr news) 6)) + +(defun mixi-news-set-media (news media) + "Set the media of NEWS." + (unless (mixi-news-p news) + (signal 'wrong-type-argument (list 'mixi-news-p news))) + (aset (cdr news) 3 media)) (defun mixi-news-set-time (news time) "Set the time of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) - (aset (cdr news) 3 time)) + (aset (cdr news) 4 time)) (defun mixi-news-set-title (news title) "Set the title of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) - (aset (cdr news) 4 title)) + (aset (cdr news) 5 title)) (defun mixi-news-set-content (news content) "Set the content of NEWS." (unless (mixi-news-p news) (signal 'wrong-type-argument (list 'mixi-news-p news))) - (aset (cdr news) 5 content)) + (aset (cdr news) 6 content)) (defconst mixi-news-category-list '(domestic politics economy area abroad sports entertainment IT)) @@ -2763,7 +2780,7 @@ Increase this value when unexpected error frequently occurs." \\(\\|\\) -.+ +\\(.+\\) \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)") (defun mixi-get-news (category &optional range) @@ -2776,15 +2793,15 @@ Increase this value when unexpected error frequently occurs." (year (nth 5 (decode-time (current-time)))) (month (nth 4 (decode-time (current-time))))) (mapcar (lambda (item) - (let ((month-of-item (string-to-number (nth 5 item)))) + (let ((month-of-item (string-to-number (nth 6 item)))) (when (> month-of-item month) (decf year)) (setq month month-of-item) - (mixi-make-news (nth 2 item) (nth 1 item) + (mixi-make-news (nth 2 item) (nth 1 item) (nth 5 item) (encode-time - 0 (string-to-number (nth 8 item)) + 0 (string-to-number (nth 9 item)) + (string-to-number (nth 8 item)) (string-to-number (nth 7 item)) - (string-to-number (nth 6 item)) month year) (nth 3 item)))) items)))