'error-conditions '(mixi-post-error error))
(defmacro mixi-realization-error (type object)
- `(let ((data (if (and (boundp 'buffer) debug-on-error)
- (list ,type ,object buffer)
+ `(let ((data (if debug-on-error
+ (list ,type ,object (buffer-string))
(list ,type ,object))))
(signal 'mixi-realization-error data)))
(defmacro mixi-post-error (type &optional object)
- `(let ((data (when (and (boundp 'buffer) debug-on-error)
- (list buffer))))
+ `(let ((data (when debug-on-error (list (buffer-string)))))
(if ,object
(setq data (cons ,type (cons ,object data)))
(setq data (cons ,type data)))
(mixi-retrieve "/logout.pl"))
(defmacro with-mixi-retrieve (url &rest body)
- `(let (buffer)
- (when ,url
- (setq buffer (mixi-retrieve ,url))
- (when (string-match "<form action=\"login\\.pl\" method=\"post\">"
- buffer)
+ `(when ,url
+ (with-temp-buffer
+ (insert (mixi-retrieve ,url))
+ (goto-char (point-min))
+ (when (search-forward
+ "<form action=\"login.pl\" method=\"post\">" nil t)
(mixi-login)
- (setq buffer (mixi-retrieve ,url))))
- ,@body))
+ (erase-buffer)
+ (insert (mixi-retrieve ,url))
+ (goto-char (point-min)))
+ ,@body)))
(put 'with-mixi-retrieve 'lisp-indent-function 'defun)
-(put 'with-mixi-retrieve 'edebug-form-spec '(form body))
+(put 'with-mixi-retrieve 'edebug-form-spec '(body))
(defmacro with-mixi-post-form (url fields &rest body)
- `(let (buffer)
- (when ,url
- (setq buffer (mixi-post-form ,url ,fields))
- (when (string-match "<form action=\"login\\.pl\" method=\"post\">"
- buffer)
+ `(when ,url
+ (with-temp-buffer
+ (insert (mixi-post-form ,url ,fields))
+ (goto-char (point-min))
+ (when (search-forward
+ "<form action=\"login.pl\" method=\"post\">" nil t)
(mixi-login)
- (setq buffer (mixi-post-form ,url ,fields))))
- ,@body))
+ (erase-buffer)
+ (insert (mixi-post-form ,url ,fields))
+ (goto-char (point-min)))
+ ,@body)))
(put 'with-mixi-post-form 'lisp-indent-function 'defun)
-(put 'with-mixi-post-form 'edebug-form-spec '(form body))
+(put 'with-mixi-post-form 'edebug-form-spec '(body))
(defun mixi-get-matched-items (url regexp &optional range)
"Get matched items to REGEXP in URL."
(catch 'end
(while (or (null range) (< (length ids) range))
(with-mixi-retrieve (format url page)
- (let ((pos 0)
- found)
- (while (and (string-match regexp buffer pos)
+ (let (found)
+ (while (and (re-search-forward regexp nil t)
(or (null range) (< (length ids) range)))
(let ((num 1)
list)
- (while (match-string num buffer)
- (setq list (cons (match-string num buffer) list))
+ (while (match-string num)
+ (setq list (cons (match-string num) list))
(incf num))
(when (not (member (reverse list) ids))
(setq found t)
- (setq ids (cons (reverse list) ids)))
- (setq pos (match-end (1- num)))))
+ (setq ids (cons (reverse list) ids)))))
(when (not found)
(throw 'end ids))))
(incf page)))
"Return a my object."
(unless mixi-me
(with-mixi-retrieve "/home.pl"
- (if (string-match mixi-my-id-regexp buffer)
- (setq mixi-me (mixi-make-friend (match-string 1 buffer)))
+ (if (re-search-forward mixi-my-id-regexp)
+ (setq mixi-me (mixi-make-friend (match-string 1)))
(signal 'error (list 'who-am-i)))))
mixi-me)
(unless (mixi-object-realized-p friend)
(let (buf)
(with-mixi-retrieve (mixi-friend-page friend)
- (setq buf buffer))
+ (setq buf (buffer-string)))
(if (string-match mixi-friend-nick-regexp buf)
(mixi-friend-set-nick friend (match-string 1 buf))
(mixi-realization-error 'cannot-find-nick friend))
(unless (string-match mixi-friend-name-regexp buf)
(with-mixi-retrieve (concat "/show_profile.pl?id="
(mixi-friend-id friend))
- (setq buf buffer)))
+ (setq buf (buffer-string))))
(if (string-match mixi-friend-name-regexp buf)
(mixi-friend-set-name friend (match-string 2 buf))
(mixi-realization-error 'cannot-find-name friend))
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realized-p diary)
(with-mixi-retrieve (mixi-diary-page diary)
- (unless (string-match mixi-diary-closed-regexp buffer)
- (if (string-match mixi-diary-owner-nick-regexp buffer)
+ (unless (re-search-forward mixi-diary-closed-regexp nil t)
+ (if (re-search-forward mixi-diary-owner-nick-regexp nil t)
(mixi-friend-set-nick (mixi-diary-owner diary)
- (match-string 1 buffer))
+ (match-string 1))
(mixi-realization-error 'cannot-find-owner-nick diary))
- (if (string-match mixi-diary-time-regexp buffer)
+ (if (re-search-forward mixi-diary-time-regexp nil t)
(mixi-diary-set-time
- diary (encode-time 0 (string-to-number (match-string 10 buffer))
- (string-to-number (match-string 9 buffer))
- (string-to-number (match-string 7 buffer))
- (string-to-number (match-string 6 buffer))
- (string-to-number (match-string 5 buffer))))
+ diary (encode-time 0 (string-to-number (match-string 10))
+ (string-to-number (match-string 9))
+ (string-to-number (match-string 7))
+ (string-to-number (match-string 6))
+ (string-to-number (match-string 5))))
(mixi-realization-error 'cannot-find-time diary))
- (if (string-match mixi-diary-title-regexp buffer)
- (mixi-diary-set-title diary (match-string 2 buffer))
+ (if (re-search-forward mixi-diary-title-regexp nil t)
+ (mixi-diary-set-title diary (match-string 2))
(mixi-realization-error 'cannot-find-title diary))
- (if (string-match mixi-diary-content-regexp buffer)
- (mixi-diary-set-content diary (match-string 2 buffer))
+ (if (re-search-forward mixi-diary-content-regexp nil t)
+ (mixi-diary-set-content diary (match-string 2))
(mixi-realization-error 'cannot-find-content diary))))
(mixi-object-touch diary)))
("submit" . "main")))
post-key)
(with-mixi-post-form (mixi-post-diary-page) fields
- (if (string-match mixi-post-key-regexp buffer)
- (setq post-key (match-string 1 buffer))
+ (if (re-search-forward mixi-post-key-regexp nil t)
+ (setq post-key (match-string 1))
(mixi-post-error 'cannot-find-key)))
(setq fields `(("post_key" . ,post-key)
("id" . ,(mixi-friend-id (mixi-make-me)))
("diary_body" . ,content)
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-diary-page) fields
- (unless (string-match mixi-post-succeed-regexp buffer)
+ (unless (re-search-forward mixi-post-succeed-regexp nil t)
(mixi-post-error 'cannot-find-succeed)))))
;; Community object.
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realized-p community)
(with-mixi-retrieve (mixi-community-page community)
- (if (string-match mixi-community-nodata-regexp buffer)
+ (if (re-search-forward mixi-community-nodata-regexp nil t)
;; FIXME: Set all members?
(mixi-community-set-name community "¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
- (if (string-match mixi-community-name-regexp buffer)
- (mixi-community-set-name community (match-string 1 buffer))
+ (if (re-search-forward mixi-community-name-regexp nil t)
+ (mixi-community-set-name community (match-string 1))
(mixi-realization-error 'cannot-find-name community))
- (if (string-match mixi-community-birthday-regexp buffer)
+ (if (re-search-forward mixi-community-birthday-regexp nil t)
(mixi-community-set-birthday
community
- (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))
- (string-to-number (match-string 1 buffer))))
+ (encode-time 0 0 0 (string-to-number (match-string 3))
+ (string-to-number (match-string 2))
+ (string-to-number (match-string 1))))
(mixi-realization-error 'cannot-find-birthday community))
- (if (string-match mixi-community-owner-regexp buffer)
- (if (string= (match-string 1 buffer) "home.pl")
+ (if (re-search-forward mixi-community-owner-regexp nil t)
+ (if (string= (match-string 1) "home.pl")
(mixi-community-set-owner community (mixi-make-me))
(mixi-community-set-owner
- community (mixi-make-friend (match-string 2 buffer)
- (match-string 3 buffer))))
+ community (mixi-make-friend (match-string 2)
+ (match-string 3))))
(mixi-realization-error 'cannot-find-owner community))
- (if (string-match mixi-community-category-regexp buffer)
- (mixi-community-set-category community (match-string 1 buffer))
+ (if (re-search-forward mixi-community-category-regexp nil t)
+ (mixi-community-set-category community (match-string 1))
(mixi-realization-error 'cannot-find-category community))
- (if (string-match mixi-community-members-regexp buffer)
+ (if (re-search-forward mixi-community-members-regexp nil t)
(mixi-community-set-members
- community (string-to-number (match-string 1 buffer)))
+ community (string-to-number (match-string 1)))
(mixi-realization-error 'cannot-find-members community))
- (if (string-match mixi-community-open-level-regexp buffer)
- (mixi-community-set-open-level community (match-string 1 buffer))
+ (if (re-search-forward mixi-community-open-level-regexp nil t)
+ (mixi-community-set-open-level community (match-string 1))
(mixi-realization-error 'cannot-find-open-level community))
- (if (string-match mixi-community-authority-regexp buffer)
- (mixi-community-set-authority community (match-string 1 buffer))
+ (if (re-search-forward mixi-community-authority-regexp nil t)
+ (mixi-community-set-authority community (match-string 1))
(mixi-realization-error 'cannot-find-authority community))
- (if (string-match mixi-community-description-regexp buffer)
- (mixi-community-set-description community (match-string 1 buffer))
+ (if (re-search-forward mixi-community-description-regexp nil t)
+ (mixi-community-set-description community (match-string 1))
(mixi-realization-error 'cannot-find-description community))))
(mixi-object-touch community)))
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realized-p topic)
(with-mixi-retrieve (mixi-topic-page topic)
- (if (string-match mixi-topic-community-regexp buffer)
+ (if (re-search-forward mixi-topic-community-regexp nil t)
(mixi-community-set-name (mixi-topic-community topic)
- (match-string 1 buffer))
+ (match-string 1))
(mixi-realization-error 'cannot-find-community topic))
- (if (string-match mixi-topic-time-regexp buffer)
+ (if (re-search-forward mixi-topic-time-regexp nil t)
(mixi-topic-set-time
- topic (encode-time 0 (string-to-number (match-string 5 buffer))
- (string-to-number (match-string 4 buffer))
- (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))
- (string-to-number (match-string 1 buffer))))
+ topic (encode-time 0 (string-to-number (match-string 5))
+ (string-to-number (match-string 4))
+ (string-to-number (match-string 3))
+ (string-to-number (match-string 2))
+ (string-to-number (match-string 1))))
(mixi-realization-error 'cannot-find-time topic))
- (if (string-match mixi-topic-title-regexp buffer)
- (mixi-topic-set-title topic (match-string 1 buffer))
+ (if (re-search-forward mixi-topic-title-regexp nil t)
+ (mixi-topic-set-title topic (match-string 1))
(mixi-realization-error 'cannot-find-title topic))
- (if (string-match mixi-topic-owner-regexp buffer)
+ (if (re-search-forward mixi-topic-owner-regexp nil t)
(mixi-topic-set-owner topic
- (mixi-make-friend (match-string 1 buffer)
- (match-string 2 buffer)))
+ (mixi-make-friend (match-string 1)
+ (match-string 2)))
(mixi-realization-error 'cannot-find-owner topic))
- (if (string-match mixi-topic-content-regexp buffer)
- (mixi-topic-set-content topic (match-string 2 buffer))
+ (if (re-search-forward mixi-topic-content-regexp nil t)
+ (mixi-topic-set-content topic (match-string 2))
(mixi-realization-error 'cannot-find-content topic)))
(mixi-object-touch topic)))
("submit" . "main")))
post-key)
(with-mixi-post-form (mixi-post-topic-page community) fields
- (if (string-match mixi-post-key-regexp buffer)
- (setq post-key (match-string 1 buffer))
+ (if (re-search-forward mixi-post-key-regexp nil t)
+ (setq post-key (match-string 1))
(mixi-post-error 'cannot-find-key community)))
(setq fields `(("post_key" . ,post-key)
("bbs_title" . ,title)
("bbs_body" . ,content)
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-topic-page community) fields
- (unless (string-match mixi-post-succeed-regexp buffer)
+ (unless (re-search-forward mixi-post-succeed-regexp nil t)
(mixi-post-error 'cannot-find-succeed community)))))
;; Event object.
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realized-p event)
(with-mixi-retrieve (mixi-event-page event)
- (if (string-match mixi-event-community-regexp buffer)
+ (if (re-search-forward mixi-event-community-regexp nil t)
(mixi-community-set-name (mixi-event-community event)
- (match-string 1 buffer))
+ (match-string 1))
(mixi-realization-error 'cannot-find-community event))
- (if (string-match mixi-event-time-regexp buffer)
+ (if (re-search-forward mixi-event-time-regexp nil t)
(mixi-event-set-time
- event (encode-time 0 (string-to-number (match-string 8 buffer))
- (string-to-number (match-string 7 buffer))
- (string-to-number (match-string 6 buffer))
- (string-to-number (match-string 5 buffer))
- (string-to-number (match-string 4 buffer))))
+ event (encode-time 0 (string-to-number (match-string 8))
+ (string-to-number (match-string 7))
+ (string-to-number (match-string 6))
+ (string-to-number (match-string 5))
+ (string-to-number (match-string 4))))
(mixi-realization-error 'cannot-find-time event))
- (if (string-match mixi-event-title-regexp buffer)
- (mixi-event-set-title event (match-string 2 buffer))
+ (if (re-search-forward mixi-event-title-regexp nil t)
+ (mixi-event-set-title event (match-string 2))
(mixi-realization-error 'cannot-find-title event))
- (if (string-match mixi-event-owner-regexp buffer)
+ (if (re-search-forward mixi-event-owner-regexp nil t)
(mixi-event-set-owner event
- (mixi-make-friend (match-string 2 buffer)
- (match-string 3 buffer)))
- (if (string-match mixi-event-owner-seceded-regexp buffer)
+ (mixi-make-friend (match-string 2)
+ (match-string 3)))
+ (if (re-search-forward mixi-event-owner-seceded-regexp nil t)
(mixi-event-set-owner event
- (mixi-make-friend nil
- (match-string 2 buffer)))
+ (mixi-make-friend nil (match-string 2)))
(mixi-realization-error 'cannot-find-owner event)))
- (if (string-match mixi-event-date-regexp buffer)
- (mixi-event-set-date event (match-string 6 buffer))
+ (if (re-search-forward mixi-event-date-regexp nil t)
+ (mixi-event-set-date event (match-string 6))
(mixi-realization-error 'cannot-find-date event))
- (if (string-match mixi-event-place-regexp buffer)
- (mixi-event-set-place event (match-string 6 buffer))
+ (if (re-search-forward mixi-event-place-regexp nil t)
+ (mixi-event-set-place event (match-string 6))
(mixi-realization-error 'cannot-find-place event))
- (if (string-match mixi-event-detail-regexp buffer)
- (mixi-event-set-detail event (match-string 6 buffer))
+ (if (re-search-forward mixi-event-detail-regexp nil t)
+ (mixi-event-set-detail event (match-string 6))
(mixi-realization-error 'cannot-find-detail event))
- (when (string-match mixi-event-limit-regexp buffer)
+ (when (re-search-forward mixi-event-limit-regexp nil t)
(mixi-event-set-limit
- event (encode-time 0 0 0 (string-to-number (match-string 8 buffer))
- (string-to-number (match-string 7 buffer))
- (string-to-number (match-string 6 buffer)))))
- (if (string-match mixi-event-members-regexp buffer)
- (mixi-event-set-members event (match-string 6 buffer))
+ event (encode-time 0 0 0 (string-to-number (match-string 8))
+ (string-to-number (match-string 7))
+ (string-to-number (match-string 6)))))
+ (if (re-search-forward mixi-event-members-regexp nil t)
+ (mixi-event-set-members event (match-string 6))
(mixi-realization-error 'cannot-find-members event)))
(mixi-object-touch event)))
("comment_body" . ,content)))
(setq fields `(("comment" . ,content))))
(with-mixi-post-form (funcall page parent) fields
- (if (string-match mixi-post-key-regexp buffer)
- (setq post-key (match-string 1 buffer))
+ (if (re-search-forward mixi-post-key-regexp nil t)
+ (setq post-key (match-string 1))
(mixi-post-error 'cannot-find-key parent)))
(if (mixi-diary-p parent)
(setq fields
("comment" . ,content)
("submit" . "confirm"))))
(with-mixi-post-form (funcall page parent) fields
- (unless (string-match mixi-post-succeed-regexp buffer)
+ (unless (re-search-forward mixi-post-succeed-regexp nil t)
(mixi-post-error 'cannot-find-succeed parent)))))
;; Message object.
"Realize a MESSAGE."
(unless (mixi-object-realized-p message)
(with-mixi-retrieve (mixi-message-page message)
- (if (string-match mixi-message-owner-regexp buffer)
+ (if (re-search-forward mixi-message-owner-regexp nil t)
(mixi-message-set-owner message
- (mixi-make-friend (match-string 2 buffer)
- (match-string 3 buffer)))
+ (mixi-make-friend (match-string 2)
+ (match-string 3)))
(mixi-realization-error 'cannot-find-owner message))
- (if (string-match mixi-message-title-regexp buffer)
- (mixi-message-set-title message (match-string 2 buffer))
+ (if (re-search-forward mixi-message-title-regexp nil t)
+ (mixi-message-set-title message (match-string 2))
(mixi-realization-error 'cannot-find-title message))
- (if (string-match mixi-message-time-regexp buffer)
+ (if (re-search-forward mixi-message-time-regexp nil t)
(mixi-message-set-time
- message (encode-time 0 (string-to-number (match-string 6 buffer))
- (string-to-number (match-string 5 buffer))
- (string-to-number (match-string 4 buffer))
- (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))))
+ message (encode-time 0 (string-to-number (match-string 6))
+ (string-to-number (match-string 5))
+ (string-to-number (match-string 4))
+ (string-to-number (match-string 3))
+ (string-to-number (match-string 2))))
(mixi-realization-error 'cannot-find-time message))
- (if (string-match mixi-message-content-regexp buffer)
- (mixi-message-set-content message (match-string 1 buffer))
+ (if (re-search-forward mixi-message-content-regexp nil t)
+ (mixi-message-set-content message (match-string 1))
(mixi-realization-error 'cannot-find-content message)))
(mixi-object-touch message)))
("submit" . "main")))
post-key)
(with-mixi-post-form (mixi-post-message-page friend) fields
- (if (string-match mixi-post-message-key-regexp buffer)
- (setq post-key (match-string 1 buffer))
+ (if (re-search-forward mixi-post-message-key-regexp nil t)
+ (setq post-key (match-string 1))
(mixi-post-error 'cannot-find-key friend)))
(setq fields `(("post_key" . ,post-key)
("subject" . ,title)
("yes" . "¡¡Á÷¡¡¿®¡¡")
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-message-page friend) fields
- (unless (string-match mixi-post-message-succeed-regexp buffer)
+ (unless (re-search-forward mixi-post-message-succeed-regexp nil t)
(mixi-post-error 'cannot-find-succeed friend)))))
;; Introduction object.
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realized-p news)
(with-mixi-retrieve (mixi-news-page news)
- (if (string-match mixi-news-title-regexp buffer)
- (mixi-news-set-title news (match-string 1 buffer))
+ (if (re-search-forward mixi-news-title-regexp nil t)
+ (mixi-news-set-title news (match-string 1))
(mixi-realization-error 'cannot-find-title news))
- (if (string-match mixi-news-media-time-regexp buffer)
+ (if (re-search-forward mixi-news-media-time-regexp nil t)
(progn
- (mixi-news-set-media news (match-string 1 buffer))
+ (mixi-news-set-media news (match-string 1))
(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))))
+ (month-of-item (string-to-number (match-string 2))))
(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))
+ news (encode-time 0 (string-to-number (match-string 5))
+ (string-to-number (match-string 4))
+ (string-to-number (match-string 3))
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))
+ (if (re-search-forward mixi-news-content-regexp nil t)
+ (mixi-news-set-content news (match-string 1))
(mixi-realization-error 'cannot-find-content news)))
(mixi-object-touch news)))