Commit 00260d69 authored by David Byers's avatar David Byers

Functions to handle FAQs

parent 0a71ed1a
1999-06-13 David Byers <davby@ida.liu.se>
* commands2.el (kom-del-faq): New function.
(kom-add-faq): New function.
(kom-status-conf): Print aux items.
(kom-status-person): Print aux items.
* view-text.el (lyskom-view-text): Use text-print-when to contol
printing of aux-items.
* lyskom-rest.el (lyskom-read-number): Accept symbol for prompt.
1999-06-12 David Byers <davby@ida.liu.se>
* commands1.el (lyskom-who-is-on-check-membership-9): Don't
......
......@@ -118,49 +118,50 @@
;;; ======================================================================
(def-aux-item content-type 1
(print-when . never)
(text-print-when . never)
(parse . lyskom-parse-content-type)
(print . lyskom-print-content-type)
(text-print . lyskom-print-content-type)
(info . lyskom-aux-item-info))
(def-aux-item fast-reply 2
(print-when . footer)
(text-print-when . footer)
(parse . nil)
(print . lyskom-print-fast-reply)
(text-print . lyskom-print-fast-reply)
(info . lyskom-aux-item-info))
(def-aux-item cross-reference 3
(print-when . comment)
(status-print . lyskom-status-print-cross-reference)
(text-print-when . comment)
(parse . lyskom-parse-cross-reference)
(print . lyskom-print-cross-reference)
(text-print . lyskom-print-cross-reference)
(edit-insert . lyskom-edit-insert-cross-reference)
(info . lyskom-aux-item-info))
(def-aux-item no-comments 4
(print-when . footer)
(text-print-when . footer)
(parse . lyskom-parse-no-comments)
(print . lyskom-print-no-comments)
(text-print . lyskom-print-no-comments)
(edit-insert . lyskom-edit-insert-no-comments)
(info . lyskom-aux-item-info))
(def-aux-item personal-comment 5
(print-when . footer)
(text-print-when . footer)
(parse . lyskom-parse-personal-comments)
(print . lyskom-print-personal-comments)
(text-print . lyskom-print-personal-comments)
(edit-insert . lyskom-edit-insert-personal-comments)
(info . lyskom-aux-item-info))
(def-aux-item request-confirmation 6
(print-when . header)
(text-print-when . header)
(parse . lyskom-parse-request-confirmation)
(print . lyskom-print-request-confirmation)
(text-print . lyskom-print-request-confirmation)
(edit-insert . lyskom-edit-insert-request-confirmation)
(info . lyskom-aux-item-info)
(read-action . lyskom-request-confirmation-action))
(def-aux-item read-confirm 7
(print-when . header)
(print . lyskom-print-read-confirm)
(text-print-when . header)
(text-print . lyskom-print-read-confirm)
(info . lyskom-aux-item-info))
(def-aux-item redirect 8
......@@ -172,8 +173,8 @@
(info . lyskom-aux-item-info))
(def-aux-item alternate-name 10
(print-when . header)
(print . lyskom-print-alternate-name)
(text-print-when . header)
(text-print . lyskom-print-alternate-name)
(info . lyskom-aux-item-info))
(def-aux-item pgp-signature 11
......@@ -185,6 +186,57 @@
(def-aux-item e-mail-address 13
(info . lyskom-aux-item-info))
(def-aux-item faq-text 14
(info . lyskom-aux-item-info)
(status-print . lyskom-status-print-faq-text))
(def-aux-item creating-software 15
(info . lyskom-aux-item-info)
(text-print-when . header)
(text-print . lyskom-print-creating-software))
(def-aux-item mx-author 16
(info . lyskom-aux-item-info))
(def-aux-item mx-from 17
(info . lyskom-aux-item-info))
(def-aux-item mx-reply-to 18
(info . lyskom-aux-item-info))
(def-aux-item mx-to 19
(info . lyskom-aux-item-info))
(def-aux-item mx-cc 20
(info . lyskom-aux-item-info))
(def-aux-item mx-date 21
(info . lyskom-aux-item-info))
(def-aux-item mx-message-id 22
(info . lyskom-aux-item-info))
(def-aux-item mx-in-reply-to 23
(info . lyskom-aux-item-info))
(def-aux-item mx-misc 24
(info . lyskom-aux-item-info))
(def-aux-item mx-allow-filter 25
(info . lyskom-aux-item-info))
(def-aux-item mx-reject-forward 26
(info . lyskom-aux-item-info))
(def-aux-item notify-comments 27
(info . lyskom-aux-item-info))
(def-aux-item faq-for-conf 28
(text-print . lyskom-print-faq-for-conf)
(text-print-when . header)
(info . lyskom-aux-item-info))
;;; ================================================================
......@@ -288,6 +340,34 @@
(lyskom-aux-item-terminating-button item obj)
)))
(defun lyskom-status-print-cross-reference (item &optional obj pers)
(lyskom-insert
(concat
(cond ((string-match "^P\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-pers-status-aux
(string-to-int
(match-string 1 (aux-item->data item)))
(aux-item->creator pers)
))
((string-match "^C\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-conf-status-aux
(string-to-int
(match-string 1 (aux-item->data item)))
pers
))
((string-match "^T\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-text-status-aux
(string-to-int
(match-string 1 (aux-item->data item)))
(aux-item->creator pers)
))
(t (lyskom-format 'strange-cross-reference-status
(aux-item->data item)
(aux-item->creator pers)
)))
(lyskom-aux-item-terminating-button item obj)
"\n")))
(defun lyskom-parse-no-comments ()
(and (looking-at (lyskom-get-string 'no-comments-regexp))
""))
......@@ -396,8 +476,25 @@
(defun lyskom-print-alternate-name (item &optional obj)
(concat "Alternate: " (aux-item->data item) " "
(concat "[" (aux-item->data item) "] "
(lyskom-aux-item-terminating-button item obj)))
(defun lyskom-status-print-faq-text (item &optional obj)
(lyskom-insert
(concat
(lyskom-format 'faq-in-text-aux (string-to-int (aux-item->data item)))
(lyskom-aux-item-terminating-button item obj)
"\n")))
(defun lyskom-print-faq-for-conf (item &optional obj)
(concat
(lyskom-format 'faq-for-conf-aux (string-to-int (aux-item->data item)))
(lyskom-aux-item-terminating-button item obj)))
(defun lyskom-print-creating-software (item &optional obj)
concat
(lyskom-format 'creating-software-aux (aux-item->data item))
(lyskom-aux-item-terminating-button item obj))
(provide 'lyskom-aux-items)
......@@ -258,6 +258,12 @@ otherwise: the conference is read with lyskom-completing-read."
(lyskom-format-insert 'conf-has-motd conf-stat)
(lyskom-view-text (conf-stat->msg-of-day conf-stat)))
;; Show aux items
(lyskom-traverse-aux item
(conf-stat->aux-items conf-stat)
(lyskom-aux-item-definition-call item 'status-print item conf-stat))
;; Show all members of CONF-STAT if the user so wishes."
(lyskom-scroll)
(if (lyskom-j-or-n-p
......@@ -410,6 +416,12 @@ otherwise: the conference is read with lyskom-completing-read."
(lyskom-format-insert 'has-motd conf-stat)
(lyskom-view-text (conf-stat->msg-of-day conf-stat))))
;; Show aux items
(lyskom-traverse-aux item
(conf-stat->aux-items conf-stat)
(lyskom-aux-item-definition-call item 'status-print item conf-stat))
;; "Show all conferences CONF-STAT is a member of if the user so wishes."
(lyskom-scroll)
(if (null (lyskom-j-or-n-p (lyskom-get-string
......@@ -1238,8 +1250,7 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
'(all) nil nil t)))
(if (not conf-stat)
(lyskom-insert-string 'somebody-deleted-that-conf)
(let ((garb-nice (lyskom-read-number
(lyskom-get-string 'new-garb-nice-q))))
(let ((garb-nice (lyskom-read-number 'new-garb-nice-q)))
(lyskom-format-insert 'garb-nice-for-is
conf-stat
garb-nice)
......@@ -1478,9 +1489,7 @@ current conference to another session."
(interactive (list
(cond
((null current-prefix-arg)
(lyskom-read-number
(lyskom-get-string 'postpone-prompt)
kom-postpone-default))
(lyskom-read-number 'postpone-prompt kom-postpone-default))
(t (prefix-numeric-value current-prefix-arg)))))
(let ((len (read-list-length lyskom-reading-list))
......@@ -1932,8 +1941,7 @@ is alive."
(secret nil)
(aux nil))
(cond ((eq type 'text)
(setq objno
(lyskom-read-number (lyskom-get-string 'label-what-text)))
(setq objno (lyskom-read-number 'label-what-text))
(setq object (blocking-do 'get-text-stat objno))
(when (null object)
(lyskom-error 'no-such-text-no objno))
......@@ -1991,14 +1999,14 @@ is alive."
(cond
((null current-prefix-arg) lyskom-current-text)
((integerp current-prefix-arg) current-prefix-arg)
((listp current-prefix-arg)
(lyskom-read-number (lyskom-get-string prompt)))
((listp current-prefix-arg) (lyskom-read-number prompt))
(t (signal 'lyskom-internal-error (list command)))))
(def-kom-command kom-fast-reply (&optional text-no)
"Add a fast reply to a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'what-fast-reply-no
'kom-fast-reply)))
(lyskom-format-insert 'fast-replying text-no)
(lyskom-fast-reply text-no
(lyskom-read-string
(lyskom-get-string 'fast-reply-prompt)
......@@ -2011,7 +2019,7 @@ is alive."
"Convenience function to add agreement."
(interactive (list (lyskom-read-text-no-prefix-arg 'what-agree-no
'kom-agree)))
(cache-del-text-stat text-no)
(lyskom-format-insert 'agreeing text-no)
(lyskom-fast-reply text-no
(lyskom-read-string (lyskom-get-string 'agree-prompt)
(lyskom-get-string 'default-agree-string)
......@@ -2029,4 +2037,95 @@ is alive."
(lyskom-create-aux-item-flags
nil nil nil nil nil nil nil nil)
0 message)))))
;;; ======================================================================
;;; FAQ Management
;;;
(def-kom-command kom-add-faq (&optional conf-no text-no)
"Add a FAQ to a conference"
(interactive (list (lyskom-read-conf-no 'conf-to-add-faq '(conf) nil nil t)
(lyskom-read-number 'text-to-add-as-faq)))
(let ((text (blocking-do 'get-text-stat text-no))
(current-faqs nil))
(if (null text)
(lyskom-format-insert 'no-such-text-no text-no)
(lyskom-format-insert 'adding-faq conf-no text-no)
(cache-del-text-stat text-no)
(cache-del-conf-stat conf-no)
(lyskom-report-command-answer
(blocking-do 'modify-conf-info
conf-no
nil
(list (lyskom-create-aux-item
0 14 0 0
(lyskom-create-aux-item-flags nil nil nil nil
nil nil nil nil)
0
(int-to-string text-no))))))))
(def-kom-command kom-del-faq (&optional conf-no text-no)
"Remove a FAQ from a conference"
(interactive)
(let* ((conf-stat (if conf-no
(blocking-do 'get-conf-stat conf-no)
(lyskom-read-conf-stat 'conf-to-del-faq '(conf) nil nil t)))
(faq-list (when conf-stat
(let ((tmp nil))
(lyskom-traverse-aux item
(conf-stat->aux-items conf-stat)
(progn
(when (eq (aux-item->tag item) 14)
(setq tmp (cons (cons (aux-item->data item) (aux-item->aux-no item)) tmp)))))
tmp)))
(text-no nil))
(cond
((null conf-stat)
(lyskom-format-insert 'conf-no-does-not-exist-r conf-no))
((null faq-list)
(lyskom-format-insert 'conf-has-no-faq conf-stat))
(t (setq text-no (completing-read (lyskom-get-string
'text-to-del-as-faq) faq-list nil t))
(when text-no
(lyskom-format-insert 'deleting-faq
(string-to-int text-no)
conf-stat)
(cache-del-text-stat (string-to-int text-no))
(cache-del-conf-stat (conf-stat->conf-no conf-no))
(lyskom-report-command-answer
(blocking-do 'modify-conf-info
(conf-stat->conf-no conf-stat)
(list (cdr (lyskom-string-assoc text-no faq-list)))
nil)))))))
(def-kom-command kom-review-faq (&optional conf-no)
"View the FAQs for a conference"
(interactive (list (lyskom-read-conf-no 'view-which-faq '(conf) nil nil t)))
(let* ((conf-stat (blocking-do 'get-conf-stat conf-no))
(faq-list (when conf-stat
(let ((tmp nil))
(lyskom-traverse-aux item
(conf-stat->aux-items conf-stat)
(progn
(when (eq (aux-item->tag item) 14)
(setq tmp (cons
(string-to-int (aux-item->data item))
tmp)))))
tmp))))
(cond
((null conf-stat)
(lyskom-format-insert 'conf-no-does-not-exist-r conf-no))
((null faq-list)
(lyskom-format-insert 'conf-has-no-faq conf-stat))
(t
(lyskom-format-insert 'review-faq-for-r conf-stat)
(read-list-enter-read-info
(lyskom-create-read-info 'REVIEW
nil
(lyskom-get-current-priority)
(lyskom-create-text-list faq-list)
nil t)
lyskom-reading-list t)))))
......@@ -202,7 +202,9 @@ A string: A name that matched nothing in the database."
(while keep-going
(lyskom-with-lyskom-minibuffer
(setq read-string (completing-read prompt
(setq read-string (completing-read (cond ((stringp prompt) prompt)
((symbolp prompt) (lyskom-get-string prompt))
(t (lyskom-get-string 'conf-prompt)))
'lyskom-read-conf-internal
type
mustmatch
......
......@@ -970,7 +970,7 @@ depending on the value of `kom-lynx-terminal'."
(blocking-do 'get-text-stat (elt arg 1))))
((eq 'conf (car arg))
(conf-stat->aux-items
(blocking-do 'get-conof-stat (elt arg 1))))
(blocking-do 'get-conf-stat (elt arg 1))))
(t nil))))
(while items
(when (eq (aux-item->aux-no (car items)) (elt arg 2))
......@@ -1003,7 +1003,7 @@ depending on the value of `kom-lynx-terminal'."
(blocking-do 'get-text-stat (elt arg 1))))
((eq 'conf (car arg))
(conf-stat->aux-items
(blocking-do 'get-conof-stat (elt arg 1))))
(blocking-do 'get-conf-stat (elt arg 1))))
(t nil))))
(while items
(when (eq (aux-item->aux-no (car items)) (elt arg 2))
......
......@@ -2593,9 +2593,9 @@ to return nil."
(setq numstr
(prog1
(lyskom-read-string
(concat (if prompt
prompt
(lyskom-get-string 'give-a-number))
(concat (cond ((null prompt) (lyskom-get-string 'give-a-number))
((symbolp prompt) (lyskom-get-string prompt))
(t prompt))
(if numdefault
(format " (%d) " numdefault)
" "))
......
......@@ -93,6 +93,8 @@ Value returned is always nil."
(put 'lyskom-traverse-aux 'edebug-form-spec
'(sexp form body))
(put 'lyskom-traverse-aux 'lisp-indent-hook 2)
(put 'lyskom-traverse 'edebug-form-spec
'(sexp form body))
......
......@@ -461,8 +461,8 @@ i svensk datorhistoria. L
(created-by . "Skapat av person %25#1p %#3s(%#2P)\n")
(created-at . "Skapad:%35#1s\n")
(members . "Antal medlemmar: %25#1d\n")
(conf-allows-secret-members . "Hemliga medlemmar: %#1s\n")
(conf-allows-anon-texts . "Anonyma inlgg: %#1s\n")
(conf-allows-secret-members . "Hemliga medlemmar: %#1s\n")
(conf-allows-anon-texts . "Anonyma inlgg: %#1s\n")
(anon-texts-permitted . "Anonyma inlgg r tilltna")
(anon-texts-not-permitted . "Anonyma inlgg r inte tilltna")
(secret-members-permitted . "Hemliga medlemmar r tilltna")
......@@ -478,6 +478,7 @@ i svensk datorhistoria. L
(supervisor-is-no-name . "Organisatr: %25#1p %#3s(%#2P)\n")
(presentation-no . "Presentation: %25#1n\n")
(conf-has-motd . "\n%#1M har en lapp p drren:\n")
(status-conf-generic . "%-40#1s %#2s\n")
(Everybody . "Alla")
(show-members-list-also-q . "Vill du se medlemslistan ocks? ")
......@@ -832,6 +833,7 @@ Gruppmeddelande till %#3M\nfr
(person-or-conf-no-regexp . "\\`[ \t]*[mpMP]\\w*[ \t]+\\([0-9]+\\)\\'")
(session-no-regexp . "\\`[ \t]*[sS]\\w*[ \t]+\\([0-9]+\\)\\'")
(conf-prompt . "Vilket mte/person? ")
;;n From prioritize.el:
......@@ -937,6 +939,7 @@ Du b
(person-does-not-exist . "Person %#1d (finns inte).")
(conference-does-not-exist . "Mte %#1d (finns inte).")
(conf-no-does-not-exist-r . "Mte %#1d finns inte.")
(person-is-anonymous . "Anonym person")
(process-signal . "Signal frn processen.")
......@@ -1128,8 +1131,27 @@ Uppkopplad sedan %#8s%#9s")
(content-type-aux . "Innehllstyp: %#1s")
(content-type-regexp . "Innehllstyp: \\(\\S-+\\)")
(agreeing . "Hller med om inlgg %#1n...")
(fast-replying . "Kort replik till inlgg %#1n...")
(fast-reply-aux . "\"%#1t\" /%#2P/")
(faq-for-conf-aux . "Texten r FAQ fr %#1M <%#1m>")
(faq-in-text-aux . "FAQ i inlgg: %10#1n")
(conf-to-add-faq . "Vilket mte vill du lgga till en FAQ fr? ")
(text-to-add-as-faq . "Vilken text vill du lgga till som FAQ? ")
(adding-faq . "Lgger till inlgg %#1n som FAQ fr %#2M...")
(conf-to-del-faq . "Vilket mte vill du ta bort en FAQ frn? ")
(text-to-del-as-faq . "Vilken text vill du ta bort som FAQ? ")
(deleting-faq . "Tar bort inlgg %#1n som FAQ fr %#2M...")
(conf-has-no-faq . "%#1M har ingen FAQ\n")
(view-which-faq . "terse FAQ fr vilket mte? ")
(review-faq-for-r . "terse FAQ fr %#1M.\n")
(cross-reference-text-status-aux . "Se ven inlgg: %10#1n /%#2P/")
(cross-reference-conf-status-aux . "Se ven mte: <%#1m> %#1M /%#2P/")
(cross-reference-pers-status-aux . "Se ven person: <%#1p> %#1P /%#2P/")
(strange-cross-reference-status . "Se ven: %#1s (vad nu det betyder)")
(cross-reference-text-aux . "Se ven inlgg %#1n /%#2P/")
(cross-reference-conf-aux . "Se ven mte <%#1m> %#1M /%#2P/")
(cross-reference-pers-aux . "Se ven person <%#1p> %#1P /%#2P/")
......@@ -1163,6 +1185,8 @@ Uppkopplad sedan %#8s%#9s")
(label-what-label . "Personligt namn: ")
(label-secret . "Skall andra kunna se namnet? ")
(creating-software-aux . "Skapad med %#1s")
(cant-get-aux-item . "Hittar inte tillggsinformationen")
(aux-item-no-info . "Ingen information tillgnglig\n")
(aux-item-info . "\
......@@ -1357,12 +1381,12 @@ Inneh
(kom-change-language . "ndra sprk")
(kom-calculate . "Berkna")
(kom-list-marks . "Lista markeringar")
(kom-where-is . "Var finns kommandot")
(kom-fast-reply . "Snabb replik")
(kom-agree . "Hlla med")
(kom-add-faq . "Addera FAQ")
(kom-del-faq . "Ta bort FAQ")
(kom-review-faq . "terse FAQ")
))
(lyskom-language-var lyskom-language-codes sv
......
......@@ -958,42 +958,6 @@ Users are encouraged to use their best sense of humor."
server)
;;; =================================================================
;;;
;;; Inherited variables
;;;
;(eval-and-compile
; (def-kom-var lyskom-inherited-variables
; '(
; lyskom-buffer
; lyskom-proc
; lyskom-idle-time-flag
; lyskom-set-last-read-flag
; lyskom-uconf-stats-flag
; lyskom-server-supports
; lyskom-collate-table
; lyskom-server-name
; lyskom-language
; )
; "Variables that all buffers associated with a LysKOM buffer inherit."))
;(eval-and-compile
; (def-kom-var lyskom-protected-variables
; (append '(lyskom-reset-var
; lyskom-dedicated-frame
; kill-buffer-hook
; lyskom-buffer-type
; lyskom-saved-window-configuration)
; lyskom-inherited-variables)
; "Variables that need to be permanent local variables."))
;(mapcar 'lyskom-protect-variable
; lyskom-protected-variables)
(defconst lyskom-commands
'(
describe-mode
......@@ -1125,66 +1089,11 @@ Users are encouraged to use their best sense of humor."
kom-send-alarm
kom-agree
kom-fast-reply
kom-add-faq
kom-del-faq
kom-review-faq
))
;(defconst lyskom-elisp-variables
; '(kom-permissive-completion
; kom-bury-buffers
; kom-ding-on-new-letter
; kom-ding-on-personal-messages
; kom-ding-on-group-messages
; kom-ding-on-common-messages
; kom-ding-on-priority-break
; kom-ding-on-wait-done
; kom-show-personal-messages-in-buffer
; kom-pop-personal-messages
; kom-user-prompt-format
; kom-user-prompt-format-executing
; kom-enabled-prompt-format
; kom-enabled-prompt-format-executing
; kom-do-when-done
; kom-higher-priority-breaks
; kom-login-hook
; kom-membership-default-placement
; kom-membership-default-priority
; kom-mercial
; kom-inhibit-typeahead
; kom-page-before-command
; kom-continuous-scrolling
; kom-permanent-filter-list
; kom-presence-messages-in-buffer
; kom-quit-hook
; kom-show-where-and-what
; kom-who-buffer-size-when-displaying
; kom-default-message-recipient
; kom-write-texts-in-window
; kom-edit-filters-in-window
; kom-list-membership-in-window
; kom-prioritize-in-window
; kom-customize-in-window
; kom-customize-format
; kom-cite-string
; kom-remote-control
; kom-remote-controllers
; kom-self-control
; kom-ansaphone-default-reply
; kom-ansaphone-replies
; kom-ansaphone-record-messages
; kom-ansaphone-show-messages
; kom-show-footnotes-immediately
; kom-follow-comments-outside-membership
; kom-friends
; kom-check-commented-author-membership
; lyskom-fetch-map-nos
; lyskom-new-text-hook
; lyskom-prefetch-conf-tresh
; lyskom-prefetch-confs
; lyskom-who-info-has-changed-hook
; lyskom-language)
; "Tells the client what flags and hooks that are to be saved in the server.