vars.el.in 33.9 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
;;;;; -*- emacs-lisp -*-
Linus Tolke's avatar
Linus Tolke committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;;;;; $Id$
;;;;; Copyright (C) 1991  Lysator Academic Computer Association.
;;;;;
;;;;; 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 
;;;;; the Free Software Foundation; either version 1, or (at your option) 
;;;;; 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
;;;; ================================================================
;;;; ================================================================
;;;;
;;;; File: vars.el
;;;;
;;;; This file contains almost all the variables used in lyskom.
;;;;


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


Per Cederqvist's avatar
.    
Per Cederqvist committed
39
40
41
42
43
44
45

(provide 'lyskom)


;;;; ================================================================
;;;;                    Emacs dependant variables

46
(defvar kom-emacs-knows-iso-8859-1 t
Per Cederqvist's avatar
.    
Per Cederqvist committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  "*If non-nil then dont convert texts and other things to swascii.
This variable is not saved. It should be set in your .emacs")


;;;; ================================================================
;;;;                     Variables and constants.


;;; User flags

(defvar kom-write-texts-in-window nil
  "*Nil means edit texts in the same window that is used for reading texts.
'other means edit in another window. Creating that window if necessary.
A buffer or buffer name means use the first window displaying that buffer.
If no window is displaying that buffer or the buffer does not exits then it
uses the same window.")

(defvar kom-created-texts-are-read t
  "*Non-nil means automatically mark texts that you create as read.")

67
68
69
(defvar kom-dont-restore-window-after-editing nil
  "*If non-nil then don't restore the window configuration after sending a text.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(defvar kom-default-mark 100
  "*If non-nil (must be an integer) then the user is not asked for type of mark.")

(defvar kom-reading-puts-comments-in-pointers-last t
  "*If Non-nil the texts are shown with comments references at the end.")

(defvar kom-dashed-lines t
  "*If Non-nil then all texts will be surrounded by lines of dashes.")

(defvar kom-print-number-of-unread-on-entrance t
  "*If Non-nil then print automatically the number of unread articles when
entering a conference.")

(defvar kom-presence-messages t
  "*If non-nil, lyskom prints continuous info about what other people are doing.
Info is printed on the message line and never in the buffer. If minibuffer is
Linus Tolke's avatar
Linus Tolke committed
86
87
88
89
used then no message is printed.

If you want the messages in the buffer you could set the variable 
kom-presence-messages-in-buffer.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
90
91
92
93
94

(defvar kom-presence-messages-in-buffer nil
  "*If t, lyskom prints information about what other people are doing in buffer.
All printing is done just before the prompt.
If nil no messages are printed.
95
96
If 'presence then messages about people logging in, out and people 
changing name is printed.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
97
98
99
100
101

(defvar kom-show-where-and-what t
  "*Non-nil means kom-who-is-on shows from which machine the user is running
and what he is doing.")

102
103
104
(defvar kom-show-footnotes-immediately t
  "*Non-nil means show footnotes immediately following the text.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
105
106
107
108
109
110
111
112
113
114
115
116
117
(defvar kom-who-buffer-size-when-displaying 10
  "*Size of window to display the who-buffer.
This is used when executing the kom-display-who-buffer command.")

(defvar kom-read-depth-first t
  "*Non-nil means read comments and footnotes to a text before other texts.")

(defvar kom-higher-priority-breaks nil
  "*Non-nil means allow texts from conferences with highter priority to break in.
If the value is 'express then texts are allowed to break in the middle of a
comment chain.  Otherwise we dont let them in until the end of the comment
tree.")

David Kågedal's avatar
David Kågedal committed
118
119
120
(defvar kom-after-load-hook nil
  "Hook to run once after lyskom is loaded.")

David Kågedal's avatar
David Kågedal committed
121
(defvar kom-login-hook nil
Per Cederqvist's avatar
.    
Per Cederqvist committed
122
123
  "*What to do when logged in.
This is a list of commands that are executed after we have logged in but before
David Kågedal's avatar
David Kågedal committed
124
any command is accepted from the keyboard.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
125

Linus Tolke's avatar
Linus Tolke committed
126
(defvar kom-do-when-done '(kom-review-all-marked-texts kom-display-time)
Per Cederqvist's avatar
.    
Per Cederqvist committed
127
128
129
130
131
132
133
134
135
136
137
  "*What to do when all texts are read.
This is a list of commands and lists of commands that are prompted for
and executed when there are no more new texts.  The last element in
the list is the one that will never be removed from the list.
A command can be one of:
type			prompt
lyskom-function		from the lyskom-command-name function.
command			\"Kommandot:\" name of function or definition of
			lambda expression
keyboard macro		\"Kommandot:\" keyboard macro definition.")

138
139
140
(defvar kom-page-before-command nil
  "*This is a list of all commands before which the screen is cleared.
If it isn't a list and isn't nil the screen is cleared before all commands.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

(defvar kom-membership-default-priority 100
  "*Default priority when joining a new conference.
If a valid priority then new conferences are read with this priority. 
Otherwise ask the user for a priority.

Valid priorities are only the range 0-255.")

(defvar kom-membership-default-placement 'last
  "*Tells the system where to put new conferences.
The value can be one of the following:
'first => before all other conferences.
'last => after all other conferences.
a number => at that position
otherwise => the new conf is entered after all conferences.")

(defvar lyskom-prompt-text " - "
  "*Text to end the prompt.")

(defvar lyskom-prompt-executing-default-command-text ". "
  "*Text to end the prompt while the default-commands is executing.")

Linus Tolke's avatar
Linus Tolke committed
163
164
165
(defvar lyskom-no-prompt nil
  "Tells the session that we have no prompt.")

166
167
168
169
170
171
(defvar kom-show-personal-messages-in-buffer t
  "*Buffer to show personal messages in.
If nil, discard them.
If t, insert them in the *kom* buffert.
If non-nil and non-t this should be a buffer or a name of a (possibly
nonexistent) buffer in which the message is inserted.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
172

173
174
175
176
(defvar kom-pop-personal-messages nil
  "*Non-nil means pop up a buffer with personal messages as they arrive.
kom-show-personal-messages-in-buffer decides which buffer to pop.")

177
178
179
(defvar kom-ding-on-priority-break 1
  "*Non-nil means ding if a higher priority text or conference breaks in.
A number means the number of times to ding. A string is an argument for the
David Kågedal's avatar
David Kågedal committed
180
program named by kom-audio-player.")
181
182
183
184
185
186
187
188
189
190
191
192
193
194

(defvar kom-ding-on-common-messages 0
  "*Non-nil means ding as common messages arrive. A number means the number of
A number means the number of times to ding. A string is an argument for the
program named by kom-audio-player.")

(defvar kom-ding-on-group-messages 1
  "*Non-nil means ding as group messages arrive. A number means the number of
A number means the number of times to ding. A string is an argument for the
program named by kom-audio-player.")

(defvar kom-ding-on-personal-messages 2
  "*Non-nil means ding as personal messages arrive. A number means the number
A number means the number of times to ding. A string is an argument for the
David Kågedal's avatar
David Kågedal committed
195
program named by kom-audio-player.")
196
197
198

(defvar kom-audio-player "audioplay"
  "*Program to play audio files.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
199

David Byers's avatar
David Byers committed
200
201
202
203
204
205
206
207
208
209
210
(defvar kom-default-message-recipient 'group
  "*Determines default recipient of personal messages.

everybody means the default recipient is everybody.

group means the default recipient is the group to which the last
message was sent, if it was a group message. If the last message was a
personal message or a common message, it means the same as sender.

sender means the sender of the last message received.")

211
212
213
214

(defvar lyskom-filter-outgoing-messages t
  "t if outgoing remote-control messages and automatic replies are not
to be displayed in the buffer.")
215

216
217
218
219
(defvar kom-text-properties t
  "*Non-nil means to insert text properties in the Emacs buffer for
various LysKOM elements.")

220
221
222
223
224
225
226
(defvar kom-use-button-hints t
  "*Non-nil means use button hints for overriding default actions.")

(defvar lyskom-button-actions
  '((text
     text-text
     lyskom-button-view-text
227
228
229
230
231
     (("Återse texten" . lyskom-button-view-text)
      ("Kommentera texten" . lyskom-button-comment-text)
      ("Personligt svar" . lyskom-button-private-comment-text)
      ("Markera texten" . lyskom-button-mark-text)
      ("Avmarkera texten" . lyskom-button-unmark-text))
232
233
234
235
     nil)
    (conf 
     conf-text
     lyskom-button-view-conf-presentation
236
237
238
     (("Visa presentation" . lyskom-button-view-conf-presentation)
      ("Visa mötesstatus" . lyskom-button-view-conf-status)
      ("Gå till mötet" . lyskom-button-goto-conf)
David Byers's avatar
David Byers committed
239
      ("Skicka gruppmeddelande" . lyskom-button-send-message)
240
241
      ("Bli medlem i mötet" . lyskom-button-add-self)
      ("Utträd ur mötet" . lyskom-button-sub-self))
242
243
244
245
     ((kom-list-news . lyskom-button-goto-conf)))
    (pers 
     pers-text
     lyskom-button-view-pers-presentation
246
     (("Visa presentation" . 
247
                             lyskom-button-view-pers-presentation)
248
249
250
      ("Visa personstatus" . lyskom-button-view-pers-status)
      ("Skicka brev" . lyskom-button-mail)
      ("Sänd meddelande" . lyskom-button-send-message))
251
252
253
254
     nil)
    (url 
     url-text
     lyskom-button-open-url
255
256
     (("Öppna" . lyskom-button-open-url)
      ("Kopiera" . lyskom-button-copy-url))
257
258
259
     nil))

"This variable defines valid button types in LysKOM. Each element is a
260
list consisting of (TYPE LABEL DEFAULT ACTIONS HINTS).
261
262
TYPE is the button type the entry defines
LABEL is a textual representation for the button type, used in menu titles. If
263
      it is a symbol, that symbol will be looked up using lyskom-get-string.
264
DEFAULT is the default action to take on a click. It must be a function.
265
266
267
268
ACTIONS are other possible actions. The format of this entry is described 
        below.
HINTS is a list of hints to override the default action. This is described 
      below.
269

270
271
272
The ACTIONS entry is used to construct a pop-up menu. It is a list consisting 
of lists with the format (STRING . FUNCTION). STRING is the menu label and
FUNCTION is the function to call when the menu item is selected.
273
274
275
276

The HINTS entry is used to generate hints that the default action should be 
overridden. It is a list containing elements (COMMAND . HINT) where COMMAND is
as interactive LysKOM command and HINT is a function to call. When a button
277
278
is generated while the command COMMAND is being executed, HINT is used as a 
hint for a new default action. The user has the option to ignore or used the 
279
280
281
hint.

Also see the function \"kom-add-button-action\".")
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303


(defvar lyskom-text-buttons
  '(
    ;; Text numbers
    ("\\(\\<[0-9][0-9][0-9][0-9][0-9]*\\>\\)"       ; Match
     text                           				; Button type
     0                                              ; Portion that's a button
     1                                              ; Portion that's the arg
     nil                                            ; Face or nil (=default)
     )

    ;; URLs

    ("\\(file://\\|ftp://\\|gopher://\\|http://\\|https://\\|news:\\|wais://\\|mailto:\\|telnet:\\)[^\t \012
\"<>|\\]*[^\t \012
\"<>|.,!(){}?'`]" 
     url 0 nil kom-url-face)

    ;; JySKom enhancements

    ("<(m[|ö]te *\\([0-9]+\\)[^0-9]*)>" conf 0 1 nil)
    ("<(text *\\([0-9]+\\)[^0-9]*)>" text 0 1 nil)
    ("<(person *\\([0-9]+\\)[^0-9]*)>" pers 0 1 nil)
David Kågedal's avatar
David Kågedal committed
304
    )
305
306
307
308
309
310
311
  "List of buttons to install in the text mass of LysKOM objects. Each element is
a list consisting of REGEXP TYPE BUTTON-MATCH BUTTON-ARG-MATCH FACE.
REGEXP is the regexp to look for in the text.
TYPE is the button type. Valid button types are defined in lyskom-button-actions
BUTTON-MATCH is the number of the parenthesized expression that is the actual button.
BUTTON-ARG-MATCH is the number of the expression to used as the button argument.
FACE is the text face to apply to the button, or nil to use the default face.")
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345


(defvar kom-url-viewer-preferences '("emacs"
				    "netscape"
				    "w3")
  "*LysKOM will attempt to use URL viewers in the order specified here.
kom-url-managers is a list of all available viewers.")


(defvar kom-url-managers '(("w3" 
			    "\\(http\\|gopher\\|ftp\\)"
			    "Emacs W3" 
			    lyskom-view-url-w3)
			   ("netscape"
			    ".*"
			    "Netscape Navigator"
			    lyskom-view-url-netscape)
			   ("\\(emacs\\|dired\\)"
			    "\\(ftp\\|file\\)"
			    "dired"
			    lyskom-view-url-dired)
			   ("\\(emacs\\|telnet-mode\\)"
			    "telnet"
			    "emacs telnet"
			    lyskom-view-url-telnet)
			   ("\\(emacs\\|mail-mode\\)"
			    "mailto"
			    "mail-mode"
			    lyskom-view-url-mailmode)
			   ("mosaic"
			    "\\(http\\|gopher\\|ftp\\|mailto\\|news\\|wais\\|file\\|te|net\\)"
			    lyskom-view-url-mosaic))

  "List of URL managers. Each element is a list consisting of
David Byers's avatar
David Byers committed
346
347
348
349
350
351
(MANAGER-REGEXP PROTOCOLS NAME VIEW-FUNCTION). When LysKOM attempts to
view an URL, kom-url-viewer-preferences is scanned, and the URL
manager whose MANAGER-REGEXP first matches an element in
kom-url-viewer-preferences and whose PROTOCOLS matches the protocol of
the selected URL is used to view the URL by calling its VIEW-FUNCTION
with the URL and the manager entry as arguments.")
352
353
354
355

(defvar kom-mosaic-command "/usr/local/bin/mosaic"
  "*Command to run to start Mosaic")

356
357
(defvar kom-netscape-command "netscape")

358
359
360
361
362
(defvar kom-confirm-multiple-recipients t
  "*Non-nil means ask the user for confirmation about recipients.
When the user writes a comment to a text with more than one recipient
he gets a y-or-n-p question for all recipients.")

David Kågedal's avatar
David Kågedal committed
363
364
365
(defvar kom-max-buffer-size nil
  "*If non-nil, ensure that buffers won't grow any larger than this")

David Byers's avatar
David Byers committed
366
(defvar lyskom-print-complex-dates (and (>= emacs-minor-version 29)
David Byers's avatar
David Byers committed
367
					(>= emacs-major-version 19))
368
369
  "*If non-nil, print today and yesterday using a special format.")

David Kågedal's avatar
David Kågedal committed
370
(defvar kom-server-aliases
David Kågedal's avatar
David Kågedal committed
371
372
373
  '(("kom.lysator.liu.se" . "LysKOM")
    ("kom.ludd.luth.se" . "LuddKOM")
    ("rydkom.rydnet.lysator.liu.se" . "RydKOM")
David Kågedal's avatar
David Kågedal committed
374
375
376
    ("kom.csd.uu.se" . "CSD-KOM")
    ("striterax.medio.mh.se" . "MedioKOM")
    ("kom.mds.mdh.se" . "MdS-KOM"))
David Kågedal's avatar
David Kågedal committed
377
378
  "An alist mapping server names to shorter identification strings")

David Byers's avatar
David Byers committed
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
408
409
410
411
412
413
414
415
416
417
418

(defvar kom-ansaphone-on nil
  "t if automatic replies to personal messages are in effect.")


(defvar kom-remote-control t
  "*t if LysKOM may be remotely controlled.")

(defvar kom-remote-controllers nil 
  "*Persons who may control LysKOM using messages.By default you can
always control your own sessions. See kom-self-control for more
information.")

(defvar kom-self-control t
  "*If non-nil, remote control commands are accepted from sessions logged
in as the same user as the current session.")

(defvar kom-ansaphone-replies
  '((group nil nil nil nil)
    (common nil nil nil nil))
  "*List of automatic replies to various messages.

A list of (MESSAGE-TYPE SENDER RECIPIENT TEXT REPLY)
    MESSAGE-TYPE is one of personal, group or common or nil
    SENDER is a list of integers or a single integer or nil
    RECIPIENT is a list of integers or a single integer or nil
    TEXT is a regular expression or nil
    REPLY is a string or nil

When an incoming message arrives and the auto-reply facility is on,
this list is checked for automatic replies. The message type, sender,
recipient and text of the incoming messages is matched against the 
elements of this list. If a match is found, the corresponding reply is
send. A nil in one of the message-type, sender, recipient or text
components in the list is taken to mean a wildcard. A null reply means
don't send a reply.

If none of the elements match, KOM-ANSAPHONE-DEFAULT-REPLY is sent.")


419
420
(defconst lyskom-elisp-variables
  '(kom-ding-on-personal-messages
421
422
    kom-ding-on-group-messages
    kom-ding-on-common-messages
David Byers's avatar
David Byers committed
423
424
425
    kom-ding-on-priority-break
    kom-show-personal-messages-in-buffer
    kom-pop-personal-messages
426
427
428
429
430
431
432
433
434
435
436
437
    kom-do-when-done
    kom-higher-priority-breaks
    kom-login-hook
    kom-membership-default-placement
    kom-membership-default-priority
    kom-mercial 
    kom-page-before-command 
    kom-permanent-filter-list
    kom-presence-messages-in-buffer
    kom-quit-hook
    kom-show-where-and-what
    kom-who-buffer-size-when-displaying
David Byers's avatar
David Byers committed
438
    kom-default-message-recipient
439
    kom-write-texts-in-window
440
441
442
443
    kom-remote-control
    kom-remote-controllers
    kom-ansaphone-on
    kom-ansaphone-default-reply
David Byers's avatar
David Byers committed
444
445
    kom-ansaphone-replies
    kom-show-footnotes-immediately
446
447
448
449
450
451
452
453
    lyskom-fetch-map-nos
    lyskom-new-text-hook
    lyskom-prefetch-conf-tresh 
    lyskom-prefetch-confs
    lyskom-prefetch-texts
    lyskom-prompt-executing-default-command-text
    lyskom-prompt-text
    lyskom-who-info-has-changed-hook)
454
  "Tells the client what flags and hooks that are to be saved in the server.
Per Cederqvist's avatar
.    
Per Cederqvist committed
455
456
These are the flags that are saved in the elisp-client part of the server.")

457
(defconst lyskom-global-boolean-variables '(
Per Cederqvist's avatar
.    
Per Cederqvist committed
458
459
460
461
462
463
  kom-created-texts-are-read
  kom-dashed-lines
  kom-presence-messages
  kom-print-number-of-unread-on-entrance
  kom-read-depth-first
  kom-reading-puts-comments-in-pointers-last
464
  kom-confirm-multiple-recipients
Per Cederqvist's avatar
.    
Per Cederqvist committed
465
)
466
467
  "List of flags that are to be saved as booleans in the common block.

Per Cederqvist's avatar
.    
Per Cederqvist committed
468
469
Dont change this. These are defined by the protocol.")
				  
470
471
472
473
474
475
(defconst lyskom-global-non-boolean-variables '(
  kom-default-mark
)
  "List of flags that are to be saved in the common block.
These are the non-boolean ones. See: lyskom-global-boolean-variables.

476
Dont change these. These are defined by the protocol.")
477

Per Cederqvist's avatar
.    
Per Cederqvist committed
478
479
480
481
482

;;; ================================================================
;;;                  Internal variables and constants


483
(defconst lyskom-clientversion "@@CLIENTVERSION@@"
Per Cederqvist's avatar
.    
Per Cederqvist committed
484
485
486
487
488
489
490
491
492
493
494
  "Version of the LysKOM elisp client.")

(defconst lyskom-max-int 8388607
  "The largest int emacs, and thus this LysKOM client, can handle.")

(defvar lyskom-max-packet-size lyskom-max-int
  "The largest possible packet size that can be transmitted to a
TCP/IP connection. This should be unlimited, but in practise there
are systems that limits this. This variable is automatically adjusted
if any problems are detected.")

Linus Tolke's avatar
Linus Tolke committed
495
496
497
498
499
500
501
502
503
504
505
506
507
(defvar lyskom-do-when-done nil
  "Internal of kom-do-when-done.")

(defvar lyskom-do-when-starting nil
  "Internal of kom-do-when-starting.")

(defvar lyskom-list-of-edit-buffers nil
  "Keeps track of active edit-buffers.")

(defvar lyskom-sessions-with-unread nil
  "List of lyskom-sessions with unread texts.
This is not buffer-local.")

508
509
510
(defvar lyskom-sessions-with-unread-letters nil
  "List of lyskom-sessions with unread letters.
This is not buffer-local.")
Linus Tolke's avatar
Linus Tolke committed
511
512
513
514
515
516
517
518
519
520
521
522
523

(defvar lyskom-buffer nil
  "What is the lyskom-buffer we are connected to.")

(defvar output nil
  "Uaark. Just to omit a warning...")

(defvar lyskom-errno nil
  "Errno of last lyskom error.")

(defvar lyskom-parse-pos nil
  "Position of parsing.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
(defvar lyskom-unparsed-buffer nil
  "Buffer containing unparsed information from the server.")

(defvar lyskom-unparsed-marker nil
  "Here are we inserting now.")

(defvar lyskom-to-be-printed-before-prompt nil
  "Contains the strings to be printed out before the next prompt.")

(defvar lyskom-other-clients-user-areas nil
  "Contains the parts of the user areas of unknown klients.
The area is a pair: name . info (both strings).")

(defvar lyskom-pending-calls nil
  "Assoc-list of calls to LysKOM server that have not yet completed.
Each element on the list has the format
	(REF-NO . KOM-QUEUE)
REF-NO	   unique number assigned by lyskom-send-packet.
KOM-QUEUE is a kom-queue. (See lyskom-call-data).")

(defvar lyskom-output-queue nil
  "Pending output to the server.
At most lyskom-max-pending-calls calls are sent at once.")

(defvar lyskom-max-pending-calls 20
  "*Max number of calls that are transmitted to the server at once.
Extra calls are queued in lyskom-output-queue and sent when the replies
returns.")

(defvar lyskom-number-of-pending-calls 0
  "Number of pending calls that are transmitted to the server.")

(defvar lyskom-ref-no 0
  "Next ref-no to use. These ref-nos are used to keep track of the
different packets.")

(defvar lyskom-pers-no 0
  "The pers-no of the current user.")

(defvar lyskom-session-no 0
  "Session number in the server for this connection")

David Kågedal's avatar
David Kågedal committed
566
567
568
569
570
(defvar lyskom-session-priority 0
  "*This sessions priority.
Only texts in conferences with a priority equal to or higher than this
will be shown.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
571
572
573
574
575
576
(defvar lyskom-proc nil
  "The process (network connection) that is associated with this buffer.")

(defvar lyskom-server-info nil
  "Info about the server")

577
578
(defvar lyskom-server-name ""
  "The name of the server")
Per Cederqvist's avatar
.    
Per Cederqvist committed
579
580
581

(defvar lyskom-conf-cache nil
  "Cache of conference statuses.")
582
583
584

(defvar lyskom-uconf-cache nil
  "Cache of small conference statuses.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603

(defvar lyskom-pers-cache nil
  "Cache of person statuses.")

(defvar lyskom-text-cache nil
  "Cache of text statuses.")

(defvar lyskom-text-mass-cache nil
  "Cache of texts.")

(defvar lyskom-marked-text-cache nil
  "Cache of marks of all texts the current user has marked. ")

(defvar lyskom-who-info-cache nil
  "Cache of people presently logged in in LysKOM.")

(defvar lyskom-who-info-buffer nil
  "Buffer for the who info presentation.")

Linus Tolke's avatar
Linus Tolke committed
604
(defvar lyskom-who-info-buffer-is-on t
605
606
  "Says wether we are collecting who-information or not.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655

(defvar lyskom-is-parsing t
  "True when parsing a result.
This is used to prevent parallell parsing since the parser is not reentrant.")

(defvar lyskom-string-bytes-missing 0
  "Number of bytes missing in the unparsed buffer when parsing a string.
Set when parsing a string and there were not enough bytes in the buffer
with the unparsed bytes. This variable is used to prevent reparsing before 
the string is complete.
This variable is buffer-local in the unparsed-buffer.")

(defvar lyskom-last-viewed 0
  "Postition of the first char of the last line that the user has had
time to view. This is normally the pos of the first char of the prompt.")

(defvar lyskom-mode-map nil
  "Keymap used in LysKOM mode.")


(defvar lyskom-reading-list nil
  "List of articles to read in the current conference.
Each element is a read-info. Only one of the elements is of the type CONF.
This one is located last in the list (except for the elements of the type 
REVIEW, REVIEW-TREE or REVIEW-MARK).
When reading an article with comments a list of the comments is built
recursively if the flag kom-read-depth-first is non-nil.
This is to keep track of the reading order.
Articles can exist in several of the read-info elements. All unread articles
in the conference are always present in the CONF type entry in this list even
if also in other entries. (COMM-IN, FOOTN-IN)

Some powerful reviewing commands requires to construct a list of articles that
should be read. These use the type REVIEW. When reviewing trees and when
every viewed article is supposed to be followed by all its comments then the
type REVIEW-TREE is used.

The first element is a dummy.")

(defvar lyskom-to-do-list nil
  "List of conferences with unread texts.
Each element is a read-info. All have the type 'CONF and there is one for
every conference with unread articles that have been prefetched already.
The list is sorted in falling priority. 
When going to a conference the first element (the one with the highest
priority) is copied from this list to lyskom-reading-list.

The first element is a dummy.")

656
;; lyskom-quit-flag is declared in macros.el
Per Cederqvist's avatar
.    
Per Cederqvist committed
657

David Kågedal's avatar
David Kågedal committed
658
659
660
661
(defvar lyskom-inhibit-minibuffer-messages nil
  "A flag indicating whether asynchronous minibuffer messages are allowed.
If this variable is non-nil, no asynchronous messages will appear.")

David Kågedal's avatar
David Kågedal committed
662
663
664
(defvar lyskom-is-saving nil
  "A flag indicating whether the server is saving at the moment.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
;;; These variables control prefetch of conf-stats, text-stats and texts:

(defvar lyskom-prefetch-texts 3
  "*Number of texts to prefetch.")

(defvar lyskom-prefetch-conf-tresh 50
  "*If fewer than lyskom-prefetch-conf-tresh texts are known, ask for more
conf-stats from server.")

(defvar lyskom-prefetch-confs 10
  "*Number of confs to ask about at once when checking for unread texts.")

(defvar lyskom-fetch-map-nos 50
  "*Number of text-nos lyskom will fetch when fetching maps.
+++ This is not yet used everywhere.")

681
682
683
684
685
686
687
688
(defvar lyskom-fetch-membership-length 6
  "*Number of entries in the membership-list that is fetched at a time.
This should be optimized depending on how often you read lyskom and
the activity in the first groups in you membership list.

Best performance is achieved if you, when logging in, always have an unread
article in one of the first lyskom-fetch-membership-length conferences.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
689
690
691
692
693
694
(defvar lyskom-last-conf-fetched -1
  "Last conf asked about. Number on the list lyskom-membership.")

(defvar lyskom-last-conf-received -1
  "Last conf known about. See lyskom-last-conf-fetched.")

David Kågedal's avatar
David Kågedal committed
695
696
697
698
(defvar lyskom-last-conf-done -1
  "This variable has obscure uses. I'm not even sure it is necessary.")
;; See lyskom-rest.el for its use. I believe it almost duplicates
;; lyskom-last-conf-received in practical use.
Per Cederqvist's avatar
.    
Per Cederqvist committed
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719


(defvar lyskom-membership nil
  "Sorted membership-list of the logged in person.")

(defvar lyskom-unread-confs nil
  "List containing all unread confs.")

(defvar lyskom-dont-change-prompt nil
  "Non-nil during the entry of a text.")

(defvar lyskom-fetched-texts nil
  "List of texts that are prefetched.")

(defvar lyskom-command-to-do 'unknown
  "Atom describing what command to do. See the function lyskom-what-to-do.")

(defvar lyskom-is-waiting nil
  "If non-nil then this is the condition for the waiting to be stopped.
If t however just meaning user is waiting for a text with prompt.
It is a form that will be evaluated (using eval) every time the asynchronous
Per Cederqvist's avatar
Per Cederqvist committed
720
721
722
message \"new text\" is received.

This is used by the command kom-busy-wait.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
723
724
725
726
727
728
729
730
731
732

(defvar lyskom-current-conf 0
  "Current conference. 0 means user is not reading any conf.")

(defvar lyskom-current-text nil
  "Text-no of current text. nil means no text is current.")

(defvar lyskom-previous-text nil
  "Text-no of previous text.  Nil means no text.")

733
734
735
(defvar lyskom-normally-read-texts nil
  "Stack of texts that are read normally. Used for kom-review-last-normally-read.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
736
737
738
(defvar lyskom-current-subject ""
  "Current subject.")

739
740
741
742
743
744
(defvar lyskom-last-added-rcpt 0
  "The default conference when adding a recipient.")

(defvar lyskom-last-added-ccrcpt 0
  "The default conference when adding a ccrecipient.")

745
746
(defvar lyskom-saved-file-name (concat default-directory "kom-text")
  "The default file name when saving a lyskom-text.")
Per Cederqvist's avatar
.    
Per Cederqvist committed
747
748
749
750

(defvar lyskom-mode-hook nil
  "Hook to run when lyskom-mode is entered.")

Linus Tolke's avatar
Linus Tolke committed
751
752
753
(defvar kom-quit-hook nil
  "Hook to run when the LysKOM session is correctly ended.")

754
(defvar kom-quit-when-idle t
David Byers's avatar
David Byers committed
755
  "Non-niil to automatically quit when LysKOM is full and the session is idle")
756

757
(defvar kom-permanent-filter-list nil
David Byers's avatar
David Byers committed
758
  "List of patterns to filter permanently")
759
760
761
762

(defvar kom-session-filter-list nil
  "List of patterns to filter during this session")

763

764
765
766
(defvar lyskom-filter-list nil
  "List of patterns that are filtered.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
767
768
769
770
771
772
773
774
775
776
777
778
(defvar lyskom-new-text-hook nil
  "*Hook to run when a new text is created.
This hook is run after the prompt is removed if it shall be changed but before
the text Text 4711 {r skapad! is printed in the message area. And before the
new prompt is printed.
If the text: Text 4711 {r skapad! should not be printed then the hook should 
set the local variable no-message non-nil.")

(defvar lyskom-who-info-has-changed-hook nil
  "*Hook to run every time the who-info-buffer has changed.
The hook is run with current-buffer the lyskom buffer, not the who-info-buffer.")

779
780
781
782
783
784
785
786
(defvar lyskom-personal-message-hook nil
  "*Hook to run when a personal message is received.
When the hook is run 'sender' is bound to the pers-stat of the sender
of the message (or possibly nil), 'recipient' is 0 if the message is a
public message and otherwise the pers-no of the user, and 'message' is
a string that holds the message.")


Per Cederqvist's avatar
.    
Per Cederqvist committed
787
788
789
790
(defvar lyskom-executing-command t
  "Non-nil means the client is executing a command.
Most commands can't be interrupted by another command.")

791
792
793
(defvar lyskom-current-command nil
  "The command currently being executed.")

Per Cederqvist's avatar
.    
Per Cederqvist committed
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
(defvar kom-low-priority -1
  "*Priority that the current conference are set to when they are
aborted. nil means don't alter priority. (That means that
kom-go-to-next-conf might go to the same conference again.)")

(defvar lyskom-membership-is-read nil
  "T when the membership has been read.")

(defvar lyskom-is-writing nil
  "t when the user is writing a text.")

(defvar lyskom-debug-communications-to-buffer nil
  "Non-nil means all communications with the server is stored in a buffer.
The name is stored in lyskom-debug-communications-to-buffer-buffer.")
  
809
(defvar lyskom-debug-communications-to-buffer-buffer "*kom*-debugs"
Per Cederqvist's avatar
.    
Per Cederqvist committed
810
811
812
813
814
815
816
817
818
819
820
821
  "Name of the buffer to insert the communications with the server into if
lyskom-debug-communications-to-buffer is non-nil.")


(defvar lyskom-count-var 0
  "This variable is used for counting things in the client, such as
unread texts in list-unread.")


(defvar lyskom-is-administrator nil
  "This variable is t if the user is in administrator mode and nil otherwise.")

822
823
824
825
826
827
(defvar lyskom-emacs19-p nil
  "This variable is t if LysKOM is running in Emacs 19")

(defvar lyskom-last-personal-message-sender ""
  "Name of sender of last personal message received")

David Kågedal's avatar
David Kågedal committed
828
829
830
(defvar lyskom-last-group-message-recipient ""
  "Name of target for last group message received")

David Kågedal's avatar
David Kågedal committed
831
832
833
(defvar lyskom-is-new-user nil
  "An internal variable used in kom-start-anew")

Per Cederqvist's avatar
.    
Per Cederqvist committed
834

835
836
837
;;;; lyskom-tell-phrases-validation-keyword-list
;;; This is a list of keywords for kom-tell-phrases.
;;; These are the only keywords that are allowed in kom-tell-phrases.
838

839
840
841
842
843
844
845
846
847
848
849
;;; To coders of the elisp-client:
;;; If you add/delete a reference to any of these keywords make sure
;;; you update these changes.

;;; To everyone:
;;; The kom-tell-phrases list is checked against this list when the
;;; client is loaded, i.e. by lyskom-tell-phrases-validate that causes
;;; an error if any keyword is not present or any non-keyword is
;;; present.

(defconst lyskom-tell-phrases-validation-keyword-list
850
  '(
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
    (kom-tell-silence)
    (kom-tell-send)
    (kom-tell-login)
    (kom-tell-read)
    (kom-tell-1st-pres)
    (kom-tell-write-comment)
    (kom-tell-write-footnote)
    (kom-tell-write-letter)
    (kom-tell-write-reply)
    (kom-tell-write-text)
    (kom-tell-conf-pres)
    (kom-tell-recover)
    (kom-tell-wait)
    (kom-tell-regret)
    (kom-tell-review)
    (kom-tell-change-name)
    (kom-tell-change-supervisor)
    (kom-tell-next-lyskom)
869
    )
870
  "Users must not change this constant, but are encouraged to change
871
872
the value of  kom-tell-phrases  for fun.")

873
874
875
876
877
878
879
880
881
882
;;; ================================================================
;;; Commands lists that are removed from extended command depending on
;;; administrator status.

(defconst lyskom-admin-removed-commands
  '(kom-enable-adm-caps))
(defconst lyskom-noadmin-removed-commands
  '(kom-disable-adm-caps kom-remove-motd kom-set-motd kom-shutdown-server))


Per Cederqvist's avatar
.    
Per Cederqvist committed
883
884
885
886
887
888
889
890
891
892
893
894
;;; ================================================================
;;;          Externally defined variables (environment)


(defvar lyskom-default-server "kom.lysator.liu.se"
  "*Default LysKOM server.")

(defvar lyskom-default-user-name nil
  "*Default LysKOM user name.")

(defvar lyskom-default-password nil
  "Default LysKOM PASSWORD.")
Linus Tolke's avatar
Linus Tolke committed
895
896
897

(defvar mode-line-conf-name nil
  "Conf name that is present on the mode-line.")
David Kågedal's avatar
David Kågedal committed
898
899
900
901
902
903
904
905
906

;;; ================================================================
;;;         Faces

(defmacro lyskom-make-face (name &rest body)
  (` (if (memq (, name) (face-list))
	 nil
       (,@ body))))

David Byers's avatar
David Byers committed
907
908
909
910
911
912
913
914
915
916
917
(defun lyskom-set-face-foreground (face color)
  (condition-case error
      (set-face-foreground face color)
    (error nil)))

(defun lyskom-set-face-background (face color)
  (condition-case error
      (set-face-background face color)
    (error nil)))


David Kågedal's avatar
David Kågedal committed
918
919
(put 'lyskom-make-face 'lisp-indent-function 1)

David Kågedal's avatar
David Kågedal committed
920
921
(when (eq window-system 'x)
  (if (x-display-color-p)
David Kågedal's avatar
David Kågedal committed
922
923
      (let* ((bgmode (cdr (assq 'background-mode (frame-parameters))))
	     (dark-bg (eq bgmode 'dark)))
David Kågedal's avatar
David Kågedal committed
924
	;; Face for text buttons and other KOM buttons
David Kågedal's avatar
David Kågedal committed
925
	(lyskom-make-face 'kom-active-face
David Kågedal's avatar
David Kågedal committed
926
	  (copy-face 'default 'kom-active-face)
David Byers's avatar
David Byers committed
927
	  (lyskom-set-face-foreground 'kom-active-face
David Kågedal's avatar
David Kågedal committed
928
			       (if dark-bg "lightblue" "blue4")))
David Kågedal's avatar
David Kågedal committed
929
	;; Face for URL buttons
David Kågedal's avatar
David Kågedal committed
930
	(lyskom-make-face 'kom-url-face
David Kågedal's avatar
David Kågedal committed
931
	  (copy-face 'default 'kom-url-face)
David Byers's avatar
David Byers committed
932
	  (lyskom-set-face-foreground 'kom-url-face
David Kågedal's avatar
David Kågedal committed
933
			       (if dark-bg "Moccasin" "BlueViolet")))
David Kågedal's avatar
David Kågedal committed
934
	;; Face for highlighting you own name
David Kågedal's avatar
David Kågedal committed
935
	(lyskom-make-face 'kom-me-face
David Kågedal's avatar
David Kågedal committed
936
	  (copy-face 'bold 'kom-me-face)
David Byers's avatar
David Byers committed
937
938
	  (lyskom-set-face-foreground 'kom-me-face "gold")
	  (lyskom-set-face-background 'kom-me-face "black"))
David Kågedal's avatar
David Kågedal committed
939
	;; Not sure what this is for
David Kågedal's avatar
David Kågedal committed
940
	(lyskom-make-face 'kom-highlight-face
David Kågedal's avatar
David Kågedal committed
941
	  (copy-face 'highlight 'kom-highlight-face)
David Byers's avatar
David Byers committed
942
	  (lyskom-set-face-foreground 'kom-highlight-face 
David Kågedal's avatar
David Kågedal committed
943
			       "midnight blue"))
David Kågedal's avatar
David Kågedal committed
944
	;; This face is not used at the moment (960226)
David Kågedal's avatar
David Kågedal committed
945
	(lyskom-make-face 'kom-text-face
David Kågedal's avatar
David Kågedal committed
946
	  (copy-face 'default 'kom-text-face))
David Kågedal's avatar
David Kågedal committed
947
	;; Face for the subject string
David Kågedal's avatar
David Kågedal committed
948
	(lyskom-make-face 'kom-subject-face
David Kågedal's avatar
David Kågedal committed
949
	  (copy-face 'kom-text-face 'kom-subject-face)
David Byers's avatar
David Byers committed
950
	  (lyskom-set-face-foreground 'kom-subject-face
David Kågedal's avatar
David Kågedal committed
951
			       (if dark-bg "Khaki" "dark green")))
David Kågedal's avatar
David Kågedal committed
952
	;; Not used (960226)
David Kågedal's avatar
David Kågedal committed
953
	(lyskom-make-face 'kom-text-no-face
David Kågedal's avatar
David Kågedal committed
954
	  (copy-face 'kom-text-face 'kom-text-no-face))
David Kågedal's avatar
David Kågedal committed
955
	;; Face for presence messages in the buffer
David Kågedal's avatar
David Kågedal committed
956
	(lyskom-make-face 'kom-presence-face
David Kågedal's avatar
David Kågedal committed
957
958
	  (make-face 'kom-presence-face)
	  (make-face-italic 'kom-presence-face nil t)
David Kågedal's avatar
David Kågedal committed
959
	  (set-face-foreground 'kom-presence-face "grey")))
David Kågedal's avatar
David Kågedal committed
960
961
    (progn
      (lyskom-make-face 'kom-active-face
David Kågedal's avatar
David Kågedal committed
962
	(copy-face 'underline 'kom-active-face))
David Kågedal's avatar
David Kågedal committed
963
      (lyskom-make-face 'kom-url-face
David Kågedal's avatar
David Kågedal committed
964
	(copy-face 'kom-active-face 'kom-url-face))
David Kågedal's avatar
David Kågedal committed
965
      (lyskom-make-face 'kom-me-face
David Kågedal's avatar
David Kågedal committed
966
	(copy-face 'highlight 'kom-me-face))
David Kågedal's avatar
David Kågedal committed
967
      (lyskom-make-face 'kom-highlight-face
David Kågedal's avatar
David Kågedal committed
968
	(copy-face 'highlight 'kom-highlight-face))
David Kågedal's avatar
David Kågedal committed
969
      (lyskom-make-face 'kom-subject-face
David Kågedal's avatar
David Kågedal committed
970
	(copy-face 'default 'kom-subject-face))
David Kågedal's avatar
David Kågedal committed
971
      (lyskom-make-face 'kom-text-face
David Kågedal's avatar
David Kågedal committed
972
	(copy-face 'default 'kom-subject-face))
David Kågedal's avatar
David Kågedal committed
973
      (lyskom-make-face 'kom-text-no-face
David Kågedal's avatar
David Kågedal committed
974
	(copy-face 'default 'kom-subject-face))
David Kågedal's avatar
David Kågedal committed
975
      (lyskom-make-face 'kom-presence-face
David Kågedal's avatar
David Kågedal committed
976
977
	(make-face 'kom-presence-face)
	(make-face-italic 'kom-presence-face nil t)))))
David Kågedal's avatar
David Kågedal committed
978