Commit aa44fb6a authored by David Byers's avatar David Byers
Browse files

Automatically list and review server FAQs when logging on

parent 5e7afa7c
2002-04-13 David Byers <david.byers@swipnet.se>
Fix language consistency:
* english-strings.el: Changed "article" to "text" in a bunch of
strings.
Check for server FAQs when logging on:
* startup.el (lyskom): Do get-version-info before get-server-info,
because otherwise we won't get the aux-items.
(kom-start-anew): Check for new FAQs when logging on.
(lyskom-startup-check-faqs): New function.
* utilities.el (lyskom-union): New function.
(filter-list): New non-recursive implementation.
More stringent format-string check (each arg needs to appear the
same number of times in all strings):
* check-strings.el (lcs-delete-format-arg): New function.
......
......@@ -265,7 +265,7 @@ Be ashamed of being You! You have a very good reason.\n\n")
(deleting-text . "Removing text %#1:n...")
(presentation-for-whom . "Which conference/user? ")
(text-to-see-author-of . "See presentation for the author of which text? ")
(text-to-see-author-of . "Review presentation of author of which text? ")
(somebody-deleted-that-conf . "Somebody just deleted that conference.\n")
(review-presentation-of . "Review presentation of %#1M.\n")
(has-no-presentation . "%#1:M has no presentation.\n")
......@@ -813,7 +813,7 @@ Mark the envelope with \"LysKOM bug report\"\n\n")
(review-cant-read-conf . "You can't review texts to a closed conference you are not a member of.\n")
(review-cant-read-letterbox . "You can't review texts to somebody else's mailbox.\n")
(review-cant-read-empty . "The conference is empty.\n")
(cant-review-everything . "You cannot review every article in LysKOM.\n")
(cant-review-everything . "You cannot review every text in LysKOM.\n")
(more-than-one-root . "Text %#1n has more than one root.\n")
(more-than-one-root-review . "\
......@@ -1401,6 +1401,7 @@ On since %#8s%#9s")
%]%[%]%#4s")
(faq-in-text . "FAQ in text %#1n %#3s%#4s")
(faq-in-text-by . "FAQ in text %#1n %#5s %#3sby %#2P %#4s")
(there-are-server-faqs . "There %#1?d%[is%]%[are%] %#1d (%#1d not marked as read) FAQ%#1?d%[%]%[s%] for this server:\n")
(too-many-languages . "Cannot code that many character sets. Send uncoded? ")
(too-many-content-types . "Cannot figure out what content type you want. Simplify the text.")
......@@ -1443,8 +1444,8 @@ On since %#8s%#9s")
(label-secret . "Should others to be able to see the label? ")
(creating-software-aux . "Created with %#1s")
(world-readable-text-aux . "The article can be read without logging on")
(world-readable-text-edit-aux . "Make the article readable without logging on")
(world-readable-text-aux . "The text can be read without logging on")
(world-readable-text-edit-aux . "Make the text readable without logging on")
(cant-get-aux-item . "Can't find auxiliary information\n")
(aux-item-no-info . "No information available\n")
......@@ -1479,7 +1480,7 @@ Contents: \"%#9s\"
(what-kind-to-add-aux-to . "Attach information to what? ")
(which-conf-to-add-aux-to . "Which conference to you want to attach information to? ")
(which-text-to-add-aux-to . "Which article to you want to attach information to? ")
(which-text-to-add-aux-to . "Which text to you want to attach information to? ")
(which-aux-item-tag . "Information tag: ")
(which-aux-item-inherit . "Set the inherit-flag? ")
(which-aux-item-secret . "Set the secret-flag? ")
......@@ -1662,8 +1663,8 @@ Number of sessions: %21#1d (total)
%21#4d unknown activity
%21#5d invisible sessions
%21#6d not logged on/secret/zombies\n")
(server-status-first-text . "Oldest existing article: %15#1n\n")
(server-status-last-text . "Youngest existing argicle: %15#1n\n")
(server-status-first-text . "Oldest existing text: %15#1n\n")
(server-status-last-text . "Youngest existing text: %15#1n\n")
(server-status-has-motd . "\nThe server has a notice:\n")
(server-status-time . "Serverns tid: %#1s\n")
))
......@@ -3414,6 +3415,10 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
If this is turned on, commands that review texts will also mark them
as read. Otherwise, the review commands will leave your reading history
untouched, as usual.")
(kom-auto-review-faqs-doc . "\
If this is turned on, server FAQs that are not marked as read will be
reviewed automatically when you log on.")
;;
;; Tags for variables
......@@ -3579,6 +3584,7 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(kom-print-seconds-in-time-strings-tag . "Include seconds in time strings:")
(kom-review-uses-cache-tag . "Review commands use cached texts:")
(kom-review-marks-texts-as-read-tag . "Review commands mark texts as read:")
(kom-auto-review-faqs-tag . "Review FAQs when logging on:")
)
)
......@@ -3723,12 +3729,8 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(error-54 . "Invalid membership type")
))
(lyskom-language-var lyskom-unread-mode-line en
(lyskom-make-lyskom-unread-mode-line))
(lyskom-language-var lyskom-unread-title-format en
(lyskom-make-lyskom-unread-title-format))
(provide 'lyskom-strings)
;;; english-strings ends here
......@@ -62,6 +62,7 @@
section
"\n"
[kom-default-language]
[kom-auto-review-faqs]
[kom-show-namedays]
[kom-show-week-number]
[kom-print-relative-dates]
......@@ -515,6 +516,7 @@ customize buffer but do not save them to the server."
(kom-autowrap (choice ((const (on t))
(const (off nil))
(number nil :tag max-text-length))))
(kom-auto-review-faqs (toggle on off))
(kom-dashed-lines (toggle (on off)))
(kom-show-author-at-end (toggle (on off)))
......
......@@ -269,14 +269,14 @@ clients of the event. See lyskom-mode for details on lyskom."
(initiate-set-client-version 'background nil
"lyskom.el" lyskom-clientversion)
(setq lyskom-server-info (blocking-do 'get-server-info))
(setq lyskom-server-version-info (blocking-do 'get-version-info))
(when (or (null lyskom-server-version-info)
(<= (version-info->protocol-version
lyskom-server-version-info) 7))
(lyskom-error 'too-old-server))
(lyskom-setup-client-for-server-version)
(setq lyskom-server-info (blocking-do 'get-server-info))
(lyskom-format-insert
'connection-done
(version-info->software-version lyskom-server-version-info))
......@@ -298,8 +298,9 @@ clients of the event. See lyskom-mode for details on lyskom."
(text->decoded-text-mass text text-stat)
(lyskom-get-string 'lyskom-motd-was-garbed)))
(lyskom-insert "\n")))
;; Can't use lyskom-end-of-command here.
(setq lyskom-executing-command nil)
(setq lyskom-executing-command nil)
;; Log in
(kom-start-anew t session-priority invisiblep)
(if (memq lyskom-buffer lyskom-buffer-list)
......@@ -309,7 +310,9 @@ clients of the event. See lyskom-mode for details on lyskom."
(list (car lyskom-buffer-list)))))
(setq lyskom-buffer-list
(cons lyskom-buffer lyskom-buffer-list)))
(setq init-done t))
;; We're done
(setq init-done t)
)
;; Something went wrong. Lets cleanup everything. :->
(if init-done
nil
......@@ -572,6 +575,12 @@ shown to other users."
(lyskom-insert-string 'presentation-encouragement)))
(setq lyskom-is-new-user nil)
;; Check FAQs (and don't croak if there is a bug!)
(unwind-protect
(lyskom-startup-check-faqs)
nil)
(lyskom-end-of-command)))
;; Run the hook kom-login-hook. We don't want to hang the
......@@ -870,124 +879,53 @@ to see, set of call."
(lyskom-set-mode-line
(lyskom-get-string 'not-present-anywhere)))
; (let ((proc lyskom-proc)
; (pers-no lyskom-pers-no)
; (membership lyskom-membership)
; (membership-is-read lyskom-membership-is-read)
; (last-viewed lyskom-last-viewed)
; (replies-buffer lyskom-unparsed-buffer)
; (replies-marker lyskom-unparsed-marker)
; (server-info lyskom-server-info)
; (server-name lyskom-server-name)
; )
; (kill-all-local-variables)
; (make-local-variable 'kom-ansaphone-show-messages)
; (make-local-variable 'kom-ansaphone-record-messages)
; (make-local-variable 'kom-ansaphone-on)
; (make-local-variable 'kom-ansaphone-default-reply)
; (make-local-variable 'kom-friends)
; (make-local-variable 'kom-login-hook)
; (make-local-variable 'kom-membership-default-priority)
; (make-local-variable 'kom-permanent-filter-list)
; (make-local-variable 'kom-user-prompt-format)
; (make-local-variable 'kom-user-prompt-format-executing)
; (make-local-variable 'kom-enabled-prompt-format)
; (make-local-variable 'kom-enabled-prompt-format-executing)
; (make-local-variable 'kom-remote-control)
; (make-local-variable 'kom-remote-controllers)
; (make-local-variable 'kom-session-filter-list)
; (make-local-variable 'lyskom-blocking-return)
; (make-local-variable 'lyskom-buffer)
; (make-local-variable 'lyskom-command-to-do)
; (make-local-variable 'lyskom-conf-cache)
; (make-local-variable 'lyskom-count-var)
; (make-local-variable 'lyskom-current-conf)
; (make-local-variable 'lyskom-current-subject)
; (make-local-variable 'lyskom-current-text)
; (make-local-variable 'lyskom-default-password)
; (make-local-variable 'lyskom-default-user-name)
; (make-local-variable 'lyskom-do-when-done)
; (make-local-variable 'lyskom-dynamic-session-info-flag)
; (make-local-variable 'lyskom-errno)
; (make-local-variable 'lyskom-executing-command)
; (make-local-variable 'lyskom-filter-list)
; (make-local-variable 'lyskom-is-administrator)
; (make-local-variable 'lyskom-is-parsing)
; (make-local-variable 'lyskom-is-waiting)
; (make-local-variable 'lyskom-is-writing)
; (make-local-variable 'lyskom-language)
; (make-local-variable 'lyskom-last-group-message-recipient)
; (make-local-variable 'lyskom-last-personal-message-sender)
; (make-local-variable 'lyskom-last-viewed)
; (make-local-variable 'lyskom-list-of-edit-buffers)
; (make-local-variable 'lyskom-marked-text-cache)
; (make-local-variable 'lyskom-membership)
; (make-local-variable 'lyskom-membership-is-read)
; (make-local-variable 'lyskom-current-prompt)
; (make-local-variable 'lyskom-normally-read-texts)
; (make-local-variable 'lyskom-number-of-pending-calls)
; (make-local-variable 'lyskom-options-done)
; (make-local-variable 'lyskom-other-clients-user-areas)
; (make-local-variable 'lyskom-output-queues)
; (make-local-variable 'lyskom-pending-calls)
; (make-local-variable 'lyskom-pending-prefetch)
; (make-local-variable 'lyskom-pers-cache)
; (make-local-variable 'lyskom-pers-no)
; (make-local-variable 'lyskom-prefetch-conf-tresh)
; (make-local-variable 'lyskom-prefetch-confs)
; (make-local-variable 'lyskom-prefetch-in-action)
; (make-local-variable 'lyskom-prefetch-pending-prefetch)
; (make-local-variable 'lyskom-prefetch-stack)
; (make-local-variable 'lyskom-prefetch-texts)
; (make-local-variable 'lyskom-previous-text)
; (make-local-variable 'lyskom-prioritize-buffer)
; (make-local-variable 'lyskom-proc)
; (make-local-variable 'lyskom-reading-list)
; (make-local-variable 'lyskom-server-info)
; (make-local-variable 'lyskom-server-name)
; (make-local-variable 'lyskom-server-version)
; (make-local-variable 'lyskom-server-supports)
; (make-local-variable 'lyskom-set-last-read-flag)
; (make-local-variable 'lyskom-uconf-stats-flag)
; (make-local-variable 'lyskom-session-no)
; (make-local-variable 'lyskom-session-priority)
; (make-local-variable 'lyskom-text-cache)
; (make-local-variable 'lyskom-text-mass-cache)
; (make-local-variable 'lyskom-to-be-printed-before-prompt)
; (make-local-variable 'lyskom-to-do-list)
; (make-local-variable 'lyskom-unparsed-buffer)
; (make-local-variable 'lyskom-unparsed-marker)
; (make-local-variable 'lyskom-unread-confs)
; (make-local-variable 'lyskom-what-i-am-doing)
; (make-local-variable 'lyskom-who-info-buffer)
; (make-local-variable 'lyskom-who-info-buffer-is-on)
; (make-local-variable 'lyskom-who-info-cache)
; (make-local-variable 'lyskom-collate-table)
; (make-local-variable 'mode-line-conf-name)
; (make-local-variable 'lyskom-mode-map)
; (make-local-variable 'lyskom-edit-mode-map)
; (make-local-variable 'lyskom-filter-edit-map)
; (make-local-variable 'lyskom-prioritize-mode-map)
; (make-local-variable 'lyskom-customize-map)
; (setq lyskom-proc proc)
; (setq lyskom-pers-no pers-no)
; (setq lyskom-membership membership)
; (setq lyskom-last-viewed last-viewed)
; (setq lyskom-membership-is-read membership-is-read)
; (setq lyskom-unparsed-buffer replies-buffer)
; (setq lyskom-unparsed-marker replies-marker)
; (setq lyskom-server-info server-info)
; (setq lyskom-server-name server-name)
; (setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
; (setq lyskom-output-queues (make-vector 10 nil))
; (setq lyskom-collate-table lyskom-default-collate-table)
; (let ((i 0))
; (while (< i 10)
; (aset lyskom-output-queues i (lyskom-queue-create))
; (++ i)))
; (setq lyskom-list-of-edit-buffers nil)
; (setq lyskom-pending-calls nil)
; (lyskom-set-mode-line (lyskom-get-string 'not-present-anywhere))))
;;; ================================================================
;;; Special login stuff
;;;
(defun lyskom-startup-check-faqs ()
(let ((faq-list (mapcar (lambda (aux)
(string-to-int (aux-item->data aux)))
(lyskom-get-aux-item
(server-info->aux-item-list lyskom-server-info)
14))))
(when faq-list
(let ((collector (make-collector))
(mship-list nil))
;; Get all text-stats
(lyskom-traverse faq faq-list
(initiate-get-text-stat 'main
'collector-push
faq
collector))
(lyskom-wait-queue 'main)
;; Get the memberships that we need
(lyskom-traverse text-stat (collector->value collector)
(setq mship-list (lyskom-union (lyskom-text-recipients text-stat)
mship-list)))
(lyskom-traverse conf-no mship-list
(lyskom-get-membership conf-no t))
;; Now we are ready
(let ((texts-to-view
(filter-list (lambda (text-stat)
(not (lyskom-text-read-at-least-once-p
text-stat)))
(collector->value collector))))
(lyskom-format-insert 'there-are-server-faqs
(length faq-list)
(length texts-to-view))
(lyskom-do-list-summary faq-list)
(when (and texts-to-view kom-auto-review-faqs)
(lyskom-review-enter-read-info
(lyskom-create-read-info 'REVIEW
nil
256
(lyskom-create-text-list
(mapcar 'text-stat->text-no
texts-to-view))
nil t)
nil)
))))))
......@@ -1400,6 +1400,7 @@ Uppkopplad sedan %#8s%#9s")
%]%[%]%#4s")
(faq-in-text . "FAQ i text %#1n %#3s%#4s")
(faq-in-text-by . "FAQ i text %#1n %#5s %#3sav %#2P %#4s")
(there-are-server-faqs . "Det finns %#1d (%#1d ej lsmarkerad%#1?d%[%]%[e%]) FAQ%#1?d%[%]%[er%] fr denna server:\n")
(too-many-languages . "Fr mnga teckenuppsttningar fr att koda. Skicka in okodat? ")
(too-many-content-types . "Kan inte avgra innehllstyp. Frenkla inlgget.")
......@@ -3863,6 +3864,9 @@ i servern. Annars sparas det i din .emacs.")
Om detta r pslaget s kommer kommandon som terser inlgg att
lsmarkera de inlgg som visas. I annat fall lmnar tersekommandona
din lshistorik orrd, precis som vanligt.")
(kom-auto-review-faqs-doc . "\
Om detta r pslaget s kommer server-FAQer som inte r lsmarkerade
att terses automatiskt nr du loggar in.")
;;
......@@ -4029,6 +4033,7 @@ i servern. Annars sparas det i din .emacs.")
(kom-print-seconds-in-time-strings-tag . "Inkludera sekunder i tidsangivelser:")
(kom-review-uses-cache-tag . "tersekommandon anvnder sparade inlgg:")
(kom-review-marks-texts-as-read-tag . "tersekommandon lsmarkerar visade texter:")
(kom-auto-review-faqs-tag . "Visa FAQer vid inloggning:")
)
)
......
......@@ -129,10 +129,11 @@ If BEFORE is not in the list, then insert EL at the end of the list."
(defun filter-list (test list)
(cond ((null list) '())
((apply test (car list) nil)
(cons (car list) (filter-list test (cdr list))))
(t (filter-list test (cdr list)))))
(let ((result nil))
(lyskom-traverse el list
(when (funcall test el)
(setq result (cons el result))))
(nreverse result)))
;;;============================================================
;;;
......@@ -672,6 +673,15 @@ The order of the list a is kept."
(setq a (cdr a)))
(nreverse list))))
(defun lyskom-union (a b)
"Returns a list containing the union of list A and list B.
The list may contain list A or list B as its tail. This means that
destructive operations on the result may affect either operand."
(let ((result nil))
(lyskom-traverse x a
(unless (memq x b) (setq result (cons x result))))
(nconc (nreverse result) b)))
;;; ======================================================================
......
......@@ -101,6 +101,12 @@ are in the list.")
;;; User flags
(def-kom-var kom-auto-review-faqs t
"*If non-nil, automatically review all server FAQs not marked as
read when logging on."
server
)
(def-kom-var kom-allow-incompleteness nil
"*If nil, commands like kom-list-news will wait for the prefetch.
If this flag is set to t, some commands may give incomplete answers,
......
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