* mixi.el (mixi-save-cache): Use while-loop instead of `mapc'.
(mixi-load-cache): Ditto.
* sb-mixi.el (shimbun-mixi-get-headers): Ditto.
(shimbun-mixi-comment-article): Ditto.
* mixi-atom.el (mixi-make-atom-entries): Ditto.
* riece-mixi.el (riece-mixi-check): Ditto.
+2007-03-07 OHASHI Akira <bg66@koka-in.org>
+
+ * riece-mixi.el (riece-mixi-display-message-function): Simplify.
+
+ * mixi.el (mixi-save-cache): Use while-loop instead of `mapc'.
+ (mixi-load-cache): Ditto.
+ * sb-mixi.el (shimbun-mixi-get-headers): Ditto.
+ (shimbun-mixi-comment-article): Ditto.
+ * mixi-atom.el (mixi-make-atom-entries): Ditto.
+ * riece-mixi.el (riece-mixi-check): Ditto.
+
2007-03-06 OHASHI Akira <bg66@koka-in.org>
* riece-mixi.el (riece-mixi-reply-to-only-me): New user option.
(concat entries (mixi-make-atom-entry object)))
(when (mixi-parent-p object)
(let ((comments (mixi-get-comments object range)))
- (mapc (lambda (comment)
- (setq entries
- (concat entries
- (mixi-make-atom-entry comment))))
- comments))))
- objects)
+ (while comments
+ (setq entries
+ (concat entries
+ (mixi-make-atom-entry (car comments))))
+ (setq comments (cdr comments))))))
+ objects)
entries))
;;;###autoload
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")
-;; (mapc (lambda (comment)
-;; (let ((from (mixi-friend-nick
-;; (mixi-comment-owner comment)))
-;; (subject (concat "Re: " subject))
-;; (date (format-time-string
-;; format (mixi-comment-time comment)))
-;; (body (mixi-remove-markup
-;; (mixi-comment-content comment))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-comments diary range))))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n")
+;; (let ((comments (mixi-get-comments diary range)))
+;; (while comments
+;; (let* ((comment (car comments))
+;; (from (mixi-friend-nick (mixi-comment-owner comment)))
+;; (subject (concat "Re: " subject))
+;; (date (format-time-string format
+;; (mixi-comment-time comment)))
+;; (body (mixi-remove-markup (mixi-comment-content comment))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq comments (cdr comments)))))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
(unless (file-directory-p cache-directory)
(make-directory cache-directory t))
(let ((caches (apropos-internal mixi-cache-regexp 'boundp)))
- (mapc (lambda (symbol)
- (with-temp-file (expand-file-name
- (substring (symbol-name symbol)
- (length mixi-object-prefix))
- cache-directory)
- (let ((coding-system-for-write mixi-coding-system)
- (cache (symbol-value symbol)))
- (insert "#s(hash-table size "
- (number-to-string (hash-table-count cache))
- " test equal data (\n")
- (maphash
- (lambda (key value)
- (let (print-level print-length)
- (insert (prin1-to-string key) " "
- (prin1-to-string value) "\n")))
- cache))
- (insert "))")))
- caches))))
+ (while caches
+ (with-temp-file (expand-file-name
+ (substring (symbol-name (car caches))
+ (length mixi-object-prefix))
+ cache-directory)
+ (let ((coding-system-for-write mixi-coding-system)
+ (cache (symbol-value (car caches))))
+ (insert "#s(hash-table size "
+ (number-to-string (hash-table-count cache))
+ " test equal data (\n")
+ (maphash
+ (lambda (key value)
+ (let (print-level print-length)
+ (insert (prin1-to-string key) " "
+ (prin1-to-string value) "\n")))
+ cache))
+ (insert "))"))
+ (setq caches (cdr caches))))))
;; stolen (and modified) from lsdb.el
(defun mixi-read-cache (&optional marker)
;; FIXME: Load friend and community first.
(let ((files (directory-files cache-directory t
mixi-cache-file-regexp)))
- (mapc (lambda (file)
- (let ((buffer (find-file-noselect file)))
- (unwind-protect
- (save-excursion
- (set-buffer buffer)
- (goto-char (point-min))
- (re-search-forward "^#s(")
- (goto-char (match-beginning 0))
- (mixi-read-cache (point-marker)))
- (kill-buffer buffer))))
- files)))))
+ (while files
+ (let ((buffer (find-file-noselect (car files))))
+ (unwind-protect
+ (save-excursion
+ (set-buffer buffer)
+ (goto-char (point-min))
+ (re-search-forward "^#s(")
+ (goto-char (match-beginning 0))
+ (mixi-read-cache (point-marker)))
+ (kill-buffer buffer)))
+ (setq files (cdr files)))))))
;; Friend object.
(defvar mixi-friend-cache (make-hash-table :test 'equal))
(defun riece-mixi-display-message-function (message)
(when (and (get 'riece-mixi 'riece-addon-enabled)
- (or (not riece-mixi-reply-to-only-me)
- (and riece-mixi-reply-to-only-me
- (riece-message-own-p message)))
+ (or (riece-message-own-p message)
+ (not riece-mixi-reply-to-only-me))
(string-match riece-mixi-regexp (riece-message-text message)))
(let* ((url (match-string 1 (riece-message-text message)))
(object (mixi-make-object-from-url url)))
(when (member target riece-current-channels)
(let ((objects (mixi-make-objects url-or-function
riece-mixi-check-range)))
- (mapc (lambda (object)
- (when (mixi-parent-p object)
- (let ((comments (mixi-get-comments
- object riece-mixi-check-range)))
- (mapc (lambda (comment)
- (let ((time (mixi-object-time comment)))
- (when (mixi-time-less-p
- riece-mixi-last-check time)
- (riece-mixi-send-object-with-url
- target comment))))
- comments)))
- (let ((time (mixi-object-time object)))
- (when (mixi-time-less-p riece-mixi-last-check
- time)
- (riece-mixi-send-object-with-url target
- object))))
- objects)))))
+ (while objects
+ (let ((object (car objects)))
+ (when (mixi-parent-p object)
+ (let ((comments (mixi-get-comments
+ object riece-mixi-check-range)))
+ (while comments
+ (let ((time (mixi-object-time (car comments))))
+ (when (mixi-time-less-p riece-mixi-last-check
+ time)
+ (riece-mixi-send-object-with-url
+ target (car comments))))
+ (setq comments (cdr comments)))))
+ (let ((time (mixi-object-time object)))
+ (when (mixi-time-less-p riece-mixi-last-check time)
+ (riece-mixi-send-object-with-url target object))))
+ (setq objects (cdr objects)))))))
riece-mixi-check-alist)
(setq riece-mixi-last-check (current-time))))
mixi-reply-to)
(defun shimbun-mixi-get-headers (shimbun objects &optional range)
- (when objects
- (let (headers)
- (catch 'stop
- (mapc (lambda (object)
- (when (mixi-object-p object)
- (let ((class (mixi-object-class object)))
- (when (mixi-parent-p object)
- (let ((comments (mixi-get-comments object range)))
- (mapc (lambda (header)
- (push header headers))
- (shimbun-mixi-get-headers shimbun
- comments))))
- (let ((id (mixi-make-message-id object)))
- (when (and (eq class 'mixi-comment)
- (shimbun-search-id shimbun id))
- (throw 'stop nil))
- (push
- (shimbun-create-header
- 0
- (mixi-make-title object
- (string-match
- "^new-"
- (shimbun-current-group-internal
- shimbun)))
- (mixi-make-author object)
- (mixi-make-date object)
- id
- (if (eq class 'mixi-comment)
- (mixi-make-message-id
- (mixi-comment-parent object))
- "")
- 0 0
- (mixi-make-url object))
- headers)
- (when (eq class 'mixi-comment)
- (puthash id (mixi-comment-content object)
- (shimbun-mixi-comment-cache-internal
- shimbun)))))))
- objects))
- headers)))
+ (let (headers)
+ (catch 'stop
+ (while objects
+ (let ((object (car objects)))
+ (when (mixi-parent-p object)
+ (let* ((comments (mixi-get-comments object range))
+ (comment-headers (shimbun-mixi-get-headers shimbun
+ comments)))
+ (while comment-headers
+ (push (car comment-headers) headers)
+ (setq comment-headers (cdr comment-headers)))))
+ (let ((class (mixi-object-class object))
+ (id (mixi-make-message-id object)))
+ (when (and (eq class 'mixi-comment)
+ (shimbun-search-id shimbun id))
+ (throw 'stop nil))
+ (push
+ (shimbun-create-header
+ 0
+ (mixi-make-title object (string-match
+ "^new-"
+ (shimbun-current-group-internal
+ shimbun)))
+ (mixi-make-author object)
+ (mixi-make-date object)
+ id
+ (if (eq class 'mixi-comment)
+ (mixi-make-message-id (mixi-comment-parent object))
+ "")
+ 0 0
+ (mixi-make-url object))
+ headers)
+ (when (eq class 'mixi-comment)
+ (puthash id (mixi-comment-content object)
+ (shimbun-mixi-comment-cache-internal shimbun)))))
+ (setq objects (cdr objects))))
+ headers))
(luna-define-method shimbun-get-headers ((shimbun shimbun-mixi)
&optional range)
(cache (shimbun-mixi-comment-cache-internal shimbun))
(article (gethash message-id cache)))
(unless (stringp article)
- (let ((parent (mixi-make-object-from-url url)))
- (mapc (lambda (comment)
- (let ((id (mixi-make-message-id comment))
- (content (mixi-comment-content comment)))
- (puthash id content cache)
- (when (string= id message-id)
- (setq article content))))
- (mixi-get-comments parent))))
+ (let* ((parent (mixi-make-object-from-url url))
+ (comments (mixi-get-comments parent)))
+ (while comments
+ (let ((id (mixi-make-message-id (car comments)))
+ (content (mixi-comment-content (car comments))))
+ (puthash id content cache)
+ (when (string= id message-id)
+ (setq article content)))
+ (setq comments (cdr comments)))))
article))
(luna-define-method shimbun-article ((shimbun shimbun-mixi)