Commit 580b95df authored by David Byers's avatar David Byers
Browse files

Bug fixes in review.el, fixes in prioritize

parent 73399be6
Fri May 3 10:13:12 1996 David Byers <davby@sen2.ida.liu.se>
* english-strings.el,swedish-strings.el (lyskom-prioritize-mode-map):
Lade till M-DEL som bindning fr kom-prioritize-deselect-all
* prioritize.el (kom-prioritize-deselect-all): Lade till detta
kommando.
* review.el (lyskom-check-review-access): Hantera tomma mten rtt.
(lyskom-get-texts-by-and-to): Optimera hantering av terse av en
flitig frfattare till ett litet mte.
* swedish-strings.el,english-strings.el (lyskom-strings): Ngra nya
strngar fr rapportering av fel i terse.
* review.el (lyskom-get-texts-by): Skrev om s den blev effektivare.
Stt maxinkrement till lyskom-fetch-map-nos. Kontrollera att man
verkligen fr lsa conf-mappen. (lyskom-get-texts-generic): Tog bort
denna eftersom den bara anvndes av lyskom-get-texts-by.
(lyskom-get-texts-to): Inlineade koden frn lyskom-get-texts-generic.
Stt maxinkrement till lyskom-fetch-map-nos.
(lyskom-get-texts-by-and-to): Startinkrement satt till
lyskom-fetch-map-nos, kontrollera att man verkligen fr lsa
conf-mappen. (lyskom-check-review-access): Ny funktion.
Thu May 2 18:47:18 1996 David Kgedal <davidk@lysator.liu.se>
* 0.41 release
......
......@@ -25,7 +25,7 @@
# $Id$
#
CLIENTVERSION = 0.41
CLIENTVERSION = 0.42-beta
GENERIC-CLEAN = *~ *.o core
GENERIC-DIST-CLEAN = TAGS
......
......@@ -34,17 +34,16 @@ Buggar
Om man försöker logga in med en förkortning som matchar flera namn
tror klienten att man inte finns.
Allmänna förbättringar
Lista meddelanden via fjärrkontroll listar baklänges.
Att försöka återse inlägg i någon annans brevlåda tar bara en
massa tid och gör ingen nytta.
Allmänna förbättringar
Inläggsnumren borde vara mer kontextkänsliga. Om man klickar på
ett inläggs eget nummer, alltså det som står precis innan datumet
och det som står inom parentesen precis efter inläggstexten, så
vill man antagligen inte återse det, eftersom man ju bevisligen
har det framför sig. I stället vill man antagligen kommentera
det.
det.
Har detta att göra med lite för optimistisk cache att göra? Kanske
bör man läsa om person-staten innan man varnar för lapp på dörren?
......
......@@ -555,6 +555,11 @@ Mark the envelope with \"LysKOM bug report\"\n\n")
(review-one-comment . "Review one comment to article %#1n.\n")
(review-many-comments . "Review %#2d comments to article %#1n.\n")
(read-normally-read . "How many articles to you want to review: ")
(review-conf-gone . "The conference does not exist.\n")
(review-pers-gone . "The user does not exist.\n")
(review-cant-read-conf . "You can't review articles to a closed conference you are not a member of.\n")
(review-cant-read-letterbox . "You can't review articles to somebody else's mailbox.")
(review-cant-read-empty . "The conference is empty.\n")
; From edit-text.el:
(press-C-c-C-c . "Enter C-c C-c to post the article.")
......@@ -1235,6 +1240,7 @@ Cf. paragraph-start.")
(define-key lyskom-prioritize-mode-map "\C-m" 'kom-prioritize-next-line)
(define-key lyskom-prioritize-mode-map "\C-j" 'kom-prioritize-next-line)
(define-key lyskom-prioritize-mode-map "\C-?" 'kom-prioritize-previous-line)
(define-key lyskom-prioritize-mode-map "\M-\C-?" 'kom-prioritize-deselect-all)
(define-key lyskom-prioritize-mode-map [down] 'kom-prioritize-next-line)
(define-key lyskom-prioritize-mode-map "\C-n" 'kom-prioritize-next-line)
(define-key lyskom-prioritize-mode-map [up] 'kom-prioritize-previous-line)
......
......@@ -278,6 +278,18 @@
(interactive)
(lyskom-message "%s" (lyskom-get-string 'prioritize-help)))
(defun kom-prioritize-deselect-all ()
"Deselect all selected entries"
(interactive)
(let ((entry nil))
(while lyskom-prioritize-selection
(setq entry (car lyskom-prioritize-selection))
(lyskom-prioritize-select entry nil)
(lyskom-prioritize-redraw-entry entry))))
(defun kom-prioritize-select (&optional arg)
"Select the record on the line containing point.
If ARG is null, toggle selection. Positive arg means always select and
......
......@@ -39,6 +39,11 @@
(concat lyskom-clientversion-long
"$Id$\n"))
(put 'lyskom-cant-review-error
'error-conditions
'(error lyskom-error lyskom-review-error))
(put 'lyskom-review-error 'error-message
"Review error")
(defun lyskom-intersection (a b)
......@@ -150,16 +155,20 @@ The defaults for this command is the conference that you are in."
info-by
info-to))
(let ((list (lyskom-get-texts-by-to by to count)))
(if list
(read-list-enter-read-info (lyskom-create-read-info
'REVIEW
nil
(lyskom-get-current-priority)
(lyskom-create-text-list list)
nil t)
lyskom-reading-list t)
(lyskom-insert-string 'no-such-text)))))
(condition-case arg
(let ((list (lyskom-get-texts-by-to by to count)))
(if list
(read-list-enter-read-info (lyskom-create-read-info
'REVIEW
nil
(lyskom-get-current-priority)
(lyskom-create-text-list list)
nil t)
lyskom-reading-list t)
(lyskom-insert-string 'no-such-text)))
(lyskom-review-error (if arg
nil
(lyskom-insert-string 'no-such-text))))))
;;; ================================================================
......@@ -175,11 +184,47 @@ The defaults for this command is the conference that you are in."
(defun lyskom-get-texts-by-to (by to num)
"Get NUM texts writteb by person number BY in conference number TO
Args: BY TO NUM"
(cond ((and (zerop by)
(zerop to)) nil)
((zerop to) (lyskom-get-texts-by by num))
((zerop by) (lyskom-get-texts-to to num))
(t (lyskom-get-texts-by-and-to by to num))))
(cond ((and (zerop by)
(zerop to)) nil)
((zerop to) (lyskom-get-texts-by by num))
((zerop by) (lyskom-get-texts-to to num))
(t (lyskom-get-texts-by-and-to by to num))))
;;; ============================================================
;;; lyskom-check-review-access
;;; Author: David Byers
;;;
;;; Check that we can access the conference map. If we can't some
;;; review functions are just not much fun
;;;
(defun lyskom-check-review-access (conf pers)
"Check that we can review texts to CONF by PERS.
CONF is a conf-stat or t if we know we can access that conference.
PERS is a pers-stat or t if we know we can access that person.
This function signals an error if review is impossible"
(cond ((null conf)
(lyskom-format-insert 'review-conf-gone)
(signal 'lyskom-cant-review-error t))
((null pers)
(lyskom-format-insert 'review-pers-gone)
(signal 'lyskom-cant-review-error t))
((lyskom-conf-stat-p conf)
(cond ((= 0 (conf-stat->no-of-texts conf))
(lyskom-format-insert 'review-cant-read-empty)
(signal 'lyskom-cant-review-error t))
((null (map->text-nos
(blocking-do 'get-map
(conf-stat->conf-no conf)
(conf-stat->first-local-no conf)
1)))
(if (conf-type->letterbox
(conf-stat->conf-type conf))
(lyskom-format-insert 'review-cant-read-letterbox)
(lyskom-format-insert 'review-cant-read-conf))
(signal 'lyskom-cant-review-error t))))))
......@@ -225,240 +270,300 @@ Args: BY TO NUM"
;;; The bad part is that it constructs a little too many new cons
;;; cells, although reversing most of the lists does help.
;;;
;;; The following optimisations have been implemented:
;;;
;;; +++ FIXME: In some cases this function can take a long time. If
;;; the total number of texts in the conference is low, but they were
;;; written a long time ago, we'll be scanning the user's map
;;; uselessly for a long time. The same is true if the user's map is
;;; small and the conference gets lots of traffic. In some cases it
;;; might actually be faster to look at and filter the text-stats in
;;; the smaller map. The fact that the user's map _is_ sorted in
;;; ascending order might also be a source for some sort of
;;; optimization.
;;;
;;; - Exploit the fact that the user's map is sorted by aborting the
;;; search if we have the full conference map and the lowest number we
;;; have from the user's map is lower than the lowest number in the
;;; conference map. Highest numbers apply when we are searching from
;;; the front.
;;; +++ FIXME: For users that have written very little in high-traffic
;;; conferences, and where the request cannot be fulfilled (if num is
;;; too high) this function ends up scanning the entire conference
;;; map. At some point it is probably faster to get all the text-stats
;;; in the user's map (when we've retrieved the map we know how many
;;; there are) and look at the recipients rather than calculate the
;;; intersection.
;;;
(defun lyskom-get-texts-by-and-to (persno confno num)
"Get NUM texts written by person PERSNO with conference CONFNO as a
recipient.
Args: persno confno num"
(let* ((persstat (blocking-do 'get-pers-stat persno))
(confstat (blocking-do 'get-conf-stat confno))
(result-list nil)
(by-list nil)
(to-list nil)
(result-size 0)
(by nil)
(to nil)
(increment 30)
(plow (pers-stat->first-created-text persstat))
(phigh (1- (+ plow (pers-stat->no-of-created-texts persstat))))
(pmark (if (and num (< num 0)) plow phigh))
(clow (conf-stat->first-local-no confstat))
(chigh (1- (+ clow (conf-stat->no-of-texts confstat))))
(cmark (if (and num (< num 0)) clow chigh)))
(if (null num)
(setq num (1+ phigh)))
(while (and (or (and (<= pmark phigh)
(>= pmark plow))
(and (<= cmark chigh)
(>= cmark clow)))
(> (abs num) result-size))
(setq by (and (<= pmark phigh)
(>= pmark plow)
(lyskom-remove-zeroes
(listify-vector
(map->text-nos
(blocking-do 'get-created-texts
(pers-stat->pers-no persstat)
(if (< num 0)
pmark
(max 0 (- pmark (1- increment))))
increment)))))
to (and (<= cmark chigh)
(>= cmark clow)
(lyskom-remove-zeroes
(listify-vector
(map->text-nos
(blocking-do 'get-map
(conf-stat->conf-no confstat)
(if (< num 0)
cmark
(max 0 (- cmark (1- increment))))
increment))))))
(let ((persstat (blocking-do 'get-pers-stat persno))
(confstat (blocking-do 'get-conf-stat confno)))
(lyskom-check-review-access confstat persstat)
(let* ((result-list nil)
(by-list nil)
(to-list nil)
(result-size 0)
(by nil)
(to nil)
(increment lyskom-fetch-map-nos)
(plow (pers-stat->first-created-text persstat))
(phigh (1- (+ plow (pers-stat->no-of-created-texts persstat))))
(pmark (if (and num (< num 0)) plow phigh))
(clow (conf-stat->first-local-no confstat))
(chigh (1- (+ clow (conf-stat->no-of-texts confstat))))
(cmark (if (and num (< num 0)) clow chigh))
(smallest nil)
(largest nil)
(abort-loop nil))
(if (null num)
(setq num (1+ phigh)))
(while (and (or (and (<= pmark phigh)
(>= pmark plow))
(and (<= cmark chigh)
(>= cmark clow)))
(> (abs num) result-size)
(not abort-loop))
(setq by (and (<= pmark phigh)
(>= pmark plow)
(lyskom-remove-zeroes
(listify-vector
(map->text-nos
(blocking-do 'get-created-texts
(pers-stat->pers-no persstat)
(if (< num 0)
pmark
(max 0 (- pmark (1- increment))))
increment)))))
to (and (<= cmark chigh)
(>= cmark clow)
(lyskom-remove-zeroes
(listify-vector
(map->text-nos
(blocking-do 'get-map
(conf-stat->conf-no confstat)
(if (< num 0)
cmark
(max 0 (- cmark (1- increment))))
increment))))))
;;
;; Add intersection between new TO and old BYs
;; to the results list.
;;
(if (> num 0)
(if (and smallest by
(> smallest (car by)))
(setq abort-loop t))
(if (and largest by
(< largest (car (nthcdr (1- (length by)) by))))
(setq abort-loop t)))
;;
;; Add intersection between new TO and old BYs
;; to the results list.
;;
(setq result-list
(cons (apply 'nconc
(mapcar
(function
(lambda (x)
(lyskom-intersection to x)))
by-list))
result-list))
;;
;; Add new BY and TO to the by-list and to-list
;;
(setq by-list (cons by by-list)
to-list (cons to to-list))
(setq result-list
(cons (apply 'nconc
(mapcar
(function
(lambda (x)
(lyskom-intersection to x)))
by-list))
result-list))
;;
;; Add intersections between new BY and all TOs
;;
;;
;; Add new BY and TO to the by-list and to-list
;;
(setq result-list
(mapcar2 (function
(lambda (x y)
(lyskom-intersection y
(nconc x by))))
result-list
to-list))
(setq by-list (cons by by-list)
to-list (cons to to-list))
(setq result-size (apply '+ (mapcar 'length result-list)))
;;
;; Add intersections between new BY and all TOs
;;
;;
;; Adjust the marks
;;
(setq result-list
(mapcar2 (function
(lambda (x y)
(lyskom-intersection y
(nconc x by))))
result-list
to-list))
(if (> num 0)
(setq pmark (- pmark increment)
cmark (- cmark increment))
(setq pmark (+ pmark increment)
cmark (+ cmark increment)))
;;
;; If we have exhausted the conference, calculate smallest and
;; largest
;;
(if (and (null smallest)
(null largest)
(or (> cmark chigh)
(< cmark clow)))
(setq smallest
(apply 'min
(mapcar (function (lambda (x)
(if x
(apply 'min x)
(lyskom-maxint))))
to-list))
largest
(apply 'max
(mapcar (function (lambda (x)
(if x
(apply 'max x)
-1)))
to-list))))
(setq result-size (apply '+ (mapcar 'length result-list)))
;;
;; Adjust the marks
;; This is the end of the while loop
;;
(if (> num 0)
(setq pmark (- pmark increment)
cmark (- cmark increment))
(setq pmark (+ pmark increment)
cmark (+ cmark increment))))
)
;;
;; Extract results
;;
;;
;; Extract results
;;
(setq result-list
(apply 'nconc (if (< num 0)
(nreverse result-list)
result-list)))
(setq result-list
(apply 'nconc (if (< num 0)
(nreverse result-list)
result-list)))
(if (> num 0)
(nthcdr (- (length result-list) num) result-list)
(nfirst (- num) result-list))))
(if (> num 0)
(nthcdr (- (length result-list) num) result-list)
(nfirst (- num) result-list)))))
;;; ===============================================================
;;; lyskom-get-texts-generic
;;; lyskom-get-texts-by, lyskom-get-texts-to
;;; Author: David Byers
;;;
;;; This function gets NUM texts from the start or end of a map.
;;; It works by fetching INCREMENT texts at a time, removing zeroes
;;; and appending to what it already has. INCREMENT starts out as the
;;; number of texts still to go, but is incremented each time no
;;; new texts are returned (when only zeroes are returned)
;;; These functions get data in chunks, starting with the number of
;;; texts requested. If they come up empty (which is common when
;;; scanning from the beginning of a map), the increment is
;;; exponentially increased up to a maximum of 150.
;;;
;;; lyskom-get-texts-by is also careful to filter out those texts that
;;; are not readable, hence the added complexity in that function.
;;;
(defun lyskom-get-texts-generic (objnum num low high get-operation)
"From object OBJNUM (a person or conference number) get NUM texts.
LOW is the lowest local text number and HIGH the highest in the
conference or person map. GET-OPERATION is the blocking-do operation
to use to get texts (get-map or get-created-texts)."
(if (null num)
(setq num (1+ high)))
(let* ((result nil)
(increment (abs num))
(mark (if (< num 0) low high)))
(while (and (<= mark high)
(>= mark low)
(> (abs num) (length result)))
(let ((found (lyskom-remove-zeroes
(defun lyskom-get-texts-by (persno num)
"Get NUM texts written by PERSNO. Args: persno num"
(let ((persstat (blocking-do 'get-pers-stat persno)))
(lyskom-check-review-access t persstat)
(let* ((plow (pers-stat->first-created-text persstat))
(phigh (1- (+ plow (pers-stat->no-of-created-texts persstat))))
(result nil)
(increment (if num (abs num)))
(mark (if (and num (< num 0)) plow phigh))
(found nil)
(data nil))
(if (null num)
(setq num (1+ phigh)
mark phigh
increment (1+ phigh)))
(setq increment (min lyskom-fetch-map-nos increment))
(while (and (<= mark phigh)
(>= mark plow)
(> (abs num) (length result)))
(setq data (lyskom-remove-zeroes
(listify-vector
(map->text-nos
(blocking-do get-operation
objnum
(blocking-do 'get-created-texts
persno
(if (< num 0)
mark
(- mark (1- increment)))
increment))))))
increment)))))
(mapcar (function (lambda (x) (initiate-get-text-stat 'main nil x)))
data)
(lyskom-wait-queue 'main)
(setq found nil)
(mapcar (function (lambda (x) (if (cache-get-text-stat x)
(setq found (cons x found)))))
data)
(setq found (nreverse found))
(if (> num 0)
(setq result (nconc found result)
mark (- mark increment)
increment (- (abs num) (length result)))
mark (- mark increment))
(setq result (nconc result found)
mark (+ mark increment)))
(if (null found)
(setq increment (min 150 (* increment 2)))
(setq increment (- (abs num) (length result))))))
(if (> num 0)
(nthcdr (- (length result) num) result)
(nfirst (- num) result))))
(setq increment (min lyskom-fetch-map-nos (* increment 2)))
(setq increment (- (abs num) (length result)))))
(if (> num 0)
(nthcdr (- (length result) num) result)
(nfirst (- num) result)))))
(defun lyskom-get-texts-by (persno num)
"Get NUM texts written by PERSNO. Args: persno num"
(let* ((persstat (blocking-do 'get-pers-stat persno))
(plow (pers-stat->first-created-text persstat))
(phigh (1- (+ plow (pers-stat->no-of-created-texts persstat))))
(new-data t)
(remaining num)
(result-list nil))
(if (null num)
(setq num (1+ phigh)
remaining (1+ phigh)))
;; +++
;; Get segments of the user's map until we have enough results
;; FIXME: The code in lyskom-get-texts-generic should be moved to
;; lyskom-get-texts-by and lyskom-get-texts-to so lyskom-get-texts-to
;; could be a little more efficient. Now it will call
;; lyskom-get-texts-generic with a remaining of one way too often.
;;
(while (and new-data
(< (length result-list) (abs num)))
(setq new-data
(lyskom-get-texts-generic persno
remaining
plow
phigh
'get-created-texts))
(if new-data
(progn
(if (< num 0)
(setq plow (+ plow (length new-data)))
(setq phigh (- phigh (length new-data))))
(mapcar
(function
(lambda (x) (initiate-get-text-stat 'main nil x)))
new-data)
(lyskom-wait-queue 'main)
(while new-data
(if (cache-get-text-stat (car new-data))
(setq result-list (cons (car new-data) result-list)))
(setq new-data (cdr new-data)))
(setq remaining (- num (length result-list)))
(setq new-data t))))
(nreverse result-list)))