startup.el 38.2 KB
Newer Older
David Byers's avatar
David Byers committed
1
;;;;; -*-coding: iso-8859-1;-*-
Linus Tolke's avatar
Linus Tolke committed
2
3
;;;;;
;;;;; $Id$
4
;;;;; Copyright (C) 1991-2002  Lysator Academic Computer Association.
Linus Tolke's avatar
Linus Tolke committed
5
;;;;;
6
;;;;; This file is part of the LysKOM Emacs LISP client.
Linus Tolke's avatar
Linus Tolke committed
7
8
9
;;;;; 
;;;;; LysKOM is free software; you can redistribute it and/or modify it
;;;;; under the terms of the GNU General Public License as published by 
10
;;;;; the Free Software Foundation; either version 2, or (at your option) 
Linus Tolke's avatar
Linus Tolke committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
;;;;; any later version.
;;;;; 
;;;;; LysKOM is distributed in the hope that it will be useful, but WITHOUT
;;;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;;;;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
;;;;; for more details.
;;;;; 
;;;;; You should have received a copy of the GNU General Public License
;;;;; along with LysKOM; see the file COPYING.  If not, write to
;;;;; Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
;;;;; or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
;;;;; MA 02139, USA.
;;;;;
;;;;; Please mail bug reports to bug-lyskom@lysator.liu.se. 
;;;;;
Per Cederqvist's avatar
.    
Per Cederqvist committed
26
27
28
29
30
31
32
33
34
35
36
;;;; ================================================================
;;;; ================================================================
;;;;
;;;; File: startup.el
;;;;
;;;; This file contains functions that are called only when lyskom
;;;; is loaded, started or when a new user is logged in during a 
;;;; session.
;;;;


37
38
39
40
41
(setq lyskom-clientversion-long 
      (concat lyskom-clientversion-long
	      "$Id$\n"))


Per Cederqvist's avatar
.    
Per Cederqvist committed
42
43
44
45
;;; ================================================================
;;;                         Start kom.


