* riece-mixi.el (riece-mixi-display-message-function): Simplify.
authorbg66 <bg66>
Wed, 7 Mar 2007 09:04:40 +0000 (09:04 +0000)
committerbg66 <bg66>
Wed, 7 Mar 2007 09:04:40 +0000 (09:04 +0000)
* 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.

ChangeLog
mixi-atom.el
mixi.el
riece-mixi.el
sb-mixi.el

index 1e82a1e..0a4335b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index add935b..24a79e3 100644 (file)
@@ -103,12 +103,12 @@ RANGE is the range for getting articles.  If RANGE is nil, get all articles."
                    (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
diff --git a/mixi.el b/mixi.el
index 1965551..835905f 100644 (file)
--- a/mixi.el
+++ b/mixi.el
 ;;       (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)))
@@ -694,24 +698,24 @@ Increase this value when unexpected error frequently occurs."
     (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)
@@ -747,17 +751,17 @@ Increase this value when unexpected error frequently occurs."
       ;; 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))
index 6cb8748..c0a38c8 100644 (file)
@@ -108,9 +108,8 @@ of mixi object."
 
 (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)))
@@ -136,23 +135,22 @@ If they exist, send them as notice to the corresponding channel."
              (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))))
 
index f790d37..0296884 100644 (file)
@@ -143,46 +143,43 @@ of mixi object."
   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)
@@ -199,14 +196,15 @@ of mixi object."
         (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)