nndraft.el (nndraft-update-unread-articles): Don't show group having no unread articl...
[gnus] / lisp / nndraft.el
index 0063488..459778b 100644 (file)
@@ -161,6 +161,25 @@ are generated if and only if they are also in `message-draft-headers'.")
      (message-headers-to-generate
       nndraft-required-headers message-draft-headers nil))))
 
+(defun nndraft-update-unread-articles ()
+  "Update groups' unread articles in the group buffer."
+  (nndraft-request-list)
+  (with-current-buffer gnus-group-buffer
+    (let* ((groups (mapcar (lambda (elem)
+                            (gnus-group-prefixed-name (car elem)
+                                                      (list 'nndraft "")))
+                          (nnmail-get-active)))
+          (gnus-group-marked (copy-sequence groups))
+          (inhibit-read-only t))
+      (gnus-group-get-new-news-this-group nil t)
+      (dolist (group groups)
+       (unless (and gnus-permanently-visible-groups
+                    (string-match gnus-permanently-visible-groups
+                                  group))
+         (gnus-group-goto-group group)
+         (when (zerop (gnus-group-group-unread))
+           (gnus-delete-line)))))))
+
 (deffoo nndraft-request-associate-buffer (group)
   "Associate the current buffer with some article in the draft group."
   (nndraft-open-server "")
@@ -182,6 +201,10 @@ are generated if and only if they are also in `message-draft-headers'.")
                  'write-contents-hooks)))
       (gnus-make-local-hook hook)
       (add-hook hook 'nndraft-generate-headers nil t))
+    (gnus-make-local-hook 'after-save-hook)
+    (add-hook 'after-save-hook 'nndraft-update-unread-articles nil t)
+    (message-add-action '(nndraft-update-unread-articles)
+                       'exit 'postpone 'kill)
     article))
 
 (deffoo nndraft-request-group (group &optional server dont-check info)