Commit 544fb484 authored by David Byers's avatar David Byers

Bug fixes:

    initiate-get-unread-confs works
    Prioritize kind of works, sometimes
    Fixed bug in kom-review-stack

Improvements:
    Use get-unread-confs at startup to speed things up a lot
    Do not get empty maps at startup
    Smileys at end of texts work :-)
    Passive memberships are almost fully supported
parent 78241233
1999-06-26 David Byers <davby@ida.liu.se>
* prefetch.el, startup.el, async.el: Use get-unread-confs to get
memberships in confs with unreads before
* view-text.el (lyskom-print-text): Moved printing of the newline
after a text to the text body (that way smileys at the end of a
text are done correctly.)
* prioritize.el (lyskom-prioritize-tell-server): Ignore new
membership asyncs.
1999-06-25 David Byers <davby@ida.liu.se>
* lyskom-rest.el (lyskom-visible-membership): Deal with passive
memberships the way they're supposed to be dealt with.
* reading.el (lyskom-add-memberships-to-membership): Don't add
passive memberships.
* review.el (kom-review-stack): Print information about all kinds
of things on the stack, not just review commands.
......
......@@ -255,8 +255,7 @@ this function shall be with current-buffer the BUFFER."
(set-buffer buffer)
(cache-del-pers-stat pers-no)
(cache-del-conf-stat conf-no)
(when (and (eq pers-no lyskom-pers-no)
(not (lyskom-try-get-membership conf-no)))
(when (eq pers-no lyskom-pers-no)
(lyskom-collect 'follow)
(initiate-get-conf-stat 'follow nil conf-no)
(initiate-query-read-texts 'follow nil pers-no conf-no)
......@@ -284,10 +283,37 @@ this function shall be with current-buffer the BUFFER."
membership
pers-no
conf-no)
(when (and membership conf-conf-stat)
(lyskom-format-insert-before-prompt 'have-become-member conf-conf-stat))
(lyskom-add-membership membership conf-no))
;; Are we already members?
(when membership
(let ((cur-mship (lyskom-try-get-membership conf-no t)))
(unless cur-mship
(lyskom-format-insert-before-prompt
(if (membership-type->passive (membership->type membership))
'have-become-passive-member
'have-become-member)
conf-conf-stat))
(cond ((membership-type->passive (membership->type membership))
(lyskom-replace-membership membership lyskom-membership)
(when (eq conf-no lyskom-current-conf)
(set-read-list-empty lyskom-reading-list)
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
lyskom-current-conf 0)
(setq lyskom-current-conf 0))
(read-list-delete-read-info conf-no lyskom-to-do-list)
(lyskom-update-prompt))
;; Already a member. Perhaps the priority changed.
;; Update the cache. The reading list is probably also
;; not quite correct since the priority might have changed
;; FIXME: Maybe fix this.
(cur-mship
(lyskom-replace-membership membership lyskom-membership))
;; Not a member. Completely new. Deal with it.
(t (lyskom-add-membership membership conf-no))))))
(defun lyskom-show-presence (num flag)
......@@ -738,7 +764,15 @@ In that case, just discard this call."
(lyskom-create-text-list (list text-no)))))
(read-list-enter-read-info info lyskom-to-do-list)
(if (= lyskom-current-conf (conf-stat->conf-no recipient))
(read-list-enter-first info lyskom-reading-list)))))
(read-list-enter-first info lyskom-reading-list)))
;; We don't have the membership yet. Treat it as an unread conf
;; and prefetch it. This might result in two prefetches of the
;; same conference, but the prefetch should be able to deal with
;; that.
(unless membership
(lyskom-prefetch-one-membership (conf-stat->conf-no recipient)
lyskom-pers-no))))
(lyskom-set-mode-line))))
......
......@@ -468,8 +468,7 @@ Also adds to lyskom-to-do-list."
(if membership
(progn
(lyskom-insert-membership membership lyskom-membership)
(lyskom-prefetch-map conf-no
membership)
(lyskom-prefetch-map conf-no membership)
(lyskom-run-hook-with-args 'lyskom-add-membership-hook
membership))
(lyskom-insert-string 'conf-does-not-exist)))
......@@ -1087,7 +1086,7 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
((null conf-stat) ;+++ annan felhantering
(lyskom-insert-string 'cant-get-conf-stat))
((or lyskom-is-administrator
(lyskom-get-membership (conf-stat->supervisor conf-stat))
(lyskom-get-membership (conf-stat->supervisor conf-stat) t)
(= lyskom-pers-no (conf-stat->conf-no conf-stat)))
(lyskom-dispatch-edit-text
lyskom-proc
......@@ -1155,7 +1154,7 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
((null conf-stat)
(lyskom-insert-string 'cant-get-conf-stat))
((or lyskom-is-administrator
(lyskom-get-membership (conf-stat->supervisor conf-stat)))
(lyskom-get-membership (conf-stat->supervisor conf-stat) t))
;; This works like a dispatch. No error handling.
(lyskom-set-conf-motd 0 (conf-stat->conf-no conf-stat)))
(t
......@@ -1188,7 +1187,7 @@ back on lyskom-to-do-list."
Allowed conferences are conferences and the mailboxes you are
member of."
(if (numberp conf) (setq conf (blocking-do 'get-conf-stat conf)))
(let ((membership (lyskom-get-membership (conf-stat->conf-no conf))))
(let ((membership (lyskom-get-membership (conf-stat->conf-no conf) t)))
(lyskom-format-insert 'go-to-conf
conf)
......@@ -1211,7 +1210,7 @@ member of."
lyskom-pers-no)
(lyskom-do-go-to-conf conf
(lyskom-get-membership
(conf-stat->conf-no conf)))
(conf-stat->conf-no conf) t))
(lyskom-insert-string 'nope))
(lyskom-insert-string 'no-ok))))))
......@@ -1380,7 +1379,7 @@ If you are not member in the conference it will be flagged with an asterisk."
(lyskom-default-button 'conf conf-no)
conf-no
(if (lyskom-get-membership conf-no)
32 ?*)
?\ ?*)
conf-no))
;;; ================================================================
......
......@@ -725,7 +725,12 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(sum 0)
(mship-confs (and (numberp num-arg)
(< num-arg 1)
(mapcar 'membership->conf-no lyskom-membership)))
(delq nil
(mapcar (lambda (el)
(when (not (membership-type->passive
(membership->type el)))
(membership->conf-no el)))
lyskom-membership))))
(nconfs 0))
(when num-arg
(lyskom-format-insert 'list-unread-with-n-unread num-arg))
......
......@@ -708,7 +708,7 @@ Based on ispell-message."
((eq lyskom-pers-no (conf-stat->conf-no conf-stat)) t)
((eq lyskom-pers-no (conf-stat->supervisor conf-stat)) t)
((eq 0 (conf-stat->supervisor conf-stat)) nil)
((lyskom-get-membership (conf-stat->conf-no conf-stat)) t)
((lyskom-get-membership (conf-stat->conf-no conf-stat) t) t)
((lyskom-is-supervisor
(blocking-do 'get-conf-stat (conf-stat->supervisor conf-stat))
(cons (conf-stat->conf-no conf-stat) memo)))))
......
......@@ -47,7 +47,10 @@
"Create a conf-no-list from all parameters."
(cons
'CONF-NO-LIST
(apply 'vector conf-nos)))
(vector
(cond ((vectorp conf-nos) (append conf-nos nil))
(t conf-nos)))))
;;; Selector:
......
......@@ -507,7 +507,7 @@ If CONF is nil, check the first conf on the to-do list."
(read-info->conf-stat
(read-list->first lyskom-to-do-list))))
(mship (and conf-stat
(lyskom-get-membership (conf-stat->conf-no conf-stat))))
(lyskom-get-membership (conf-stat->conf-no conf-stat) t)))
(type nil)
(continue t))
(when (and conf-stat mship)
......@@ -675,37 +675,46 @@ CONF can be a a conf-stat or a string."
;;; +++Where should this be moved???
(defun lyskom-try-get-membership (conf-no)
(defun lyskom-try-get-membership (conf-no &optional want-passive)
"Returns non-nil if conference CONF-NO is present on lyskom-membership.
The value is actually the membership for the conference.
For foreground functions, lyskom-get-membership should probably be used
instead.
This function does not use blocking-do."
This function does not use blocking-do.
Optional argument mship-list is the membership list to look in."
(let ((list lyskom-membership)
(found nil))
(while (and (not found) (not (null list)))
(if (= conf-no (membership->conf-no (car list)))
(setq found (car list)))
(setq list (cdr list)))
found))
(if (and found
(or want-passive
(not (membership-type->passive (membership->type found)))))
found
nil)))
(defun lyskom-get-membership (conf-no)
(defun lyskom-get-membership (conf-no &optional want-passive)
"Get the membership for CONF-NO, or nil if the user is not a member of
CONF-NO.
If the membership list is not fully prefetched and the membership can't be
found in lyskom-membership, a blocking call to the server is made."
(or (lyskom-try-get-membership conf-no)
(or (lyskom-try-get-membership conf-no want-passive)
(and (not (lyskom-membership-is-read))
(let ((membership
(blocking-do 'query-read-texts lyskom-pers-no conf-no)))
(if (and membership (lyskom-visible-membership membership))
(lyskom-add-membership membership conf-no))
membership))))
(if (and membership
(or want-passive
(not (membership-type->passive
(membership->type membership)))))
membership
nil)))))
;;;; ================================================================
......@@ -1536,8 +1545,6 @@ Note that it is not allowed to use deferred insertions in the text."
(let ((level 1))
(while (> level 0)
(setq tmp (substring (format-state->format-string format-state)
(format-state->start format-state)))
(if (null (string-match "\\(%\\[\\|%\\]\\)"
(format-state->format-string format-state)
(format-state->start format-state)))
......@@ -2878,7 +2885,7 @@ lyskom-session-priority and nil otherwise.
If MEMBERSHIPs prioriy is 0, it always returns nil."
(let ((priority (membership->priority membership)))
(and (> priority 0)
(and (not (membership-type->passive (membership->type membership)))
(>= priority lyskom-session-priority))))
;;; The filter.
......
......@@ -704,9 +704,9 @@ than 0. Args: ITEMS-TO-PARSE PRE-FETCHED. Returns -1 if ITEMS-TO-PARSE is
(defun lyskom-parse-conf-no-list ()
"Parse result from functions that return conf-no-list"
(apply 'lyskom-create-conf-no-list
(lyskom-parse-vector (lyskom-parse-num)
'lyskom-parse-num)))
(lyskom-create-conf-no-list
(lyskom-parse-vector (lyskom-parse-num)
'lyskom-parse-num)))
(defun lyskom-parse-conf-list ()
......
......@@ -231,14 +231,19 @@ prefetched the prefetch is not done."
(defun lyskom-prefetch-membership (pers-no &optional queue)
"+++"
;; h{mtar medlemsskapet i sm} delar
;; och d{refter conf-stat f|r m|tena
"h{mtar medlemsskapet i sm} delar och d{refter conf-stat f|r m|tena"
(if queue
(lyskom-queue-enter queue (cons 'MEMBERSHIP pers-no))
(lyskom-stack-push lyskom-prefetch-stack (cons 'MEMBERSHIP pers-no)))
(lyskom-continue-prefetch))
(defun lyskom-prefetch-one-membership (conf-no pers-no &optional queue)
(if queue
(lyskom-queue-enter queue (list 'ONE-MEMBERSHIP conf-no pers-no))
(lyskom-stack-push lyskom-prefetch-stack (list 'ONE-MEMBERSHIP
conf-no pers-no)))
(lyskom-continue-prefetch))
(defun lyskom-prefetch-map (conf-no membership &optional queue)
"Prefetches a map for conf CONFNO."
......@@ -424,7 +429,7 @@ Return t if an element was prefetched, otherwise return nil."
;; A complex request?
((and (listp element)
(memq (car element)
'(TEXTAUTH TEXT-ALL TEXTTREE
'(TEXTAUTH TEXT-ALL TEXTTREE ONE-MEMBERSHIP
CONFSTATFORMAP MAP MARKS
MEMBERSHIP WHOBUFFER TEXTS)))
(let ((queue (lyskom-queue-create)))
......@@ -475,6 +480,7 @@ Return t if an element was prefetched, otherwise return nil."
(defun lyskom-prefetch-one-request (request queue)
"Prefetch REQUEST. If the request is complex, put the resulting requests on QUEUE."
; (message "Prefetch: %s" request)
(cond
((eq (car request) 'CONFSTAT)
(initiate-get-conf-stat 'prefetch
......@@ -496,6 +502,15 @@ Return t if an element was prefetched, otherwise return nil."
((eq (car request) 'TEXTTREE)
(initiate-get-text-stat 'prefetch 'lyskom-prefetch-texttree-handler
(cdr request) queue))
((eq (car request) 'ONE-MEMBERSHIP)
(initiate-query-read-texts 'prefetch
'lyskom-prefetch-read-texts-handler
(elt request 2)
(elt request 1)
(elt request 1)
queue))
((eq (car request) 'MEMBERSHIP)
(if (numberp lyskom-membership-is-read) ; Are we done?
(initiate-get-part-of-membership
......@@ -612,18 +627,43 @@ Put the requests on QUEUE."
(lyskom-start-prefetch))
(defun lyskom-prefetch-read-texts-handler (membership pers-no queue)
(lyskom-stop-prefetch)
(-- lyskom-pending-prefetch)
(when membership
(unless (lyskom-try-get-membership (membership->conf-no membership) t)
(lyskom-add-memberships-to-membership (list membership))
(when (and (lyskom-visible-membership membership)
(lyskom-prefetch-map (membership->conf-no membership)
membership
queue)))))
(lyskom-start-prefetch))
(defun lyskom-prefetch-membership-handler (memberships pers-no queue)
"Handle the return of the membership prefetch call."
(lyskom-stop-prefetch)
(let ((size (length memberships))
(i 0))
(i 0)
(old-mships (mapcar (lambda (mship)
(and (lyskom-try-get-membership
(membership->conf-no mship))
(membership->conf-no mship)))
memberships)))
(lyskom-add-memberships-to-membership memberships)
(while (< i size)
(let ((membership (aref memberships i)))
(if (lyskom-visible-membership membership)
(lyskom-prefetch-map (membership->conf-no membership)
membership
queue)))
;;; Commented out 1999-06-26 byers
;;; This should not be necessary since we know that all of these
;;; maps were empty when we started the client. Texts created after
;;; the client was started should end up in the reading list anyway
;;; 'cuase they generate asynchronous messages.
;;; (if (and (lyskom-visible-membership membership)
;;; (not (memq (membership->conf-no membership) old-mships)))
;;; (lyskom-prefetch-map (membership->conf-no membership)
;;; membership
;;; queue))
)
(++ i))
(if (and (numberp lyskom-membership-is-read)
(< (length memberships) lyskom-fetch-membership-length))
......
......@@ -75,7 +75,7 @@
;;;
(defun make-prioritize-entry (prio conf-stat membership)
(vector prio conf-stat nil nil membership))
(vector prio conf-stat nil membership))
(defun prioritize-entry->priority (el)
(aref el 0))
......@@ -721,6 +721,7 @@ of conferences you are a member of."
(string (concat (lyskom-mode-name-from-host)
" prioritize: "
lyskom-server-name)))
(setq membership-list (listify-vector membership-list))
(set-buffer tmp-buffer)
(make-local-variable 'lyskom-pers-no)
(make-local-variable 'lyskom-prioritize-entry-list)
......@@ -737,7 +738,8 @@ of conferences you are a member of."
'prioritize
'lyskom-prioritize-handle-get-conf-stat
(membership->conf-no memb-ship)
collector))
collector
))
(lyskom-wait-queue 'prioritize)
......@@ -759,9 +761,10 @@ of conferences you are a member of."
(lyskom-end-of-command)))))
(defun lyskom-prioritize-handle-get-conf-stat (conf-stat collector)
(let* ((membership (lyskom-get-membership
(conf-stat->conf-no conf-stat)))
(defun lyskom-prioritize-handle-get-conf-stat (conf-stat
collector)
(let* ((membership (lyskom-try-get-membership
(conf-stat->conf-no conf-stat) t))
(tmp (make-prioritize-entry
(membership->priority
membership)
......@@ -859,16 +862,17 @@ only tell server about that entry."
(save-excursion
(set-buffer lyskom-buffer)
(set-membership->priority
(lyskom-get-membership conf-no)
(lyskom-get-membership conf-no t)
(prioritize-entry->priority entry))
(initiate-add-member 'priority
'lyskom-prioritize-handler
conf-no
lyskom-pers-no
(prioritize-entry->priority entry)
entry-number
(membership->type
(prioritize-entry->membership entry))))))))
(lyskom-ignoring-async (18)
(initiate-add-member 'priority
'lyskom-prioritize-handler
conf-no
lyskom-pers-no
(prioritize-entry->priority entry)
entry-number
(membership->type
(prioritize-entry->membership entry)))))))))
......
......@@ -62,6 +62,7 @@ If an item of the membership is already read and entered in the
lyskom-membership list then this item is not entered."
(let ((list (listify-vector memberships)))
(while list
;; If membership is already added or passive, don't add it
(if (memq (membership->conf-no (car list))
(mapcar (function membership->conf-no) lyskom-membership))
nil
......
......@@ -1174,7 +1174,7 @@ end."
(read-list->all-entries lyskom-reading-list))
(cond (lyskom-current-conf
(lyskom-format-insert 'you-have-no-unreads lyskom-current-conf))
(lyskom-insert 'not-reading-anywhere))))
(t (lyskom-insert 'not-reading-anywhere)))))
......
......@@ -533,12 +533,17 @@ This is called at login and after prioritize and set-unread."
(setq lyskom-membership nil)
(setq lyskom-to-do-list (lyskom-create-read-list))
(setq lyskom-reading-list (lyskom-create-read-list))
(lyskom-reset-prefetch)
(lyskom-start-prefetch)
(let ((unreads (blocking-do 'get-unread-confs lyskom-pers-no)))
(lyskom-traverse conf-no (conf-no-list->conf-nos unreads)
(lyskom-prefetch-one-membership conf-no lyskom-pers-no)))
(lyskom-prefetch-membership lyskom-pers-no)
(setq lyskom-to-do-list (lyskom-create-read-list))
(setq lyskom-reading-list (lyskom-create-read-list)))
(lyskom-start-prefetch)
)
(defun lyskom-set-membership (membership)
......
......@@ -575,7 +575,7 @@ Meddelandet du f
(you-have-unreads . "Du har %#1d olst%#1?d%[%]%[a%] inlgg i %#2M\n")
(you-have-unreads-special . "Du har %#1d okommentera%#1?d%[t%]%[de%] inlgg i %#2M\n")
(you-have-no-unreads . "Du har inget olst i %#1M.\n")
(you-have-no-unreads . "Du har inget olst i %#1M\n")
(you-have-read-everything . "Du har sett alla nyheter.\n")
(total-unreads . "\nDu har %#1d olst%#1?d%[%]%[a%] inlgg i %#2d mte%#2?d%[%]%[n%].\n")
(list-unread-with-n-unread . "Visar endast mten med minst %#1d olsta.\n")
......@@ -780,6 +780,7 @@ Annat se \\[describe-mode] ---")
(today . "idag")
(yesterday . "igr")
(no-such-text-no . "Det finns inget sdant inlgg. (%#1:n)\n")
(time-yyyy-mm-dd . "%4#1d-%02#2d-%02#3d")
(head-Subject . "rende: ")
(Recipient . "Mottagare")
......@@ -829,10 +830,11 @@ upptagna. Logga ut och kom tillbaks senare om du v
(unknown . "oknd")
(unknown-person . "Oknd person")
(no-longer-member . "Du r inte lngre medlem i %#1M\n")
(no-longer-member . "Du r inte lngre medlem i %#1M.\n")
(no-longer-member-n . "Du r inte lngre medlem i mte %#1m (finns inte.)\n")
(have-become-member . "Du har blivit medlem i %#1M\n")
(have-become-member . "Du har blivit medlem i %#1M.\n")
(have-become-passive-member . "Du har blivit passiv medlem i %#1M.\n")
(message-broadcast . "\
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
......@@ -365,7 +365,7 @@ recipients to it that the user is a member in."
;; Is this function ever called asynchronously? If not, we
;; can use lyskom-get-membership istead.
(let ((membership (lyskom-try-get-membership
(misc-info->recipient-no misc-info)))
(misc-info->recipient-no misc-info) t))
(loc-no (misc-info->local-no misc-info)))
;; Make a note that this text really is in a group we are
......@@ -404,9 +404,9 @@ blocking-do."
(eq type 'CC-RECPT))
(setq membership (if bg
(lyskom-try-get-membership
(misc-info->recipient-no misc-item))
(misc-info->recipient-no misc-item) t)
(lyskom-get-membership
(misc-info->recipient-no misc-item))))
(misc-info->recipient-no misc-item) t)))
(when membership
(setq is-member t)
(when (or (<= (misc-info->local-no misc-item)
......@@ -643,7 +643,7 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW."
truncated t)))))
(let ((lyskom-current-function-phase 'body))
(lyskom-format-insert "%#1t" (cons text-stat body)))
(lyskom-format-insert "%#1t\n" (cons text-stat body)))
;; Indicate that the text was truncated
(if truncated
......@@ -657,13 +657,12 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW."
(lyskom-insert
(make-string kom-text-header-dash-length ?-)))
(lyskom-insert "\n")
(lyskom-format-insert "%#1t" (cons text-stat str))
(lyskom-format-insert "%#1t\n" (cons text-stat str))
(setq lyskom-current-subject "")))
(if (lyskom-text-p (cache-get-text (text->text-no text)))
(cache-del-text (text->text-no text)))
(sit-for 0)
(let ((lyskom-current-function-phase 'footer))
(lyskom-insert "\n")
(if kom-deferred-printing
(progn
(lyskom-format-insert "%#1s\n" lyskom-defer-indicator)
......
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