startup.el 27 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
2
;;;;;
;;;;; $Id$
3
;;;;; Copyright (C) 1991, 1996  Lysator Academic Computer Association.
Linus Tolke's avatar
Linus Tolke committed
4
5
6
7
8
;;;;;
;;;;; This file is part of the LysKOM server.
;;;;; 
;;;;; LysKOM is free software; you can redistribute it and/or modify it
;;;;; under the terms of the GNU General Public License as published by 
9
;;;;; the Free Software Foundation; either version 2, or (at your option) 
Linus Tolke's avatar
Linus Tolke committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;;;;; 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
25
26
27
28
29
30
31
32
33
34
35
;;;; ================================================================
;;;; ================================================================
;;;;
;;;; 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.
;;;;


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


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


45
;;;###autoload
46
(defun lyskom (&optional host username password session-priority)
Per Cederqvist's avatar
.    
Per Cederqvist committed
47
  "Start a LysKOM session.
Linus Tolke's avatar
Linus Tolke committed
48
49
50
Optional arguments: HOST, USERNAME and PASSWORD.

See lyskom-mode for details."
David Kågedal's avatar
David Kågedal committed
51
52
53
54
  (interactive (list (lyskom-read-server-name
		      (lyskom-format 'server-q
				     (or (getenv "KOMSERVER")
					 lyskom-default-server)))
Per Cederqvist's avatar
.    
Per Cederqvist committed
55
		     nil
56
57
58
59
		     nil
		     (if current-prefix-arg
			 (prefix-numeric-value current-prefix-arg)
		       nil)))
Per Cederqvist's avatar
.    
Per Cederqvist committed
60

61
  (run-hooks 'lyskom-init-hook)
62
  (setq username
David Kågedal's avatar
David Kågedal committed
63
	(or username (getenv "KOMNAME")))
64
  (setq password
David Kågedal's avatar
David Kågedal committed
65
	(or password (getenv "KOMPASSWORD")))
Per Cederqvist's avatar
.    
Per Cederqvist committed
66
  (if (zerop (length host))
67
68
69
70
71
      (let* ((env-kom (getenv "KOMSERVER"))
	     (canon (rassoc env-kom kom-server-aliases)))
	(setq host (or (car canon)
		       env-kom
		       lyskom-default-server))))
72
73
  (let ((port 4894)
	(init-done nil))
Per Cederqvist's avatar
.    
Per Cederqvist committed
74
75
76
77
78
79
80
81
82
    (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 Kågedal's avatar
David Kågedal committed
83
84
    (let* ((buffer (get-buffer host))
	   (name nil)
David Kågedal's avatar
David Kågedal committed
85
	   (proc nil))
David Kågedal's avatar
David Kågedal committed
86
87
88
89
90
91
92
      (if (and buffer
	       (lyskom-buffer-p buffer)
	       (not (j-or-n-p (lyskom-get-string
			       'start-new-session-same-server))))
	  (switch-to-buffer buffer)
	(unwind-protect
	    (progn
93
	      (cond ((and buffer (not (lyskom-buffer-p buffer)))
David Kågedal's avatar
David Kågedal committed
94
95
96
97
98
99
100
101
		     (set-buffer buffer)
		     (goto-char (point-max))
		     (let ((time (decode-time (current-time))))
		       (setcar (cdr (cdr (cdr (cdr time))))
			       (1- (car (cdr (cdr (cdr (cdr time)))))))
		       (setcar (cdr (cdr (cdr (cdr (cdr time)))))
			       (- (car (cdr (cdr (cdr (cdr (cdr time))))))
				  1900))
102
		       (lyskom-insert
David Kågedal's avatar
David Kågedal committed
103
104
105
106
107
108
109
110
111
112
			(format (lyskom-get-string 'new-session-in-buffer)
				(lyskom-format-time
				 (apply 'lyskom-create-time time))))
		       (setq name (buffer-name buffer))))
		    (t
		     (setq buffer (generate-new-buffer host))
		     (setq name (buffer-name buffer))))
	      (setq proc (open-network-stream name buffer host port))
	      (switch-to-buffer buffer)
	      (lyskom-mode)		;Clearing lyskom-default...
113
114
	      (if session-priority
		  (setq lyskom-session-priority session-priority))
David Kågedal's avatar
David Kågedal committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
	      (setq lyskom-buffer buffer)
	      (setq lyskom-default-user-name username)
	      (setq lyskom-default-password password)
	      (setq lyskom-server-name host)
	      (setq lyskom-proc proc)
	      (lyskom-setup-faces)
	      (lyskom-insert
	       (lyskom-format 'try-connect lyskom-clientversion host))
	      (set-process-filter proc 'lyskom-connect-filter)
	      (lyskom-process-send-string proc
					  (concat "A"
						  (lyskom-format-objects
						   (concat (user-login-name)
							   "%" (system-name)))))
	      (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))

	      ;; 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))
	      (setq lyskom-server-version
		    (list (/ (server-info->version lyskom-server-info) 10000)
			  (/ (% (server-info->version lyskom-server-info) 10000)
			     100)
			  (% (server-info->version lyskom-server-info) 100)))
	      (lyskom-setup-client-for-server-version)
	      (lyskom-format-insert 
	       'connection-done
	       (if (zerop (elt lyskom-server-version 2))
		   (format "%d.%d"
			   (elt lyskom-server-version 0)
			   (elt lyskom-server-version 1))
		 (format "%d.%d.%d"
155
156
157
                         (elt lyskom-server-version 0)
                         (elt lyskom-server-version 1)
                         (elt lyskom-server-version 2))))
David Kågedal's avatar
David Kågedal committed
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
	      (if (not (zerop (server-info->motd-of-lyskom lyskom-server-info)))
		  (let ((text (blocking-do 'get-text 
					   (server-info->motd-of-lyskom
					    lyskom-server-info))))
		    (lyskom-insert 
		     (if text
			 (text->text-mass text)
		       (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
	      (kom-start-anew t)
	      (setq lyskom-buffer-list (cons lyskom-buffer lyskom-buffer-list))
	      (setq init-done t))
	  ;; Something went wrong. Lets cleanup everything. :->
	  (if init-done
	      nil
	    (if proc (delete-process proc))
	    (kill-buffer buffer)))))))
Per Cederqvist's avatar
.    
Per Cederqvist committed
178
179


180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
(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))
195
196
197
198
199
200
201
202
               (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)))))))
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230


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

Per Cederqvist's avatar
.    
Per Cederqvist committed
231
232
(defun lyskom-connect-filter (proc output)
  "Receive connection acknowledgement from server."
233
  (if lyskom-debug-communications-to-buffer
David Kågedal's avatar
David Kågedal committed
234
      (lyskom-debug-insert proc "-----> " output))
235
236
237
238
239
240
  (cond
   ((string-match "^LysKOM\n" output)
    (set-process-filter proc 'lyskom-filter))))



Per Cederqvist's avatar
.    
Per Cederqvist committed
241
242
243
244
245
246


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


247
(defun kom-start-anew (&optional lyskom-first-time-around)
248
  "Start as a new person."
Per Cederqvist's avatar
.    
Per Cederqvist committed
249
250
  (interactive)
  (lyskom-start-of-command 'kom-start-anew)
251
  (lyskom-completing-clear-cache)
252
  (clear-all-caches)
David Kågedal's avatar
David Kågedal committed
253
254
  (let ((old-me lyskom-pers-no))
    (unwind-protect
255
256
257
258
259
260
        (progn
          (if lyskom-first-time-around
              nil
            (lyskom-tell-internat 'kom-tell-login))
          (setq lyskom-pers-no nil)
          (while (not lyskom-pers-no)
261

262
263
264
265
            (if (and lyskom-first-time-around
                     lyskom-default-user-name)
                ;; This is nil if we can't find a unique match.
                (setq lyskom-pers-no
266
                      (conf-z-info->conf-no
267
268
                       (lyskom-lookup-conf-by-name lyskom-default-user-name
                                                   '(pers)))))
269
            (if lyskom-pers-no
270
271
272
                nil
              (let ((name (lyskom-read-conf-name
                           (lyskom-get-string 'what-is-your-name)
273
                           '(pers none) t "" t)))
274
                (setq lyskom-pers-no
275
                      (or (conf-z-info->conf-no 
276
                           (lyskom-lookup-conf-by-name name '(pers)))
277
278
279
280
281
282
                          (lyskom-create-new-person name)))))
            ;; Now lyskom-pers-no contains a number of a person.
            ;; Lets log him in.
            (if lyskom-pers-no
                (let ((conf-stat (blocking-do 'get-conf-stat lyskom-pers-no))
                      (lyskom-inhibit-minibuffer-messages t))
283
284
285

		  ;; DEBUG
		  (if (null conf-stat)
286
		      (lyskom-insert "You don't exist. Go away.\n"))
287

288
289
290
291
292
293
294
295
296
297
298
299
300
                  (lyskom-insert (concat (conf-stat->name conf-stat) "\n"))
                  (setq lyskom-first-time-around nil)
                  (if (blocking-do 'login lyskom-pers-no
                                   (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
301
302
                                         (silent-read
					  (lyskom-get-string 'password)))))
303
304
305
306
307
308
309
                      (if lyskom-is-new-user
                          (blocking-do 'add-member
                                       (server-info->conf-pres-conf lyskom-server-info)
                                       lyskom-pers-no 100 1))
                    (lyskom-insert-string 'wrong-password)
                    (setq lyskom-pers-no nil))
                  (setq lyskom-is-new-user nil))))
David Kågedal's avatar
David Kågedal committed
310
	  
311
312
313
314
315
316
317
          ;; Now we are logged in.
          (lyskom-insert-string 'are-logged-in)
          (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)
318
319
320
                  (let ((lyskom-show-comments ; +++SOJGE
                         (not kom-no-comments-to-motd)))
                    (lyskom-view-text (conf-stat->msg-of-day conf-stat)))))
321
322
323
324
325
326
327
328
329
330
331
332
333
            (if (and conf-stat
                     (zerop (conf-stat->presentation conf-stat))
                     (not (zerop (conf-stat->no-of-texts conf-stat))))
                (lyskom-insert-string 'presentation-encouragement)))
          (if (not lyskom-dont-read-user-area)
              (lyskom-read-options))
          (lyskom-refetch)
          ;; (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))))
David Kågedal's avatar
David Kågedal committed
334
	  
David Kågedal's avatar
David Kågedal committed
335
336
      ;; If something failed, make sure we are someone
      (if (null lyskom-pers-no) (setq lyskom-pers-no old-me))
David Kågedal's avatar
David Kågedal committed
337
      (setq lyskom-is-new-user nil)
David Kågedal's avatar
David Kågedal committed
338
339
340
341
      (lyskom-end-of-command)))
  ;; Run the hook kom-login-hook. We don't want to hang the
  ;; login, just because something crashed here.
  (condition-case err
342
      (progn
343
344
        (run-hooks 'lyskom-login-hook)
        (run-hooks 'kom-login-hook))
David Kågedal's avatar
David Kågedal committed
345
    (error (lyskom-format-insert-before-prompt
346
            'error-in-login-hook (format "%s" err)))))
Linus Tolke's avatar
Linus Tolke committed
347
348
349


(defun lyskom-refetch ()
350
351
352
353
354
355
  "Resets and fetches all reading info.
This is called at login and after prioritize and set-unread."
  ;; The whole membership!
  (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))
Linus Tolke's avatar
Linus Tolke committed
356
357
  (setq lyskom-last-conf-fetched -1)
  (setq lyskom-last-conf-received -1)
358
  (setq lyskom-last-conf-done -1)
Linus Tolke's avatar
Linus Tolke committed
359
  (setq lyskom-to-do-list (lyskom-create-read-list))
360
  (setq lyskom-reading-list (lyskom-create-read-list)))
361
362


Linus Tolke's avatar
Linus Tolke committed
363
364
365
(defun lyskom-set-membership (membership)
  "Sets lyskom-membership to a new value.
Args: MEMBERSHIP."
David Kågedal's avatar
David Kågedal committed
366
  (setq lyskom-membership (sort (listify-vector membership)
Linus Tolke's avatar
Linus Tolke committed
367
368
				'lyskom-membership-<))
  (setq lyskom-membership-is-read t))
Per Cederqvist's avatar
.    
Per Cederqvist committed
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407


(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
408
(defun lyskom-create-new-person (name)
Per Cederqvist's avatar
.    
Per Cederqvist committed
409
410
411
412
413
414
415
416
417
418
  "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
419
	;; Failed to enter the same password twice
Per Cederqvist's avatar
.    
Per Cederqvist committed
420
	(lyskom-insert-string 'repeat-failure)
David Kågedal's avatar
David Kågedal committed
421
	nil)
Per Cederqvist's avatar
.    
Per Cederqvist committed
422
       (t
David Kågedal's avatar
David Kågedal committed
423
424
425
426
427
428
429
430
	;; Entered the same password twice
	(let ((new-person (blocking-do 'create-person name password)))
	  (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
431
   (t
David Kågedal's avatar
David Kågedal committed
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
    ;; 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
454

Per Cederqvist's avatar
.    
Per Cederqvist committed
455

David Kågedal's avatar
David Kågedal committed
456
457
(defun lyskom-read-server-name (prompt)
  "Read the name of a LysKOM server.
David Kågedal's avatar
David Kågedal committed
458
Copmpletion is done on the servers i kom-server-aliases. If an
David Kågedal's avatar
David Kågedal committed
459
460
461
462
463
464
465
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
466
			 kom-server-aliases)
David Kågedal's avatar
David Kågedal committed
467
468
		 (mapcar (function (lambda (pair)
				     (cons (cdr pair) (car pair))))
David Kågedal's avatar
David Kågedal committed
469
			 kom-server-aliases)))
David Kågedal's avatar
David Kågedal committed
470
471
472
473
474
475
476
	(completion-ignore-case t)
	server)
    (setq server (completing-read prompt known-servers nil nil))
    (or (cdr (assoc server known-servers))
	server)))
      

Per Cederqvist's avatar
.    
Per Cederqvist committed
477
478
479
;;; ================================================================
;;;                        The LysKOM mode.

480
481
482
;; 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
483
484
485
486

(defun lyskom-mode ()
  "\\<lyskom-mode-map>Mode for LysKOM client.
Commands:
David Kågedal's avatar
David Kågedal committed
487
488
489
490
491
492
\\[kom-next-command]	Do the default action. This can be to read the next text,select
n	ext conference with unread texts or whatever the prompt says.
\\[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
493

David Kågedal's avatar
David Kågedal committed
494
495
\\[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
496

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

David Kågedal's avatar
David Kågedal committed
499
500
\\[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
501

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

David Kågedal's avatar
David Kågedal committed
505
506
507
\\[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
508
	read article.
David Kågedal's avatar
David Kågedal committed
509
\\[kom-send-letter]	Start writing a letter to a person or conference.
Per Cederqvist's avatar
.    
Per Cederqvist committed
510

David Kågedal's avatar
David Kågedal committed
511
512
\\[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
513

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

David Kågedal's avatar
David Kågedal committed
517
\\[kom-busy-wait]	Put the lyskom-session in wait mode. The next created text with 
Per Cederqvist's avatar
.    
Per Cederqvist committed
518
519
	a priotity higher that that of the next conference you are going
	to will be read directly when it is created.
David Kågedal's avatar
David Kågedal committed
520
521
522
\\[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
523

David Kågedal's avatar
David Kågedal committed
524
525
526
527
\\[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
528

David Kågedal's avatar
David Kågedal committed
529
530
\\[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
531
532
	in depth-first order.

David Kågedal's avatar
David Kågedal committed
533
534
535
\\[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
536
537
	in a named conference.

David Kågedal's avatar
David Kågedal committed
538
539
540
541
\\[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
542

David Kågedal's avatar
David Kågedal committed
543
544
545
546
547
548
\\[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
549

David Kågedal's avatar
David Kågedal committed
550
551
552
\\[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
553

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

David Kågedal's avatar
David Kågedal committed
557
558
\\[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
559
560
561
562

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
563
564
565
566
567
568
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
569
570
571
  (interactive)
  (lyskom-clear-vars)
  (setq mode-line-buffer-identification
572
	(list (concat (lyskom-mode-name-from-host) ": ") 'mode-line-conf-name))
Per Cederqvist's avatar
.    
Per Cederqvist committed
573
574
575

  (setq major-mode 'lyskom-mode)
  (setq mode-name "LysKOM")
576
  (setq mode-line-process (lyskom-get-string 'mode-line-working))
Per Cederqvist's avatar
.    
Per Cederqvist committed
577
  (use-local-map lyskom-mode-map)
578
  (lyskom-count-down-edits)
579
580
  (run-hooks 'lyskom-mode-hook)
  (lyskom-tell-phrases-validate))
Per Cederqvist's avatar
.    
Per Cederqvist committed
581
582
583
584
585
586
587
588
589
590

(defun lyskom-clear-vars ()
  "Set up buffer-local vars."
  (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)
Linus Tolke's avatar
Linus Tolke committed
591
	(server-info lyskom-server-info)
592
	(server-name lyskom-server-name)
Linus Tolke's avatar
Linus Tolke committed
593
	)
Per Cederqvist's avatar
.    
Per Cederqvist committed
594
    (kill-all-local-variables)
David Byers's avatar
David Byers committed
595
596
597
    (make-local-variable 'kom-ansaphone-show-messages)
    (make-local-variable 'kom-ansaphone-record-messages)
    (make-local-variable 'kom-prompt-format)
598
599
600
601
    (make-local-variable 'kom-ansaphone-on)
    (make-local-variable 'kom-ansaphone-default-reply)
    (make-local-variable 'kom-remote-control)
    (make-local-variable 'kom-remote-controllers)
David Kågedal's avatar
David Kågedal committed
602
    (make-local-variable 'kom-login-hook)
David Byers's avatar
David Byers committed
603
604
605
    (make-local-variable 'kom-friends)
    (make-local-variable 'kom-permanent-filter-list)
    (make-local-variable 'kom-session-filter-list)
David Kågedal's avatar
David Kågedal committed
606
    (make-local-variable 'lyskom-accept-async-flag)
Linus Tolke's avatar
Linus Tolke committed
607
    (make-local-variable 'lyskom-blocking-return)
David Kågedal's avatar
David Kågedal committed
608
609
    (make-local-variable 'lyskom-buffer)
    (make-local-variable 'lyskom-command-to-do)
Per Cederqvist's avatar
.    
Per Cederqvist committed
610
    (make-local-variable 'lyskom-conf-cache)
David Kågedal's avatar
David Kågedal committed
611
612
613
614
    (make-local-variable 'lyskom-count-var)
    (make-local-variable 'lyskom-current-conf)
    (make-local-variable 'lyskom-current-subject)
    (make-local-variable 'lyskom-current-text)
615
    (make-local-variable 'lyskom-default-password)
David Kågedal's avatar
David Kågedal committed
616
617
    (make-local-variable 'lyskom-default-user-name)
    (make-local-variable 'lyskom-do-when-done)
David Kågedal's avatar
David Kågedal committed
618
    (make-local-variable 'lyskom-dynamic-session-info-flag)
David Kågedal's avatar
David Kågedal committed
619
620
621
622
623
    (make-local-variable 'lyskom-dont-change-prompt)
    (make-local-variable 'lyskom-errno)
    (make-local-variable 'lyskom-executing-command)
    (make-local-variable 'lyskom-fetched-texts)
    (make-local-variable 'lyskom-filter-list)
David Kågedal's avatar
David Kågedal committed
624
    (make-local-variable 'lyskom-idle-time-flag)
David Kågedal's avatar
David Kågedal committed
625
    (make-local-variable 'lyskom-is-administrator)
Per Cederqvist's avatar
.    
Per Cederqvist committed
626
    (make-local-variable 'lyskom-is-parsing)
David Kågedal's avatar
David Kågedal committed
627
628
629
    (make-local-variable 'lyskom-is-waiting)
    (make-local-variable 'lyskom-is-writing)
    (make-local-variable 'lyskom-last-conf-done)
Per Cederqvist's avatar
.    
Per Cederqvist committed
630
631
    (make-local-variable 'lyskom-last-conf-fetched)
    (make-local-variable 'lyskom-last-conf-received)
David Kågedal's avatar
David Kågedal committed
632
633
    (make-local-variable 'lyskom-last-group-message-recipient)
    (make-local-variable 'lyskom-last-personal-message-sender)
David Kågedal's avatar
David Kågedal committed
634
635
    (make-local-variable 'lyskom-last-viewed)
    (make-local-variable 'lyskom-list-of-edit-buffers)
David Kågedal's avatar
David Kågedal committed
636
    (make-local-variable 'lyskom-long-conf-types-flag)
David Kågedal's avatar
David Kågedal committed
637
    (make-local-variable 'lyskom-marked-text-cache)
Per Cederqvist's avatar
.    
Per Cederqvist committed
638
    (make-local-variable 'lyskom-membership)
David Kågedal's avatar
David Kågedal committed
639
    (make-local-variable 'lyskom-membership-is-read)
640
    (make-local-variable 'lyskom-current-prompt)
641
    (make-local-variable 'lyskom-normally-read-texts)
David Kågedal's avatar
David Kågedal committed
642
643
644
    (make-local-variable 'lyskom-number-of-pending-calls)
    (make-local-variable 'lyskom-options-done)
    (make-local-variable 'lyskom-other-clients-user-areas)
David Kågedal's avatar
David Kågedal committed
645
    (make-local-variable 'lyskom-output-queues)
David Kågedal's avatar
David Kågedal committed
646
647
648
649
650
651
652
653
654
    (make-local-variable 'lyskom-pending-calls)
    (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-texts)
    (make-local-variable 'lyskom-previous-text)
    (make-local-variable 'lyskom-prioritize-buffer)
    (make-local-variable 'lyskom-proc)
Per Cederqvist's avatar
.    
Per Cederqvist committed
655
    (make-local-variable 'lyskom-reading-list)
David Kågedal's avatar
David Kågedal committed
656
657
    (make-local-variable 'lyskom-server-info)
    (make-local-variable 'lyskom-server-name)
658
659
660
661
662
663
    (make-local-variable 'lyskom-server-version)
    (make-local-variable 'lyskom-server-supports)
    (make-local-variable 'lyskom-long-conf-types-flag)
    (make-local-variable 'lyskom-set-last-read-flag)
    (make-local-variable 'lyskom-uconf-stats-flag)
    (make-local-variable 'lyskom-z-lookup-flag)
David Kågedal's avatar
David Kågedal committed
664
    (make-local-variable 'lyskom-session-no)
David Kågedal's avatar
David Kågedal committed
665
    (make-local-variable 'lyskom-session-priority)
David Kågedal's avatar
David Kågedal committed
666
667
    (make-local-variable 'lyskom-text-cache)
    (make-local-variable 'lyskom-text-mass-cache)
Per Cederqvist's avatar
.    
Per Cederqvist committed
668
    (make-local-variable 'lyskom-to-be-printed-before-prompt)
David Kågedal's avatar
David Kågedal committed
669
670
671
672
    (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)
Per Cederqvist's avatar
.    
Per Cederqvist committed
673
    (make-local-variable 'lyskom-what-i-am-doing)
David Kågedal's avatar
David Kågedal committed
674
675
676
    (make-local-variable 'lyskom-who-info-buffer)
    (make-local-variable 'lyskom-who-info-buffer-is-on)
    (make-local-variable 'lyskom-who-info-cache)
677
    (make-local-variable 'lyskom-collate-table)
Per Cederqvist's avatar
.    
Per Cederqvist committed
678
679
680
681
682
683
684
685
686
    (make-local-variable 'mode-line-conf-name)
    (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)
687
    (setq lyskom-server-name server-name)
Per Cederqvist's avatar
.    
Per Cederqvist committed
688
    (setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
David Kågedal's avatar
David Kågedal committed
689
    (setq lyskom-output-queues (make-vector 10 nil))
690
    (setq lyskom-collate-table lyskom-default-collate-table)
David Kågedal's avatar
David Kågedal committed
691
692
693
694
    (let ((i 0))
      (while (< i 10)
	(aset lyskom-output-queues i (lyskom-queue-create))
	(++ i)))
695
    (setq lyskom-list-of-edit-buffers nil)
David Kågedal's avatar
David Kågedal committed
696
    (setq lyskom-pending-calls nil)
Per Cederqvist's avatar
.    
Per Cederqvist committed
697
    (lyskom-set-mode-line (lyskom-get-string 'not-present-anywhere))))