* wl-folder.el (wl-folder-init-hook): New hook.
[elisp/wanderlust.git] / wl / wl-folder.el
index 188bd68..c2e374c 100644 (file)
   (require 'wl)
   (require 'elmo-nntp))
 
+(defcustom wl-folder-init-hook nil
+  "A hook called after folder initialization is finished."
+  :type 'hook
+  :group 'wl)
+
 (defvar wl-folder-buffer-name "Folder")
 (defvar wl-folder-entity nil)          ; desktop entity.
 (defvar wl-folder-group-alist nil)     ; opened or closed
@@ -816,8 +821,12 @@ Optional argument ARG is repeart count."
          (wl-folder-sync-entity entity)
          (setq nums (elmo-folder-diff folder)))
       (unless wl-folder-notify-deleted
-       (setq unsync (if (and (car nums) (> 0 (car nums))) 0 (car nums)))
-       (setq nomif (if (and (car nums) (> 0 (cdr nums))) 0 (cdr nums)))
+       (setq unsync (if (car nums)
+                        (max 0 (car nums))
+                      nil))
+       (setq nomif (if (cdr nums)
+                       (max 0 (cdr nums))
+                     nil))
        (setq nums (cons unsync nomif)))
       (setq unread (or ;; If server diff, All unreads are
                        ; treated as unsync.
@@ -827,7 +836,6 @@ Optional argument ARG is repeart count."
                    (wl-summary-count-unread (elmo-msgdb-mark-load
                                              (elmo-folder-msgdb-path
                                               folder)))))
-      (setq unread (min unread (- (or (cdr nums) 0) (or (car nums) 0))))
       (when new (setq unread (- unread new)))
       (wl-folder-entity-hashtb-set wl-folder-entity-hashtb entity
                                   (list (or new (car nums))
@@ -837,8 +845,10 @@ Optional argument ARG is repeart count."
     (setq wl-folder-info-alist-modified t)
     (sit-for 0)
     (list (if wl-folder-notify-deleted
-             (car nums)
-           (or new (max (or (car nums) 0)))) unread (cdr nums))))
+             (or new (car nums) 0)
+           (max 0 (or new (car nums) 0)))
+         unread
+         (cdr nums))))
 
 (defun wl-folder-check-entity-async (entity &optional auto)
   (let ((elmo-nntp-groups-async t)
@@ -1991,7 +2001,8 @@ Entering Folder mode calls the value of `wl-folder-mode-hook'."
   (interactive)
   (if wl-use-acap
       (wl-acap-init)
-    (funcall wl-folder-init-function)))
+    (funcall wl-folder-init-function))
+  (run-hooks 'wl-folder-init-hook))
 
 (defun wl-local-folder-init ()
   "Initialize local folder."