Commit bec35a53 authored by David Byers's avatar David Byers

Keep the unread counter in the membership buffer up-to-date

Detailed changes:
> 	* mship-edit.el (lp--maybe-update-unreads): Zero unreads are
> 	formatted as "", even if there is a read-info on the to-do list.
>
> 	* clienttypes.el (read-list-enter-read-info): Update unreads when
> 	appending unread texts to old read-infos and adding new
> 	read-infos.
>
> 	* view-text.el (lyskom-mark-as-read): Removed the callback. We
> 	update the membership buffer elsewhere.
>
> 	* clienttypes.el (read-list-enter-text): Update unreads in the
> 	membership buffer.
> 	(read-list-delete-text): Update unreads in the membership buffer.
>
> 	* komtypes.el (text-list->memq): New subst.
>
parent 595e3bef
2004-07-18 David Byers <byers@lysator.liu.se>
* mship-edit.el (lp--maybe-update-unreads): Zero unreads are
formatted as "", even if there is a read-info on the to-do list.
* clienttypes.el (read-list-enter-read-info): Update unreads when
appending unread texts to old read-infos and adding new
read-infos.
* view-text.el (lyskom-mark-as-read): Removed the callback. We
update the membership buffer elsewhere.
* clienttypes.el (read-list-enter-text): Update unreads in the
membership buffer.
(read-list-delete-text): Update unreads in the membership buffer.
* komtypes.el (text-list->memq): New subst.
* reading.el (lyskom-membership-list-move): Return non-nil if
moved.
(lyskom-replace-membership): Sort the to-do list if the membership
......
......@@ -172,6 +172,7 @@ Returns t if there was a conference to insert this text into."
(conf-stat->conf-no (read-info->conf-stat read-info))))
(read-info-enter-text-last read-info text-no)
(setq inserted t))))
(when inserted (lp--maybe-update-unreads recipient))
inserted))
......@@ -185,14 +186,17 @@ TEXT-NO may be nil, in which case only empty read-infos on RLIST are removed."
(let* ((prev rlist) ;"Previous" cons-celll
(curr (cdr rlist))) ;Current cons-cell
(while curr
(if text-no
(cond
((let ((type (read-info->type (car curr))))
(when text-no
(cond
((let ((type (read-info->type (car curr))))
; Don't change REVIEW et c.
(memq type lyskom-review-types-list)))
(t ; Do change all other entries.
(let ((tl (read-info->text-list (car curr))))
(text-list->delq tl text-no)))))
(memq type lyskom-review-types-list)))
(t ; Do change all other entries.
(let ((tl (read-info->text-list (car curr))))
(when (text-list->memq tl text-no)
(text-list->delq tl text-no)
(lp--maybe-update-unreads
(conf-stat->conf-no (read-info->conf-stat (car curr)))))))))
;; Delete this element from RLIST if the text-list became or was empty.
......@@ -228,8 +232,9 @@ will be inserted before it."
(read-info-append-text-list
(car (cdr rlist))
(text-list->texts (read-info->text-list read-info)))
(lp--maybe-update-unreads (conf-stat->conf-no conf-stat))
(setq continue nil))
((null (cdr rlist))
(setcdr rlist (list read-info))
(setq continue nil))
......@@ -237,7 +242,11 @@ will be inserted before it."
(setcdr rlist (cons read-info (cdr rlist)))
(setq continue nil))
(t
(setq rlist (cdr rlist)))))))
(setq rlist (cdr rlist)))))
(when (eq type 'CONF)
(lp--maybe-update-unreads (conf-stat->conf-no conf-stat)) )))
(defun read-list-delete-read-info (conf-no rlist)
"Destructively removes all the entries for the conf CONF-NO in RLIST.
......@@ -249,7 +258,6 @@ RLIST is a list of read-info."
(setcdr rlist (cdr (cdr rlist)))
(setq rlist (cdr rlist)))))
(defun read-list-rotate (read-list)
"Put the first element of READ-LIST last in the same list. The second
element will be the new first element."
......
......@@ -764,6 +764,10 @@ The MAPS must be consecutive. No gaps or overlaps are currently allowed."
(length (text-list->texts text-list))))
(text-list->length-internal text-list))
(defsubst text-list->memq (text-list no)
"Return non-nil if TEXT-LIST contains TEXT-NO."
(memq no (text-list->texts text-list)))
(defsubst text-list->delq (text-list no)
"Remove text NO from TEXT-LIST."
(set-text-list->texts-internal text-list (delq no (text-list->texts text-list)))
......
......@@ -498,7 +498,8 @@ Normally there should only be one buffer, but who knows..."
(delete-region (car bounds) (cdr bounds))
(goto-char (car bounds))
(insert (lyskom-format "%#2@%=5#1s"
(if unread (int-to-string unread) "")
(if (and unread (> unread 0))
(int-to-string unread) "")
'(lp--unread t))))))))))
conf-no (lyskom-find-unread conf-no)))
......
......@@ -966,17 +966,13 @@ the client. That is done by lyskom-is-read."
;; (lyskom-member-p (misc-info->recipient-no misc-info))
)
(initiate-mark-as-read 'background
'lyskom-mark-as-read-callback
nil
(misc-info->recipient-no misc-info)
(list (misc-info->local-no misc-info))
text-stat
(misc-info->recipient-no misc-info)
(list (misc-info->local-no misc-info)))))))
(defun lyskom-mark-as-read-callback (result text-stat recipient local-nos)
(lp--maybe-update-unreads recipient))
(defun lyskom-print-header-recpt (conf-no misc)
"Print a line of info about a recipient (or cc-recipient) of a text."
(lyskom-format-insert "%#1s: %#2M <%#3d>\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment