* sb-mixi.el (shimbun-get-headers): Use `mixi-bbs-p'.
[elisp/mixi.git] / sb-mixi.el
index 3e4dfe4..2c56b98 100644 (file)
@@ -65,13 +65,8 @@ of mixi object."
   :group 'shimbun
   :type 'integer)
 
-(defcustom shimbun-mixi-get-comment-p t
-  "*If non-nil, get diaries or BBSes together with its comments."
-  :group 'shimbun
-  :type 'boolean)
-
 (defcustom shimbun-mixi-logout-p nil
-  "*If non-ni, Logout from mixi when shimbun server was closed."
+  "*If non-ni, logout from mixi when shimbun server was closed."
   :group 'shimbun
   :type 'boolean)
 
@@ -94,14 +89,23 @@ of mixi object."
 (luna-define-method shimbun-groups ((shimbun shimbun-mixi))
   (mapcar 'car shimbun-mixi-group-alist))
 
-(defun shimbun-mixi-make-subject (object)
+(defun shimbun-mixi-make-subject (shimbun object)
   (let ((class (mixi-object-class object)))
-    (cond ((eq class 'mixi-comment)
-          (concat "Re: " (shimbun-mixi-make-subject
-                          (mixi-comment-parent object))))
-         ((eq class 'mixi-event)
-          (concat "[¥¤¥Ù¥ó¥È] " (mixi-event-title object)))
-         (t (mixi-object-title object)))))
+    (if (eq class 'mixi-comment)
+        (concat "Re: " (shimbun-mixi-make-subject
+                       shimbun (mixi-comment-parent object)))
+      (let ((prefix (when (eq class 'mixi-event) "[¥¤¥Ù¥ó¥È]"))
+           (subject (mixi-object-title object))
+           (suffix (when (string-match
+                          "^new-" (shimbun-current-group-internal shimbun))
+                     (concat " ("
+                             (if (eq class 'mixi-diary)
+                                 (mixi-friend-nick
+                                  (mixi-diary-owner object))
+                               (mixi-community-name
+                                (mixi-bbs-community object)))
+                             ")"))))
+       (concat prefix subject suffix)))))
 
 (defun shimbun-mixi-make-from (object)
   (let ((owner (mixi-object-owner object)))
@@ -175,7 +179,7 @@ of mixi object."
                    (push
                     (shimbun-create-header
                      0
-                     (shimbun-mixi-make-subject object)
+                     (shimbun-mixi-make-subject shimbun object)
                      (shimbun-mixi-make-from object)
                      (shimbun-mixi-make-date object)
                      id
@@ -186,10 +190,8 @@ of mixi object."
                      0 0
                      (shimbun-mixi-make-xref object))
                     headers)
-                   (when (and shimbun-mixi-get-comment-p
-                              (or (eq class 'mixi-diary)
-                                  (eq class 'mixi-topic)
-                                  (eq class 'mixi-event)))
+                   (when (or (eq class 'mixi-diary)
+                             (mixi-bbs-p object))
                      (let ((comments (mixi-get-comments object range)))
                        (mapc (lambda (header)
                                (push header headers))
@@ -216,15 +218,14 @@ of mixi object."
                ((eq class 'mixi-community)
                 (setq objects (mixi-get-bbses object range)))
                ((or (eq class 'mixi-diary)
-                    (eq class 'mixi-topic)
-                    (eq class 'mixi-event))
+                    (mixi-bbs-p object))
                 (setq objects (mixi-get-comments object range)))
                (t (error (concat (symbol-name class)
                                  " is not supported yet.")))))
       (setq objects (funcall url-or-function range)))
     (shimbun-sort-headers (shimbun-mixi-get-headers shimbun objects range))))
 
-(defun shimbun-comment-article (url shimbun header)
+(defun shimbun-mixi-comment-article (url shimbun header)
   (let* ((message-id (shimbun-header-id header))
         (cache (shimbun-mixi-comment-cache-internal shimbun))
         (article (gethash message-id cache)))
@@ -232,7 +233,6 @@ of mixi object."
       (let ((parent (mixi-make-object-from-url url)))
        (mapc (lambda (comment)
                (let ((id (shimbun-mixi-make-message-id comment))
-                     ;; FIXME: Concat parent's information?
                      (content (mixi-comment-content comment)))
                  (puthash id content cache)
                  (when (string= id message-id)
@@ -248,8 +248,8 @@ of mixi object."
        (or (with-temp-buffer
             (let* ((url (shimbun-article-url shimbun header))
                    (article (if (string-match "#comment$" url)
-                                (shimbun-comment-article url shimbun header)
-                              ;; FIXME: Concat community information?
+                                (shimbun-mixi-comment-article
+                                 url shimbun header)
                               (shimbun-mixi-make-body
                                (mixi-make-object-from-url url)))))
               (when (stringp article)