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

Add/Sub anything uses correct reading procedures

Anonymous texts handled
Cleaned up use of kom-buffer and lyskom-buffer
Added Show User Area and Change Conference Type commands
parent ee9105a8
No preview for this file type
......@@ -147,7 +147,16 @@ this function shall be with current-buffer the BUFFER."
((eq msg-no 11)
(lyskom-save-excursion
(set-buffer buffer)
(lyskom-insert-before-prompt (lyskom-get-string 'lyskom-is-full))))
(lyskom-insert-before-prompt (lyskom-get-string 'lyskom-is-full))
; (if (and (eq major-mode 'lyskom-mode)
; (not (listp lyskom-time-last-command))
; kom-auto-quit-when-idle)
; (progn
; (lyskom-insert-before-prompt
; (lyskom-get-string 'session-auto-ended))
; (kom-quit 1)
))
((eq msg-no 12) ; Message to the user (or everybody)
(let ((recipient (lyskom-parse-num))
......
......@@ -446,109 +446,78 @@ Also adds to lyskom-to-do-list."
;;; Uttr{d - Subtract yourself as a member from a conference
;;; Uteslut medlem - Subtract somebody else as a member
;;; Author: Inge Wallin
;;; Author: David Byers
;;; Based on code by Inge Wallin
;; Subtract another person
(defun kom-sub-member ()
"Subtract a person as a member from a conference. Ask for
the name of the person."
"Subtract a person as a member from a conference. Ask for the name
of the person."
(interactive)
(lyskom-start-of-command 'kom-sub-member)
(lyskom-completing-read 'main 'lyskom-sub-member
(lyskom-get-string 'who-to-exclude)
'person nil ""))
(defun lyskom-sub-member (pers-no)
"Ask which conference the person should be subtracted from."
(lyskom-completing-read 'main 'lyskom-sub-member-2
(lyskom-get-string 'where-from-exclude)
nil nil ""
pers-no))
(lyskom-sub-member
(lyskom-read-conf-stat (lyskom-get-string 'who-to-exclude) 'pers nil "")
(lyskom-read-conf-stat (lyskom-get-string 'where-from-exclude)
'all nil "")))
;; Subtract self
(defun kom-sub-self ()
"Subtract this person as a member from a conference."
(interactive)
(lyskom-start-of-command 'kom-sub-self)
(lyskom-completing-read 'main 'lyskom-sub-member-2
(lyskom-get-string 'leave-what-conf)
nil nil
(let ((ccn (if (zerop lyskom-current-conf)
""
(conf-stat->name
(blocking-do 'get-conf-stat
lyskom-current-conf)))))
(or ccn ""))
lyskom-pers-no))
(defun lyskom-sub-member-2 (conf-no pers-no)
"Get the conf-stat for both the person and the conference and
send them into lyskom-sub-member-3"
(lyskom-collect 'main)
(initiate-get-conf-stat 'main nil conf-no)
(initiate-get-conf-stat 'main nil pers-no)
(lyskom-use 'main 'lyskom-sub-member-3))
(defun lyskom-sub-member-3 (conf-conf-stat pers-conf-stat)
"Does the deletion of a person from a conf if all needed info could be fetched.
If either the person or the confs conf-stat could not be fetched it tells the
user so instead."
(cond ((null pers-conf-stat)
(lyskom-insert-string 'error-fetching-person)
(lyskom-end-of-command))
((null conf-conf-stat)
(lyskom-insert-string 'error-fetching-conf)
(lyskom-end-of-command))
(t
(if (= (conf-stat->conf-no pers-conf-stat)
lyskom-pers-no)
(lyskom-format-insert 'unsubscribe-to
conf-conf-stat)
(lyskom-format-insert 'exclude-from
pers-conf-stat
conf-conf-stat)
(initiate-sub-member 'main 'lyskom-sub-member-answer
(conf-stat->conf-no conf-conf-stat)
(conf-stat->conf-no pers-conf-stat)
conf-conf-stat pers-conf-stat)
(if (= (conf-stat->conf-no pers-conf-stat) lyskom-pers-no)
(initiate-get-membership 'main 'lyskom-set-membership
(conf-stat->conf-no
pers-conf-stat)))))))
(defun lyskom-sub-member-answer (answer conf-conf-stat pers-conf-stat)
"Handles the answer after the unsubscribe call to the server."
(if (not answer)
(lyskom-format-insert
'unsubscribe-failed
(if (= (conf-stat->conf-no pers-conf-stat) lyskom-pers-no)
(lyskom-get-string 'You)
pers-conf-stat)
conf-conf-stat)
(lyskom-insert-string 'done)
(if (and (= (conf-stat->conf-no pers-conf-stat)
lyskom-pers-no)
(= (conf-stat->conf-no conf-conf-stat)
lyskom-current-conf))
(progn
(set-read-list-empty lyskom-reading-list)
(setq lyskom-current-conf 0)))
(if (= (conf-stat->conf-no pers-conf-stat)
lyskom-pers-no)
(setq lyskom-last-conf-received (1- lyskom-last-conf-received)))
(read-list-delete-read-info (conf-stat->conf-no conf-conf-stat)
lyskom-to-do-list))
(lyskom-run 'main 'lyskom-end-of-command))
(lyskom-sub-member
(blocking-do 'get-conf-stat lyskom-pers-no)
(lyskom-read-conf-stat (lyskom-get-string 'leave-what-conf)
'all nil
(let ((ccn
(if (or (zerop lyskom-current-conf))
""
(conf-stat->name
(blocking-do 'get-conf-stat
lyskom-current-conf)))))
(or ccn "")))))
(defun lyskom-sub-member (pers conf)
"Remove the person indicated by PERS as a member of CONF."
(let ((reply nil)
(self (= (conf-stat->conf-no pers) lyskom-pers-no)))
(cond ((null pers) (lyskom-insert-string 'error-fetching-person))
((null conf) (lyskom-insert-string 'error-fetching-conf))
(t
(if self
(lyskom-format-insert 'unsubscribe-to conf)
(lyskom-format-insert 'exclude-from pers conf))
(setq reply (blocking-do 'sub-member
(conf-stat->conf-no conf)
(conf-stat->conf-no pers)))
(if self
(lyskom-set-membership (blocking-do 'get-membership
lyskom-pers-no)))
(if (not reply)
(lyskom-format-insert 'unsubscribe-failed
(if self
(lyskom-get-string 'You)
(conf-stat->conf-name pers))
(conf-stat->conf-name conf))
(lyskom-insert-string 'done)
(if (and self
(= (conf-stat->conf-no conf)
lyskom-current-conf))
(progn
(set-read-list-empty lyskom-reading-list)
(setq lyskom-current-conf 0)))
(if self
(setq lyskom-last-conf-received
(1- lyskom-last-conf-received)))
(read-list-delete-read-info (conf-stat->conf-no conf)
lyskom-to-do-list)))))
(lyskom-end-of-command))
;;; ================================================================
;;; Skapa m|te - Create a conference
......@@ -1715,120 +1684,122 @@ footnotes) to it as read in the server."
;;; Addera mottagare - Add recipient
;;; Subtrahera mottagare - Subtract recipient
;;; Author: Inge Wallin
;;; Author: David Byers
;;; Based on code by Inge Wallin
(defun kom-add-recipient (text-no-arg)
"Add a recipient to a text. If the argument TEXT-NO-ARG is non-nil,
"Add a recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-add-recipient)
(initiate-get-conf-stat 'main 'lyskom-add-sub-rcpt lyskom-last-added-rcpt
text-no-arg
(lyskom-get-string 'text-to-add-recipient)
t))
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-rcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-recipient)
'add-rcpt
conf)))
(defun kom-add-copy (text-no-arg)
"Add a recipient to a text. If the argument TEXT-NO-ARG is non-nil,
"Add a cc recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-add-copy)
(initiate-get-conf-stat 'main 'lyskom-add-sub-rcpt lyskom-last-added-ccrcpt
text-no-arg (lyskom-get-string 'text-to-add-copy)
'copy))
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-ccrcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-copy)
'add-copy
conf)))
(defun kom-sub-recipient (text-no-arg)
"Subtract a recipient from a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-sub-recipient)
(initiate-get-conf-stat 'main 'lyskom-add-sub-rcpt lyskom-current-conf
text-no-arg
(lyskom-get-string 'text-to-delete-recipient)
nil))
(let ((conf (blocking-do 'get-conf-stat lyskom-current-conf)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-delete-recipient)
'sub
conf)))
(defun lyskom-add-sub-recipient (text-no-arg
prompt
action
conf)
(let ((text-no (lyskom-read-number prompt
(or text-no-arg lyskom-current-text)))
(conf-to-add-to (lyskom-read-conf-stat
(lyskom-get-string
(cond ((eq action 'add-rcpt) 'who-to-add-q)
((eq action 'add-copy) 'who-to-add-copy-q)
((eq action 'sub) 'who-to-sub-q)
(t (lyskom-error "internal error"))))
'all
nil
(if conf (conf-stat->name conf) "")))
(result nil))
(setq result
(cond ((eq action 'add-rcpt)
(lyskom-format-insert 'adding-name-as-recipient
conf-to-add-to
text-no)
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'recpt)
(setq lyskom-last-added-rcpt
(conf-stat->conf-no conf-to-add-to)))
((eq action 'add-copy)
(lyskom-format-insert 'adding-name-as-copy
conf-to-add-to
text-no)
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'cc-recpt)
(setq lyskom-last-added-ccrcpt
(conf-stat->conf-no conf-to-add-to)))
((eq action 'sub)
(lyskom-format-insert 'remove-name-as-recipient
(conf-stat->conf-no conf-to-add-to)
text-no)
(blocking-do 'sub-recipient
text-no
(conf-stat->conf-no conf-to-add-to)))
(t (lyskom-error "internal error"))))
(cache-del-text-stat text-no)
(lyskom-handle-command-answer result)))
(defun lyskom-add-sub-rcpt (conf text-no-arg prompt do-add)
"Second part of the add/subtract recipient. Fixes default."
(if conf ;+++ annan felhantering
(lyskom-add-sub-recipient text-no-arg prompt do-add
(conf-stat->name conf))
(lyskom-add-sub-recipient text-no-arg prompt do-add)))
(defun lyskom-add-sub-recipient (text-no-arg prompt do-add &optional default)
"Get the number of the text that is to be added or subtracted a recipient
to/from
Arguments: TEXT-NO-ARG: an argument as it is gotten from (interactive P)
PROMPT: A string that is used when prompting for a number.
DO-ADD: NIL if a recipient should be subtracted.
Otherwise a recipient is added
DEFAULT: The default conference to be prompted for."
(let ((text-no (cond ((null text-no-arg) lyskom-current-text)
(t text-no-arg))))
(setq text-no (lyskom-read-number prompt text-no))
(lyskom-completing-read-conf-stat
'main 'lyskom-add-sub-recipient-2
(cond
((eq do-add 'copy)
(lyskom-get-string 'who-to-add-copy-q))
(do-add (lyskom-get-string 'who-to-add-q))
(t (lyskom-get-string 'who-to-sub-q)))
nil nil (or default "") text-no do-add)))
(defun lyskom-add-sub-recipient-2 (conf-stat text-no do-add)
"Tell what we do and do the call to the server."
(if do-add
(progn
(lyskom-format-insert (if (eq do-add 'copy)
'adding-name-as-copy
'adding-name-as-recipient)
conf-stat
text-no)
(initiate-add-recipient
'main 'lyskom-handle-command-answer
text-no (conf-stat->conf-no conf-stat) (if (eq do-add 'copy)
'cc-recpt
'recpt))
(if (eq do-add 'copy)
(setq lyskom-last-added-ccrcpt (conf-stat->conf-no conf-stat))
(setq lyskom-last-added-rcpt (conf-stat->conf-no conf-stat))))
(lyskom-format-insert 'remove-name-as-recipient
conf-stat
text-no)
(initiate-sub-recipient
'main 'lyskom-handle-command-answer
text-no (conf-stat->conf-no conf-stat)))
(cache-del-text-stat text-no))
;;; ================================================================
;;; Addera kommentar - Add comment
;;; Subtrahera kommentar - Subtract comment
;;; Author: Lars Willf|r
;;; Author: David Byers
;;; Heavily based on code by Lars Willf|r
(defun kom-add-comment (text-no-arg)
"Add a text as a comment to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
"Add a text as a comment to another text."
(interactive "P")
(lyskom-start-of-command 'kom-add-comment)
(lyskom-add-sub-comment text-no-arg
(lyskom-add-sub-comment text-no-arg
(lyskom-get-string 'text-to-add-comment-to)
t))
(defun kom-sub-comment (text-no-arg)
"Subtract a recipient from a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
"Remove a comment from a text."
(interactive "P")
(lyskom-start-of-command 'kom-sub-comment)
(lyskom-add-sub-comment text-no-arg
(lyskom-get-string 'text-to-delete-comment-from)
nil))
(defun lyskom-add-sub-comment (text-no-arg prompt do-add)
"Get the number of the text that is going to have a comment added to it or
subtracted from it
......@@ -1836,37 +1807,25 @@ Arguments: TEXT-NO-ARG: an argument as it is gotten from (interactive P)
PROMPT: A string that is used when prompting for a number.
DO-ADD: NIL if a comment should be subtracted.
Otherwise a comment is added"
(let ((text-no (if (null text-no-arg)
lyskom-current-text
text-no-arg))
(comment-text-no))
(setq text-no (lyskom-read-number prompt text-no))
(setq comment-text-no
(lyskom-read-number
(if do-add
(lyskom-get-string 'text-to-add-q)
(lyskom-get-string 'text-to-remove-q))
(if (= text-no lyskom-current-text)
nil
lyskom-current-text)))
(if do-add
(lyskom-format-insert 'add-comment-to
comment-text-no
text-no)
(lyskom-format-insert 'sub-comment-to
comment-text-no
text-no)
(if do-add
(initiate-add-comment 'main
'lyskom-handle-command-answer
comment-text-no
text-no)
(initiate-sub-comment 'main
'lyskom-handle-command-answer
comment-text-no
text-no))
(let* ((text-no (lyskom-read-number prompt
(or text-no-arg lyskom-current-text)))
(comment-text-no (lyskom-read-number
(lyskom-get-string
(if do-add 'text-to-add-q 'text-to-remove-q))
(if (eq text-no lyskom-current-text)
nil
lyskom-current-text))))
(lyskom-format-insert (if do-add 'add-comment-to 'sub-comment-to)
comment-text-no
text-no)
(cache-del-text-stat text-no)
(cache-del-text-stat comment-text-no))))
(cache-del-text-stat comment-text-no)
(lyskom-handle-command-answer
(blocking-do (if do-add 'add-comment 'sub-comment)
comment-text-no
text-no))))
;;; ================================================================
......
......@@ -52,9 +52,9 @@
"-membership"))))
(save-window-excursion
(set-buffer buffer)
(make-local-variable 'kom-buffer)
(make-local-variable 'lyskom-buffer)
(local-set-key [mouse-2] 'kom-mouse-2)
(setq kom-buffer buf)
(setq lyskom-buffer buf)
(erase-buffer)
(insert (lyskom-get-string 'your-memberships))
(insert (lyskom-get-string 'memberships-header)))
......@@ -1289,3 +1289,47 @@ current conference to another session."
(kom-bury)
(switch-to-buffer (car buffers))))))
;;;============================================================
;;; Visa user-arean (kom-show-user-area)
;;;
;;; Author: David Byers
(defun kom-show-user-area ()
"Get and display the user area of the current person"
(interactive)
(lyskom-start-of-command 'kom-show-user-area)
(let ((pers-stat (blocking-do 'get-pers-stat lyskom-pers-no)))
(lyskom-view-text 'main (pers-stat->user-area pers-stat)
nil nil nil nil nil nil)
(lyskom-run 'main 'lyskom-end-of-command)))
;;;============================================================
;;; ndra mtestyp (kom-change-conf-type)
;;;
;;; Author: Tomas Abrahamsson & David Byers
(defun kom-change-conf-type ()
"Change type of a conference"
(interactive)
(lyskom-start-of-command 'kom-change-conf-type)
(let* ((conf-no (lyskom-read-conf-no
(lyskom-get-string 'what-conf-to-change)
'conf nil ""))
(open (j-or-n-p (lyskom-get-string 'anyone-member)))
(secret (if (not open) (j-or-n-p (lyskom-get-string 'secret-conf))))
(orig (j-or-n-p (lyskom-get-string 'comments-allowed))))
(cache-del-conf-stat conf-no)
(if (not (blocking-do 'set-conf-type
conf-no
(lyskom-create-conf-type (not open)
(not orig)
secret
nil)))
(progn (lyskom-insert-string 'nope)
(lyskom-format-insert 'error-code
(lyskom-get-error-text lyskom-errno)
lyskom-errno))))
(lyskom-end-of-command))
......@@ -332,10 +332,19 @@ Entry to this mode runs lyskom-edit-mode-hook."
;;; Functions bound to keyboard seqences in lyskom-edit-mode
;;;
(defun kom-edit-send-anonymous ()
"Send the text anonymously to the server."
(interactive)
(lyskom-edit-send 'initiate-create-anonymous-text))
(defun kom-edit-send ()
"Send the text to the server."
(interactive)
(lyskom-edit-send 'initiate-create-text))
(defun lyskom-edit-send (send-function)
"Send the text to the server by calling SEND-FUNCTION."
(interactive)
(if (or (string= mode-name lyskom-edit-mode-name)
(j-or-n-p (lyskom-get-string 'already-sent)))
(progn
......@@ -352,7 +361,7 @@ Entry to this mode runs lyskom-edit-mode-hook."
(setq lyskom-dont-change-prompt t)
(setq lyskom-is-writing nil)
(lyskom-tell-internat 'kom-tell-send)
(initiate-create-text 'sending 'lyskom-create-text-handler
(funcall send-function 'sending 'lyskom-create-text-handler
(concat subject "\n" message) misc-list
buffer)))
(if kom-dont-restore-window-after-editing
......
......@@ -171,6 +171,7 @@ Email-address:\n\nOther:\t")
(what-conf-to-delete . "Conference/user to delete: ")
(what-conf-to-change . "Conference to modify: ")
(confirm-delete-pers-or-conf . "Really delete %#1s %#2s? ")
(the-pers . "the user")
(the-conf . "the conference")
......@@ -235,6 +236,11 @@ Send a letter to %#2s to apply for membership.")
LysKOM session finished
You are now disconnected from the server
--------------------------------------------\n")
(session-auto-ended . "
============================================================
Disconnecting from LysKOM since all connections are in use
and you have finished reading. Please come back later.
============================================================\n\n")
(what-to-change-pres-you . "Change presentation of who/what (yourself): ")
(who-to-put-motd-for . "Post note on the door of who/what (yourself): ")
......@@ -432,7 +438,7 @@ The message you were sending to %#1s was:
(buggrepport-compilestart . "Creating bug report...")
(buggrepport-compileend . "Creating bug report...done")
(buggreport-description . "This is what I was doing:
(Fill in your comments below)\n================\n\n
\(Fill in your comments below\)\n================\n\n
================
In the information below are the 100 most recently pressed keys from
your emacs. If you recently logged on, you password may be contained in
......@@ -564,6 +570,7 @@ Mark the envelope with \"LysKOM bug report\"\n\n")
(name-has-changed-to-name-r . "%#1s has changed name to %#2s\n")
(you-changed-name-to . "You have now changed your name to %#1s.\n")
(database-sync . "Synching database.")
(lyskom-is-full . "\
===========================================================
Message from the LysKOM-system: Somebody tried to connect,
......@@ -678,6 +685,7 @@ Group message to %#3s from %#2s (%#4s):
(person-does-not-exist . "User %#1d (does not exist).")
(conf-does-not-exist . "Conference %#1d (does not exist).")
(person-is-anonymous . "Anonymous user")
(process-signal . "Signal from the process.")
(closed-connection . "
......@@ -844,6 +852,7 @@ Error message: %#1s**************************************************")
(kom-filter-text "Filter contents")
(kom-list-filters "List filters")
(kom-show-user-area "Show user area")
(kom-change-conference-type "Change conference type")
)
"A list of LysKOM-commands recognized by the extended parser.")
......@@ -903,6 +912,9 @@ Cf. paragraph-start.")
(define-key lyskom-mode-map "s" 'lyskom-S-prefix)
(define-key lyskom-mode-map [mouse-2] 'kom-mouse-2)
(define-key lyskom-mode-map "*" 'kom-key-mouse-2)
(define-key lyskom-mode-map "\M-f" 'kom-next-link)
(define-key lyskom-mode-map "\M-b" 'kom-previous-link)
; These should be first in order to be last in the menu of alternatives.
(define-key lyskom-mode-map "A?" 'lyskom-help)
......@@ -1286,7 +1298,8 @@ Users are encouraged to use their best sense of humor.")
(copy-face 'default 'kom-text-face))
(lyskom-make-face 'kom-subject-face
(copy-face 'kom-text-face 'kom-subject-face)
(set-face-foreground 'kom-subject-face "dark green"))
(set-face-foreground 'kom-subject-face
"dark green"))
(lyskom-make-face 'kom-text-no-face
(copy-face 'kom-text-face 'kom-text-no-face)))
(progn
......
......@@ -30,6 +30,10 @@
;;;; This file contains the filter editor
;;;;
(defvar filter-edit-currently-edited-filter-entry-list nil
"List of filters currently being edited in a filter editor")
;;;
;;; Utility functions
;;;
......@@ -200,15 +204,16 @@ nil means WHERE is not in any entry."
(let ((entry-no (lyskom-filter-edit-locate-no where)))
(if (= -1 entry-no)
nil
(elt entry-list entry-no))))
(elt filter-edit-currently-edited-filter-entry-list entry-no))))