46
47
48
49
50
51
52
53
(defvar lyskom-www-proxy-connect-phase 1
  "Phase when reading connection response from www-proxy:
1: (initial phase) waiting for the
   string \"HTTP/1.0 2000 Connection established\"
2: we have seen the connection string. After this, it may come lines stating
   proxy-agents and other things. They all seem to end with an empty line,
   so in this phase we wait for an empty line.")

54
;;;###autoload
55
(defun lyskom (&optional host username password session-priority invisiblep)
Per Cederqvist's avatar
.    
Per Cederqvist committed
56
  "Start a LysKOM session.
57
Optional arguments: HOST, USERNAME, PASSWORD and INVISIBLEP.
Linus Tolke's avatar
Linus Tolke committed
58

59
60
61
A numeric prefix argument sets the session priority. A prefix argument
of `C-u', on the other hand, logs in the session without notifying other
clients of the event. See lyskom-mode for details on lyskom."
David Kågedal's avatar
David Kågedal committed
62
63
64
65
  (interactive (list (lyskom-read-server-name
		      (lyskom-format 'server-q
				     (or (getenv "KOMSERVER")
					 lyskom-default-server)))
Per Cederqvist's avatar
.    
Per Cederqvist committed
66
		     nil
67
68
69
		     nil
		     (if current-prefix-arg
			 (prefix-numeric-value current-prefix-arg)
70
71
		       nil)
		     (and current-prefix-arg (listp current-prefix-arg))))
Per Cederqvist's avatar
.    
Per Cederqvist committed
72

73
  (run-hooks 'lyskom-init-hook)
74
  (setq username
David Kågedal's avatar
David Kågedal committed
75
	(or username (getenv "KOMNAME")))
76
  (setq password
David Kågedal's avatar
David Kågedal committed
77
	(or password (getenv "KOMPASSWORD")))
Per Cederqvist's avatar
.    
Per Cederqvist committed
78
  (if (zerop (length host))
79
      (let* ((env-kom (getenv "KOMSERVER"))
80
	     (canon (lyskom-string-rassoc env-kom kom-server-aliases)))
81
82
83
	(setq host (or (car canon)
		       env-kom
		       lyskom-default-server))))
84
85
  (let ((port 4894)
	(init-done nil))
Per Cederqvist's avatar
.    
Per Cederqvist committed
86
87
88
89
90
91
92
93
94
    (cond				;Allow "nanny:4892" to use port 4892.
     ((string-match ":" host)
      (setq port (string-to-int (substring host (match-end 0))))
      (cond
       ((zerop (match-beginning 0))
	(setq host lyskom-default-server))
       (t
	(setq host (substring host 0 (match-beginning 0)))))))

David Byers's avatar
David Byers committed
95
96
97
    (let* ((duplicate-buffers
            (delq nil
                  (mapcar (lambda (buffer)
98
                            (and (lyskom-buffer-p buffer t)
David Byers's avatar
David Byers committed
99
100
101
102
103
104
105
106
107
                                 (buffer-name buffer)
                                 (string-match (regexp-quote host)
                                               (buffer-name buffer))
                                 (save-excursion (set-buffer buffer)
                                                 (and 
                                                  (boundp 'lyskom-server-port)
                                                  (eq port lyskom-server-port)))
                                 buffer))
                          (buffer-list))))
David Kågedal's avatar
David Kågedal committed
108
	   (name nil)
David Byers's avatar
David Byers committed
109
	   (proc nil)
David Byers's avatar
David Byers committed
110
           (buffer (car duplicate-buffers))
111
	   ;; (alive (lyskom-buffer-p buffer))
David Byers's avatar
David Byers committed
112
           (reused-buffer nil))
David Byers's avatar
David Byers committed
113
114
      

115
116
117
118
      ;;<<<<<<< startup.el
      ;;      (if (and buffer
      ;;	       alive
      ;;=======
119
      (if (and (lyskom-buffer-p buffer nil)
120
121
	       (not (prog1
			(j-or-n-p (lyskom-get-string
122
				   'start-new-session-same-server))
123
		      (message ""))))
David Byers's avatar
David Byers committed
124
125
126
	  (progn 
            (switch-to-buffer buffer)
            (setq reused-buffer t))
David Kågedal's avatar
David Kågedal committed
127
128
	(unwind-protect
	    (progn
129
	      (cond ((and buffer (not (lyskom-buffer-p buffer)))
David Kågedal's avatar
David Kågedal committed
130
		     (set-buffer buffer)
David Byers's avatar
David Byers committed
131
                     (setq reused-buffer t)
David Kågedal's avatar
David Kågedal committed
132
		     (goto-char (point-max))
133
134
135
136
137
                     (lyskom-insert
                      (format (lyskom-get-string 'new-session-in-buffer)
                              (lyskom-format-time
                               'timeformat-day-yyyy-mm-dd-hh-mm-ss)))
                     (setq name (buffer-name buffer)))
David Kågedal's avatar
David Kågedal committed
138
		    (t
139
		     (setq buffer (lyskom-generate-new-buffer host))
David Kågedal's avatar
David Kågedal committed
140
		     (setq name (buffer-name buffer))))
David Byers's avatar
David Byers committed
141
142
143
144
145
146
147
148
149
150
              (let* ((proxy-host-string
                      (cond ((stringp kom-www-proxy) kom-www-proxy)
                            ((listp kom-www-proxy)
                             (or (cdr (lyskom-string-assoc host kom-www-proxy))
                                 (cdr (assq t kom-www-proxy))
                                 nil))
                            (t nil)))
                     (proxy-host nil)
                     (proxy-port nil)
                     (match (string-match "\\(.*\\):\\([0-9]+\\)"
151
152
                                          (or proxy-host-string "")))
                     (headers nil))
David Byers's avatar
David Byers committed
153
154
155
156
157
158
159
160
161
                (setq proxy-host (or (and match
                                          (match-string 1 proxy-host-string))
                                     proxy-host-string)
                      proxy-port (or (and match
                                          (string-to-int
                                           (match-string 2
                                                         proxy-host-string)))
                                     80))
                (cond (proxy-host
162
163
164
165
166
167
168
169
170
171
172
                       (setq headers 
                             (cond ((stringp kom-www-proxy-headers)
                                    (list kom-www-proxy-headers))
                                   ((and (listp kom-www-proxy-headers)
                                         (stringp (car kom-www-proxy-headers)))
                                    kom-www-proxy-headers)
                                   ((and (listp kom-www-proxy-headers)
                                         (consp (car kom-www-proxy-headers)))
                                    (cdr (or (lyskom-string-assoc proxy-host
                                                                  kom-www-proxy-headers)
                                             (assq t kom-www-proxy-headers))))))
David Byers's avatar
David Byers committed
173
174
175
                       (setq proc (open-network-stream name buffer
                                                       proxy-host
                                                       proxy-port))
176
                       ;; We do explicit coding
177
                       (set-process-coding-system proc 'no-conversion 'no-conversion)
178
179
180
181
182
183
184
185
186

		       ;; Install our filter.
		       ;; Do this before we send the CONNECT command to
		       ;; the proxy, in case the proxy answers fast.
		       (setq lyskom-www-proxy-connect-phase 1)
		       (set-process-filter proc
					   'lyskom-www-proxy-connect-filter)
		       (process-kill-without-query proc nil)

David Byers's avatar
David Byers committed
187
188
                       (lyskom-process-send-string 
                        proc
189
                        (format "CONNECT %s:%d HTTP/1.0\r\n"
190
191
                                host port))

192
193
194
195
196
197
198
                       (mapcar (lambda (header)
                                 (lyskom-process-send-string proc header)
                                 (lyskom-process-send-string proc "\r\n"))
                               headers)
                       (lyskom-process-send-string proc "\r\n")


199
200
201
202
203
204
205
206
207
208
209
		       ;; Now wait for the answer from the proxy
		       ;;
		       ;; This is because anything we send before the
		       ;; connection ack will be thrown away by the proxy
		       ;; so it is bad to try to start talking with the
		       ;; server before the connection is up.
		       (while (eq 'lyskom-www-proxy-connect-filter
				  (process-filter proc))
			 (accept-process-output proc))
		       ;; Now the proxy has connected to the kom server
		       )
David Byers's avatar
David Byers committed
210
                      (t (setq proc (open-network-stream name buffer
211
                                                         host port))
212
                         ;; We do explicit coding
213
                         (set-process-coding-system proc 'no-conversion 'no-conversion))))
David Kågedal's avatar
David Kågedal committed
214
215
216
217
218
219
	      (switch-to-buffer buffer)
	      (lyskom-mode)		;Clearing lyskom-default...
	      (setq lyskom-buffer buffer)
	      (setq lyskom-default-user-name username)
	      (setq lyskom-default-password password)
	      (setq lyskom-server-name host)
220
	      (setq lyskom-server-port port)
David Kågedal's avatar
David Kågedal committed
221
222
223
224
225
	      (setq lyskom-proc proc)
	      (lyskom-setup-faces)
	      (lyskom-insert
	       (lyskom-format 'try-connect lyskom-clientversion host))
	      (set-process-filter proc 'lyskom-connect-filter)
David Byers's avatar
David Byers committed
226
              (process-kill-without-query proc nil)
227
228
229
230
231
	      (lyskom-process-send-string
	       proc
	       (concat "A"
		       (lyskom-format-objects
			(concat (user-login-name)
David Byers's avatar
David Byers committed
232
233
				"%" (system-name)))
                       "\n"))
David Kågedal's avatar
David Kågedal committed
234
235
236
237
238
239
240
241
	      (while (eq 'lyskom-connect-filter (process-filter proc))
		(accept-process-output proc))
	      ;; Now we have got the correct response.
	      (set-process-sentinel proc 'lyskom-sentinel)

	      (save-excursion
		(lyskom-init-parse buffer))

David Byers's avatar
David Byers committed
242
243
244
              ;; Async messages
              (lyskom-accept-async)

245
246
247
	      ;; +++PREFETCH+++
	      (lyskom-setup-prefetch)

David Kågedal's avatar
David Kågedal committed
248
249
250
251
252
	      ;; Tell the server who we are
	      (initiate-set-client-version 'background nil
					   "lyskom.el" lyskom-clientversion)

	      (setq lyskom-server-info (blocking-do 'get-server-info))
253
              (setq lyskom-server-version-info (blocking-do 'get-version-info))
David Byers's avatar
David Byers committed
254
255
256
              (when (or (null lyskom-server-version-info)
                        (<= (version-info->protocol-version 
                             lyskom-server-version-info) 7))
257
258
                (lyskom-error 'too-old-server))

David Kågedal's avatar
David Kågedal committed
259
260
261
	      (lyskom-setup-client-for-server-version)
	      (lyskom-format-insert 
	       'connection-done
262
	       (version-info->software-version lyskom-server-version-info))
263

264
              (when (lyskom-have-call 85)
265
                (setq lyskom-collate-table (blocking-do 'get-collate-table))
266
                (setq lyskom-char-classes nil)
267
                (lyskom-update-command-completion))
268
269
	      (if (not (zerop (server-info->motd-of-lyskom
			       lyskom-server-info)))
270
271
272
273
274
275
276
277
278
		  (blocking-do-multiple ((text (get-text 
                                                (server-info->motd-of-lyskom
                                                 lyskom-server-info)))
                                         (text-stat (get-text-stat
                                                     (server-info->motd-of-lyskom
                                                      lyskom-server-info))))
		    (lyskom-format-insert "%#1t"
		     (if (and text text-stat)
			 (text->decoded-text-mass text text-stat)
David Kågedal's avatar
David Kågedal committed
279
280
281
282
283
		       (lyskom-get-string 'lyskom-motd-was-garbed)))
		    (lyskom-insert "\n")))
	      ;; Can't use lyskom-end-of-command here.
	      (setq lyskom-executing-command nil) 
	      ;; Log in
284
	      (kom-start-anew t session-priority invisiblep)
285
286
287
288
289
290
291
	      (if (memq lyskom-buffer lyskom-buffer-list)
		  (while (not (eq lyskom-buffer (car lyskom-buffer-list)))
		    (setq lyskom-buffer-list
			  (nconc (cdr lyskom-buffer-list)
				 (list (car lyskom-buffer-list)))))
		(setq lyskom-buffer-list
		      (cons lyskom-buffer lyskom-buffer-list)))
David Kågedal's avatar
David Kågedal committed
292
293
294
295
296
	      (setq init-done t))
	  ;; Something went wrong. Lets cleanup everything. :->
	  (if init-done
	      nil
	    (if proc (delete-process proc))
David Byers's avatar
David Byers committed
297
	    (unless reused-buffer (kill-buffer buffer))))))))
Per Cederqvist's avatar
.    
Per Cederqvist committed
298
299


David Byers's avatar
David Byers committed
300
(defun lyskom-accept-async ()
301
302
  (blocking-do 'accept-async '(5 7 8 9 11 12 13 14 15 16 17 18))
  (let* ((ans (blocking-do 'query-async)))
David Byers's avatar
David Byers committed
303
    (unless (memq 15 (listify-vector ans))
David Byers's avatar
David Byers committed
304
305
      (blocking-do 'accept-async '(0 5 7 8 9 11 12 13 14 16 17 18)))))

306
307
308
309
310
311
312

(defun lyskom-www-proxy-connect-filter (proc output)
  "Receive connection acknowledgement from proxy."
  (if lyskom-debug-communications-to-buffer
      (lyskom-debug-insert proc "-----> " output))
  (cond
   ((and (= lyskom-www-proxy-connect-phase 1)
313
	 (string-match "^HTTP/1\\.. 200.*\r\n" output))
314
315
316
317
318
319
320
321
322
323
    (setq lyskom-www-proxy-connect-phase 2)
    ;; safety check: see if the empty line is already in this output
    (lyskom-www-proxy-connect-filter proc output))

   ((and (= lyskom-www-proxy-connect-phase 2)
	 (string-match "^\r\n" output))
    (set-process-filter proc 'lyskom-connect-filter))))



324
(defun lyskom-setup-client-for-server-version ()
325
  "Setup flags according to protocol versions."
David Byers's avatar
David Byers committed
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
  (lyskom-clear-features)
  (let ((protocol-version 
         (version-info->protocol-version lyskom-server-version-info)))

  (when (>= protocol-version 10)
    (lyskom-set-feature bcc-misc t)
    (lyskom-set-feature aux-items t)
    (lyskom-set-feature highest-call 105)
    (lyskom-set-feature local-to-global t))

  (when (>= protocol-version 9)
    (lyskom-set-feature dynamic-session-info t)
    (lyskom-set-feature idle-time t))

  (when (>= protocol-version 8)
    (lyskom-set-feature long-conf-types t))))
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391


;;;(defun lyskom-setup-client-check-version (spec version)
;;;  (let ((relation (elt spec 0))
;;;        (major (elt spec 1))
;;;        (minor (elt spec 2))
;;;        (revision (elt spec 3)))
;;;    (cond ((eq relation '=)
;;;           (and (or (null major) (= major (elt version 0)))
;;;                (or (null minor) (= minor (elt version 1)))
;;;                (or (null revision) (= revision (elt version 2)))))
;;;          ((eq relation '>=)
;;;           (or (and (= (elt version 0) major)
;;;                    (= (elt version 1) minor)
;;;                    (>= (elt version 2) revision))
;;;               (and (= (elt version 0) major)
;;;                    (> (elt version 1) minor))
;;;               (and (> (elt version 0) major))))
;;;          ((eq relation '<)
;;;           (or (and (= (elt version 0) major)
;;;                    (= (elt version 1) minor)
;;;                    (< (elt version 2) revision))
;;;               (and (= (elt version 0) major)
;;;                    (< (elt version 1) minor))
;;;               (and (< (elt version 0) major)))))))


;;;(defun lyskom-setup-client-for-server-version ()
;;; "Set up the supports list and flags for the current server. See
;;;variable documentation for lyskom-server-feautres"
;;;  (let ((result nil)
;;;        (flags nil))
;;;    (mapcar (function
;;;             (lambda (spec)
;;;               (let ((spec-version (elt spec 0))
;;;                     (plist (elt spec 1)))
;;;                 (if (and (lyskom-setup-client-check-version 
;;;                           spec-version
;;;                           lyskom-server-version))
;;;                     (mapcar
;;;                      (function
;;;                       (lambda (x)
;;;                         (cond ((consp x) (setq result (cons x result)))
;;;                               ((symbolp x) (setq flags (cons x flags)))
;;;                               (t (setq result (cons (cons x t) 
;;;                                                     result))))))
;;;                      plist)))))
;;;            lyskom-server-features)
;;;    (mapcar (function (lambda (x) (set x t))) flags)
;;;    (setq lyskom-server-supports result)))
392
393
394
                                             
                                                                 

Per Cederqvist's avatar
.    
Per Cederqvist committed
395
396
(defun lyskom-connect-filter (proc output)
  "Receive connection acknowledgement from server."
397
  (if lyskom-debug-communications-to-buffer
David Kågedal's avatar
David Kågedal committed
398
      (lyskom-debug-insert proc "-----> " output))
399
400
401
402
403
404
  (cond
   ((string-match "^LysKOM\n" output)
    (set-process-filter proc 'lyskom-filter))))



Per Cederqvist's avatar
.    
Per Cederqvist committed
405
406
407
408
409
410


;;; ================================================================
;;;                        Start anew


411
412
413
(defun kom-start-anew (&optional lyskom-first-time-around session-priority invisiblep)
  "Start/login as a new person. If INVISIBLEP is not nil, the login will not be
shown to other users."
Per Cederqvist's avatar
.    
Per Cederqvist committed
414
415
  (interactive)
  (lyskom-start-of-command 'kom-start-anew)
416
  (lyskom-completing-clear-cache)
417
  (let ((old-me lyskom-pers-no)
418
	(new-me nil)
419
	(login-successful nil))
David Kågedal's avatar
David Kågedal committed
420
    (unwind-protect
421
422
423
424
        (progn
          (if lyskom-first-time-around
              nil
            (lyskom-tell-internat 'kom-tell-login))
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
	  ;; We can't allow the prefetch to go on after the new user
	  ;; is logged in, but to shut down the prefetch would be too
	  ;; brutal, since the new login might be cancelled. To
	  ;; prevent the blocking-do calls below from allowing
	  ;; prefetch we set lyskom-inhibit-prefetch locally.
	  (let ((lyskom-inhibit-prefetch t))
	    (while (not new-me)

	      (if (and lyskom-first-time-around
		       lyskom-default-user-name)
		  ;; This is nil if we can't find a unique match.
		  (setq new-me
			(conf-z-info->conf-no
			 (lyskom-lookup-conf-by-name lyskom-default-user-name
						     '(pers)))))
	      (if new-me
		  nil
		(let ((name (lyskom-read-conf-name
			     (lyskom-get-string 'what-is-your-name)
			     '(pers none) t "" t)))
		  (setq new-me
			(or (conf-z-info->conf-no 
			     (lyskom-lookup-conf-by-name name '(pers)))
			    (lyskom-create-new-person name)))))
	      ;; Now new-me contains a number of a person.
	      ;; Lets log him in.
	      (if new-me
		  (let ((conf-stat (blocking-do 'get-conf-stat new-me))
			(lyskom-inhibit-minibuffer-messages t))

		    ;; Previously this code used lyskom-pers-no
		    ;; directly instead of new-me, but that caused
		    ;; problem with asynchrounous code trying to
		    ;; access it.
		    (setq lyskom-pers-no new-me)
		  
		    ;; DEBUG
		    (if (null conf-stat)
			(lyskom-insert "You don't exist. Go away.\n"))

		    (lyskom-insert (concat (conf-stat->name conf-stat) "\n"))
		    (setq lyskom-first-time-around nil)
		    (if (blocking-do 'login new-me
				     (if lyskom-default-password
					 (prog1
					     lyskom-default-password
					   (setq lyskom-default-password nil)
					   (set-default 'lyskom-default-password
							nil))
				       ;; Use password read when creating
				       ;; the person when loggin in new
				       ;; users
				       (or lyskom-is-new-user
					   (silent-read
David Byers's avatar
David Byers committed
479
					    (lyskom-get-string 'password))))
480
                                     (if invisiblep 1 0))
481
482
483
484
			(progn
			  (if lyskom-is-new-user
			      (blocking-do 'add-member
					   (server-info->conf-pres-conf lyskom-server-info)
485
486
487
488
489
					   new-me
                                           100 
                                           1
                                           (lyskom-create-membership-type
                                            nil nil nil nil nil nil nil nil)))
490
491
			  (setq login-successful t))
		      (lyskom-insert-string 'wrong-password)
492
493
494
495
496
497
498
499
500
501
502
                      (when (lyskom-get-aux-item 
                             (server-info->aux-item-list lyskom-server-info)
                             13)        ; e-mail
                        (lyskom-insert 'wrong-password-help)
                        (mapcar (lambda (el)
                                  (lyskom-format-insert 'wrong-password-email
                                                        (aux-item->data el)))
                                (lyskom-get-aux-item 
                                 (server-info->aux-item-list lyskom-server-info)
                                 13)    ; e-mail
                                ))
503
504
505
506
507
508
509
510
		      (setq new-me nil))
		    (setq lyskom-is-new-user nil))))
	    
	    ;; Now we are logged in.
	    (lyskom-insert-string 'are-logged-in)
	    
	    (if (not lyskom-dont-read-user-area)
		(lyskom-read-options))
511
512
513
            (when (or session-priority kom-default-session-priority)
              (setq lyskom-session-priority
                    (or session-priority kom-default-session-priority)))
514
515
516
517
518
519
520
521
522
523
	    (lyskom-run-hook-with-args 'lyskom-change-conf-hook
				       lyskom-current-conf
				       0)
	    (setq lyskom-current-conf 0)
	    ;; (cache-initiate-who-info-buffer (blocking-do 'who-is-on))
	    (cache-set-marked-texts (blocking-do 'get-marks))
	    ;; What is this variable? It is never used. It is ust to
	    ;; fill the cache?
	    (let ((lyskom-who-am-i (blocking-do 'who-am-i)))
	      (if lyskom-who-am-i (setq lyskom-session-no lyskom-who-am-i))))
524
525
          ;; Start the prefetch
          (lyskom-refetch))
David Kågedal's avatar
David Kågedal committed
526
	  
David Byers's avatar
David Byers committed
527
528
      ;; If login succeeded, clear the caches and set the language

529
      (if login-successful
David Byers's avatar
David Byers committed
530
531
532
533
534
535
	  (progn (clear-all-caches)
                 (unless (eq lyskom-language kom-default-language)   
                   (when (lyskom-set-language kom-default-language)
                     (lyskom-format-insert-before-prompt 
                      'language-set-to
                      (lyskom-language-name kom-default-language)))))
536
	(setq lyskom-pers-no old-me))
David Byers's avatar
David Byers committed
537
538
539
540
541
542
543
544

      ;; Show motd and encourage writing a presentation

      (let ((conf-stat (blocking-do 'get-conf-stat lyskom-pers-no)))
        (if (and conf-stat
                 (/= (conf-stat->msg-of-day conf-stat) 0))
            (progn
              (lyskom-insert-string 'you-have-motd)
David Byers's avatar
David Byers committed
545
              (lyskom-view-text (conf-stat->msg-of-day conf-stat))))
David Byers's avatar
David Byers committed
546
547
548
549
550
        (if (and conf-stat
                 (zerop (conf-stat->presentation conf-stat))
                 (not (zerop (conf-stat->no-of-texts conf-stat))))
            (lyskom-insert-string 'presentation-encouragement)))

David Kågedal's avatar
David Kågedal committed
551
      (setq lyskom-is-new-user nil)
David Kågedal's avatar
David Kågedal committed
552
      (lyskom-end-of-command)))
David Byers's avatar
David Byers committed
553

David Kågedal's avatar
David Kågedal committed
554
555
  ;; Run the hook kom-login-hook. We don't want to hang the
  ;; login, just because something crashed here.
David Byers's avatar
David Byers committed
556

David Kågedal's avatar
David Kågedal committed
557
  (condition-case err
558
      (progn
559
560
        (run-hooks 'lyskom-login-hook)
        (run-hooks 'kom-login-hook))
David Kågedal's avatar
David Kågedal committed
561
    (error (lyskom-format-insert-before-prompt
David Byers's avatar
David Byers committed
562
            'error-in-login-hook (format "%s" err)))))
Linus Tolke's avatar
Linus Tolke committed
563
564
565


(defun lyskom-refetch ()
566
567
  "Resets and fetches all reading info.
This is called at login and after prioritize and set-unread."
568
569
  ;; +++PREFETCH+++

570
  ;; The whole membership!
571
572
573
574
  ;; (lyskom-set-membership (blocking-do 'get-membership lyskom-pers-no))
  ;; (setq lyskom-membership-is-read t)
  ;; (setq lyskom-unread-confs (blocking-do 'get-unread-confs lyskom-pers-no))

575
576
  (setq lyskom-membership nil)

David Byers's avatar
David Byers committed
577
578
579
580
  (setq lyskom-to-do-list (lyskom-create-read-list))
  (setq lyskom-reading-list (lyskom-create-read-list))


581
  (lyskom-reset-prefetch)
David Byers's avatar
David Byers committed
582
583
584
585
586
  (let ((lyskom-inhibit-prefetch t))
    (lyskom-prefetch-membership lyskom-pers-no)
    (let ((unreads (blocking-do 'get-unread-confs lyskom-pers-no)))
      (lyskom-traverse conf-no (nreverse (conf-no-list->conf-nos unreads))
        (lyskom-prefetch-one-membership conf-no lyskom-pers-no))))
David Byers's avatar
David Byers committed
587
588
  (lyskom-start-prefetch)
)
589
590


Linus Tolke's avatar
Linus Tolke committed
591
592
593
(defun lyskom-set-membership (membership)
  "Sets lyskom-membership to a new value.
Args: MEMBERSHIP."
David Byers's avatar
David Byers committed
594
595
  (setq lyskom-membership (listify-vector membership))
  (lyskom-sort-membership)
Linus Tolke's avatar
Linus Tolke committed
596
  (setq lyskom-membership-is-read t))
Per Cederqvist's avatar
.    
Per Cederqvist committed
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635


(defun lyskom-print-name (conf-stat)
  "Print the name of the CONF-STAT, with a trailing \n."
  (lyskom-insert (concat (conf-stat->name conf-stat) "\n")))


(defun lyskom-extract-persons (conf-list)
  "Extract persons from a conf-list.
Return a list of pers-nos of all conferences that are persons.
Args: CONF-LIST."
  (lyskom-do-extract-persons-or-confs conf-list t))


(defun lyskom-extract-confs (conf-list)
  "Extract conferences from a conf-list.
Return a list of conf-nos of all conferences that are persons.
Args: CONF-LIST."
  (lyskom-do-extract-persons-or-confs conf-list nil))


(defun lyskom-do-extract-persons-or-confs (conf-list want-persons)
  "Extract persons or conferences from CONF-LIST.
WANT-PERSONS is t for persons, nil for confs."
  (let* ((result nil)
	 (i 0)
	 (nos (conf-list->conf-nos conf-list))
	 (types (conf-list->conf-types conf-list))
	 (len (length nos)))
    (while (< i len)
      (cond
       ((eq (conf-type->letterbox (elt types i))
	    want-persons)
	(setq result (cons (elt nos i)
			   result))))
      (++ i))
    (nreverse result)))


David Kågedal's avatar
David Kågedal committed
636
(defun lyskom-create-new-person (name)
Per Cederqvist's avatar
.    
Per Cederqvist committed
637
638
639
640
641
642
643
644
645
646
  "A new user named NAME (or an old that mis-spelled his name)."
  (lyskom-insert
   (lyskom-format 'first-greeting name))
  (lyskom-scroll)
  (cond
   ((ja-or-nej-p (lyskom-format 'is-name-correct name))
    (let ((password (silent-read (lyskom-get-string 'personal-password))))
      (cond
       ((not (equal password 
		    (silent-read (lyskom-get-string 'repeat-password))))
David Kågedal's avatar
David Kågedal committed
647
	;; Failed to enter the same password twice
Per Cederqvist's avatar
.    
Per Cederqvist committed
648
	(lyskom-insert-string 'repeat-failure)
David Kågedal's avatar
David Kågedal committed
649
	nil)
Per Cederqvist's avatar
.    
Per Cederqvist committed
650
       (t
David Kågedal's avatar
David Kågedal committed
651
	;; Entered the same password twice
David Byers's avatar
David Byers committed
652
653
654
655
656
657
658
659
660
661
662
	(let ((new-person (blocking-do 'create-person name
                                       password
                                       (lyskom-create-flags nil
                                                            nil
                                                            nil
                                                            nil
                                                            nil
                                                            nil
                                                            nil
                                                            nil)
                                       nil)))
David Kågedal's avatar
David Kågedal committed
663
664
665
666
667
668
	  (if (null new-person)
	      (lyskom-insert-string 'could-not-create-you)
	    ;; Raise a flag so the user will be added to the
	    ;; presentation conference after login
	    (setq lyskom-is-new-user password))
	  new-person)))))
Per Cederqvist's avatar
.    
Per Cederqvist committed
669
   (t
David Kågedal's avatar
David Kågedal committed
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
    ;; Do not create a new person
    nil)))


;;(defun lyskom-start-anew-create-handler (pers-no name password)
;;  "A new person has been created. Log in as him."
;;  (cond
;;   ((null pers-no)
;;    (lyskom-insert-string 'could-not-create-you)
;;    (setq lyskom-executing-command nil)
;;    (kom-start-anew))
;;   (t
;;    (initiate-login 'main 'lyskom-add-for-new-person
;;		    pers-no password pers-no lyskom-pers-no)
;;    )))

;;(defun lyskom-add-for-new-person (reply pers-no lyskom-pers-no)
;;  "Add a news person as member in the default presentation conference."
;;  (initiate-add-member 'main 'lyskom-start-anew-login-2
;;		       (server-info->conf-pres-conf lyskom-server-info)
;;		       pers-no 100 1
;;		       pers-no lyskom-pers-no))
Linus Tolke's avatar
Linus Tolke committed
692

Per Cederqvist's avatar
.    
Per Cederqvist committed
693

David Kågedal's avatar
David Kågedal committed
694
695
(defun lyskom-read-server-name (prompt)
  "Read the name of a LysKOM server.
David Kågedal's avatar
David Kågedal committed
696
Copmpletion is done on the servers i kom-server-aliases. If an
David Kågedal's avatar
David Kågedal committed
697
698
699
700
701
702
703
alias name is entered, the corresponding address is returned."
  ;; Create a completion table like
  ;; (("kom.lysator.liu.se" . "kom.lysator.liu.se")
  ;;  ("LysKOM" . "kom.lysator.liu.se"))
  (let ((known-servers
	 (append (mapcar (function (lambda (pair)
				     (cons (car pair) (car pair))))
David Kågedal's avatar
David Kågedal committed
704
			 kom-server-aliases)
David Kågedal's avatar
David Kågedal committed
705
706
		 (mapcar (function (lambda (pair)
				     (cons (cdr pair) (car pair))))
David Kågedal's avatar
David Kågedal committed
707
			 kom-server-aliases)))
David Kågedal's avatar
David Kågedal committed
708
709
	(completion-ignore-case t)
	server)
David Byers's avatar
David Byers committed
710
711
712
713
    (setq server (lyskom-completing-read prompt
                                         (lyskom-maybe-frob-completion-table
                                          known-servers)
                                         nil nil))
714
    (or (cdr (lyskom-string-assoc server known-servers))
David Kågedal's avatar
David Kågedal committed
715
716
717
	server)))
      

Per Cederqvist's avatar
.    
Per Cederqvist committed
718
719
720
;;; ================================================================
;;;                        The LysKOM mode.

721
722
723
;; The LysKOM mode should not be inherited if we create a new buffer
;; and default-major-mode is nil.
(put 'lyskom-mode 'mode-class 'special)
Per Cederqvist's avatar
.    
Per Cederqvist committed
724
725
726
727

(defun lyskom-mode ()
  "\\<lyskom-mode-map>Mode for LysKOM client.
Commands:
David Kågedal's avatar
David Kågedal committed
728
\\[kom-next-command]	Do the default action. This can be to read the next text,select
729
	next conference with unread texts or whatever the prompt says.
David Kågedal's avatar
David Kågedal committed
730
731
732
733
\\[kom-go-to-conf]	Go to a conference. LysKOM will ask you for a conference
	and make you a member of it if you are not already.
\\[kom-list-conferences]	List conferences matching a given string.
\\[kom-list-persons]	List persons matching a given string.
Per Cederqvist's avatar
.    
Per Cederqvist committed
734

David Kågedal's avatar
David Kågedal committed
735
736
\\[kom-list-news]	List the conferences you have unread texts in.
\\[kom-go-to-next-conf]	Go to the next conference with unread texts.
Per Cederqvist's avatar
.    
Per Cederqvist committed
737

David Kågedal's avatar
David Kågedal committed
738
\\[kom-membership]	Display a buffer with the list of conferences you are member in.
Per Cederqvist's avatar
.    
Per Cederqvist committed
739

David Kågedal's avatar
David Kågedal committed
740
741
\\[kom-quit]	Leave this LysKOM session.
\\[kom-who-is-on]	Show a list of all the users of lyskom right now.
Per Cederqvist's avatar
.    
Per Cederqvist committed
742

David Kågedal's avatar
David Kågedal committed
743
\\[kom-extended-command]	Read a command using the minibuffer and execute it.
744
	This is another way to give commands.
Per Cederqvist's avatar
.    
Per Cederqvist committed
745

David Kågedal's avatar
David Kågedal committed
746
747
748
\\[kom-write-text]	Start writing a new text.
\\[kom-write-comment]	Start writing a comment to the last read article.
\\[kom-private-answer]	Start writing a personal answer to the author of the last
Per Cederqvist's avatar
.    
Per Cederqvist committed
749
	read article.
David Kågedal's avatar
David Kågedal committed
750
\\[kom-send-letter]	Start writing a letter to a person or conference.
Per Cederqvist's avatar
.    
Per Cederqvist committed
751

David Kågedal's avatar
David Kågedal committed
752
753
\\[kom-page-next-command]	Clear the page and do what \\[kom-next-command] does.
\\[kom-line-next-command]	Do what \\[kom-next-command] does, but scroll at most 1 line.
Per Cederqvist's avatar
.    
Per Cederqvist committed
754

David Kågedal's avatar
David Kågedal committed
755
756
0 .. 9	Give a numeric argument to the next command.
\\[describe-mode]	Display this help text.
Per Cederqvist's avatar
.    
Per Cederqvist committed
757

David Kågedal's avatar
David Kågedal committed
758
\\[kom-busy-wait]	Put the lyskom-session in wait mode. The next created text with 
759
	a priority higher than that of the next conference you are going
Per Cederqvist's avatar
.    
Per Cederqvist committed
760
	to will be read directly when it is created.
David Kågedal's avatar
David Kågedal committed
761
762
763
\\[kom-set-unread]	Mark a number of texts as unread.
\\[kom-jump]	Skip (mark as read) all the comments to this article recursively.
\\[kom-display-time]	Show the current date and time.
Per Cederqvist's avatar
.    
Per Cederqvist committed
764

David Kågedal's avatar
David Kågedal committed
765
766
767
768
\\[kom-change-presentation]	Change your presentation.
\\[kom-view]	View the specified text.
\\[kom-view-commented-text]	View the text that the current text comments or is a footnote to.
\\[kom-review-presentation]	Show the presentation for a person or a conferencce.
Per Cederqvist's avatar
.    
Per Cederqvist committed
769

David Kågedal's avatar
David Kågedal committed
770
771
\\[kom-review-comments]	View all comments to the current text.
\\[kom-review-tree]	View all comments to the current text and step through the tree
Per Cederqvist's avatar
.    
Per Cederqvist committed
772
773
	in depth-first order.

David Kågedal's avatar
David Kågedal committed
774
775
776
\\[kom-find-root-review]	View the complete comment tree.
\\[kom-find-root]	Show the root text of this comment tree.
\\[kom-review-by-to]	View the last (first or all) article written by named author
Per Cederqvist's avatar
.    
Per Cederqvist committed
777
778
	in a named conference.

David Kågedal's avatar
David Kågedal committed
779
780
781
782
\\[kom-mark-text]	Create a mark on a text.
\\[kom-unmark-text]	Remove the mark on a text.
\\[kom-review-marked-texts]	View all text marked with a certain mark.
\\[kom-review-all-marked-texts]	View all marked text.
Per Cederqvist's avatar
.    
Per Cederqvist committed
783

David Kågedal's avatar
David Kågedal committed
784
785
786
787
788
789
\\[kom-view-next-new-text]	Read the next text from the list of unread.
\\[kom-review-next]	Continue the viewing.
\\[kom-review-stack]	Show the stack of things we are viewing.
\\[kom-review-clear]	Clear the stack of things we are viewing.
\\[kom-review-backward]	Toggles the read order of reviewed texts. This can only be done
	when viewing texts with \\[kom-review-by-to], \\[kom-review-marked-texts] and \\[kom-review-all-marked-texts].
Per Cederqvist's avatar
.    
Per Cederqvist committed
790

David Kågedal's avatar
David Kågedal committed
791
792
793
\\[kom-status-conf]	Show the status of a conference.
\\[kom-status-person]	Show the status of a person
\\[kom-save-text]	Save the text you are looking at to a file.
Per Cederqvist's avatar
.    
Per Cederqvist committed
794

David Kågedal's avatar
David Kågedal committed
795
796
\\[kom-get-abuse]	Get an insulting text.
\\[kom-get-appreciation]	Get an encouraging text.
Per Cederqvist's avatar
.    
Per Cederqvist committed
797

David Kågedal's avatar
David Kågedal committed
798
799
\\[kom-add-self]	Become a member of a conference.
\\[kom-sub-self]	Removes you as a member of a conference.
Per Cederqvist's avatar
.    
Per Cederqvist committed
800
801
802
803

All bindings (this is here due to the fact that inconsistensies while 
developping this package are frequent):
\\{lyskom-mode-map}
Linus Tolke's avatar
Linus Tolke committed
804
805
806
807
808
809
Entry to this mode runs lyskom-mode-hook.

Functions and variables beginning with kom- are intended for the user to see,
set or call.
Functions and variables beginning with lyskom- are not intended for the user
to see, set of call."
Per Cederqvist's avatar
.    
Per Cederqvist committed
810
811
812
  (interactive)
  (lyskom-clear-vars)
  (setq mode-line-buffer-identification
813
	(list (concat (lyskom-mode-name-from-host) ": ") 'mode-line-conf-name))
Per Cederqvist's avatar
.    
Per Cederqvist committed
814
815
816

  (setq major-mode 'lyskom-mode)
  (setq mode-name "LysKOM")
817
  (setq mode-line-process (lyskom-get-string 'mode-line-working))
Per Cederqvist's avatar
.    
Per Cederqvist committed
818
  (use-local-map lyskom-mode-map)
David Byers's avatar
X    
David Byers committed
819
  (lyskom-set-menus 'lyskom-mode lyskom-mode-map)
820
  (run-hooks 'lyskom-mode-hook)
821

822
  (buffer-disable-undo (current-buffer))
David Kågedal's avatar
David Kågedal committed
823
  (setq buffer-read-only t))
Per Cederqvist's avatar
.    
Per Cederqvist committed
824
825
826

(defun lyskom-clear-vars ()
  "Set up buffer-local vars."
David Byers's avatar
X    
David Byers committed
827
828
829
830
831
832
833
834
835
  (lyskom-save-variables (lyskom-proc
                          lyskom-pers-no
                          lyskom-membership
                          lyskom-membership-is-read
                          lyskom-last-viewed
                          lyskom-unparsed-buffer
                          lyskom-unparsed-marker
                          lyskom-server-info
                          lyskom-server-name)
David Byers's avatar
David Byers committed
836
      (kill-all-local-variables))
David Byers's avatar
X    
David Byers committed
837
    (lyskom-setup-local-variables)
Per Cederqvist's avatar
.    
Per Cederqvist committed
838
    (setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
David Kågedal's avatar
David Kågedal committed
839
    (setq lyskom-output-queues (make-vector 10 nil))
840
    (setq lyskom-collate-table lyskom-default-collate-table)
841
    (setq lyskom-char-classes nil)
842
    (let ((i 0))
David Kågedal's avatar
David Kågedal committed
843
      (while (< i 10)
David Byers's avatar
X    
David Byers committed
844
845
        (aset lyskom-output-queues i (lyskom-queue-create))
        (setq i (1+ i))))
David Kågedal's avatar
David Kågedal committed
846
    (setq lyskom-pending-calls nil)
David Byers's avatar
X    
David Byers committed
847
    (lyskom-set-mode-line
David Byers's avatar
David Byers committed
848
     (lyskom-get-string 'not-present-anywhere)))
David Byers's avatar
X    
David Byers committed
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970



  
;  (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))))