option-edit.el 77 KB
Newer Older
David Byers's avatar
David Byers committed
1
;;;;; -*-coding: iso-8859-1;-*-
2
3
;;;;;
;;;;; $Id$
4
;;;;; Copyright (C) 1991-2002  Lysator Academic Computer Association.
5
;;;;;
6
;;;;; This file is part of the LysKOM Emacs LISP client.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;;;;; 
;;;;; 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 2, 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. 
;;;;;
;;;; ================================================================
;;;; ================================================================
;;;;
David Byers's avatar
David Byers committed
29
;;;; File: option-edit.el
30
;;;;
David Byers's avatar
David Byers committed
31
;;;; Customization for LysKOM
32
33
34
35
36
37
38
;;;;


(setq lyskom-clientversion-long 
      (concat lyskom-clientversion-long
	      "$Id$\n"))

39
40
41
(lyskom-external-function widget-default-format-handler)
(lyskom-external-function popup-mode-menu)

42
43
;;; ======================================================================
;;; Require Per Abrahamsens widget package, version 0.991 or later.
David Byers's avatar
David Byers committed
44
45
;;;

46
47
48
;;; ======================================================================
;;; Global variables

David Byers's avatar
David Byers committed
49
50
51
(defvar lyskom-widgets nil
  "List of widgets in the customize buffer.")

52
53
;(setq lyskom-customize-buffer-format '([kom-format-html-authors]))

54
(defvar lyskom-customize-buffer-format
David Byers's avatar
David Byers committed
55
  '("\n"
56
57
58
59
60
61
62
63
64
65
66
67
68
    (lyskom bold centered)
    "\n\n"
    lyskom-doc
    "\n\n"
    [kom-customize-format]
    "\n\n"
    section
    (look-and-feel-misc bold centered)
    section
    "\n"
    [kom-default-language]
    [kom-show-namedays]
    [kom-show-week-number]
69
70
    [kom-print-relative-dates]
    [kom-print-seconds-in-time-strings]
71
    "\n"
72
    [kom-extended-status-information]
David Byers's avatar
David Byers committed
73
74
75
    [kom-auto-list-faqs]
    [kom-auto-review-faqs]
    "\n"
David Byers's avatar
David Byers committed
76
77
    [kom-auto-confirm-new-conferences]
    "\n"
78
    [kom-idle-hide]
79
    [kom-relogin-behaviour]
80
    [kom-relogin-inhibit-commands]
81
    [kom-remember-password]
82
83
84
    [kom-show-where-and-what]
    [kom-show-since-and-when]
    "\n"
85
    [kom-highlight-conferences]
86
    [kom-friends]
87
    [kom-morons]
88
89
90
91
    [kom-person-list-1]
    [kom-person-list-2]
    [kom-person-list-3]
    [kom-person-list-4]
92
    "\n"
93
    [kom-show-unread-in-frame-title]
94
    [kom-unread-mode-line-type]
David Byers's avatar
David Byers committed
95
    [kom-presence-messages-in-echo-area]
96
97
    [kom-presence-messages-in-buffer]
    "\n"
98
    [kom-text-no-prompts]
99
    [kom-keyboard-menu-immediate-selection]
100
    [kom-page-before-command]
101
102
    [kom-deferred-printing]
    [kom-max-buffer-size]
103
    [kom-trim-buffer-minimum]
104
    [kom-bury-buffers]
105
    [kom-keep-alive-interval]
Pontus Freyhult's avatar
Pontus Freyhult committed
106
    [kom-lost-session-notification]
107
    [kom-show-sync-messages]
108
    "\n"
109
110
    [kom-agree-text]
    [kom-mercial]
111
112
113
114
115
116
117
    "\n"
    [kom-user-prompt-format]
    [kom-user-prompt-format-executing]
    [kom-anonymous-prompt-format]
    [kom-anonymous-prompt-format-executing]
    [kom-enabled-prompt-format]
    [kom-enabled-prompt-format-executing]
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    "\n\n"
    section
    (window-locations bold centered)
    section
    "\n"
    (windows-where bold centered)
    "\n"
    windows-doc
    "\n\n"
    [kom-customize-in-window]
    [kom-edit-filters-in-window]
    [kom-prioritize-in-window]
    [kom-list-membership-in-window]
    [kom-write-texts-in-window]
    [kom-view-commented-in-window]
    [kom-personal-messages-in-window]
    
135
136
    "\n\n"
    section
137
    (predefined-fonts bold centered)
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    section
    "\n"
    [kom-active-face]
    [kom-url-face]
    [kom-me-face]
    [kom-highlight-face]
    [kom-subject-face]
    [kom-text-no-face]
    [kom-friends-face]
    [kom-morons-face]
    [kom-presence-face]
    [kom-first-line-face]
    [kom-warning-face]
    [kom-mark-face]
    [kom-dim-face]
    [kom-text-body-face]
    [kom-dashed-lines-face]
    [kom-async-text-body-face]
    [kom-async-dashed-lines-face]
157
158
    "\n\n"
    section
159
160
161
162
163
164
165
    (other-fonts bold centered)
    section
    "\n"
    [kom-active-highlight-face]
    [kom-active-strikethrough-face]
    "\n\n"
    section
166
167
168
169
170
171
172
173
174
    (audio-cues bold centered)
    section
    "\n"
    [kom-audio-player]
    "\n"
    (audio-cues-when bold centered)
    "\n"
    audio-cues-doc
    "\n\n"
175
176
    [kom-ding-on-priority-break]
    [kom-ding-on-new-letter]
David Byers's avatar
David Byers committed
177
    [kom-ding-on-wait-done]
178
    [kom-ding-on-no-subject]
David Byers's avatar
David Byers committed
179
180
181
    [kom-ding-on-common-messages]
    [kom-ding-on-group-messages]
    [kom-ding-on-personal-messages]
Joel Rosdahl's avatar
Joel Rosdahl committed
182
    "\n"
183
184
185
186
187
188
189
190
191
    [kom-silent-ansaphone]
    "\n\n"
    section
    (reading bold centered)
    section
    "\n"
    [kom-default-session-priority]
    [kom-print-number-of-unread-on-entrance]
    [kom-allow-incompleteness]
192
    [kom-permissive-completion]
193
    [kom-complete-numbers-before-names]
194
195
    [kom-continuous-scrolling]
    [kom-inhibit-typeahead]
196
    [kom-confirm-add-recipients]
197
    "\n"
198
199
    [kom-higher-priority-breaks]
    [kom-review-priority]
200
201
    [kom-server-priority]
    [kom-server-priority-breaks]
202
    [kom-session-nickname]
203
    "\n"
204
205
    [kom-read-depth-first]
    [kom-reading-puts-comments-in-pointers-last]
206
207
    [kom-show-footnotes-immediately]
    [kom-follow-comments-outside-membership]
208
    [kom-follow-attachments]
209
    [kom-mark-read-texts-as-read-in-new-recipient]
210
    [kom-created-texts-are-read]
211
    [kom-created-texts-are-saved]
212
    [kom-review-uses-cache]
213
    [kom-review-marks-texts-as-read]
214
    "\n"
215
    [kom-saved-file-name]
216
    [kom-default-mark]
217
    [kom-symbolic-marks-alist]
Pontus Freyhult's avatar
Pontus Freyhult committed
218
    [kom-membership-default-message-flag]
219
220
221
222
223
224
    [kom-membership-default-priority]
    [kom-membership-default-placement]
    [kom-unsubscribe-makes-passive]
    [kom-postpone-default]
    "\n"
    [kom-autowrap]
225
    [kom-autowrap-timeout]
226
227
228
229
230
    [kom-show-author-at-end]
    [kom-show-creating-software]
    [kom-show-imported-importer]
    [kom-show-imported-external-recipients]
    [kom-show-imported-envelope-sender]
231
    [kom-show-imported-message-id]
David Byers's avatar
David Byers committed
232
233
    [kom-text-properties]
    [kom-fontify-text]
234
235
    [kom-smileys]
    [kom-w3-simplify-body]
David Byers's avatar
David Byers committed
236
    [kom-format-html-authors]
237
    [kom-format-show-images]
238
    "\n"
239
    [kom-max-overlays]
240
241
242
    [kom-highlight-first-line]
    [kom-highlight-dashed-lines]
    [kom-highlight-text-body]
243
244
    [kom-async-highlight-dashed-lines]
    [kom-async-highlight-text-body]
245
    "\n"
246
247
248
249
250
251
252
253
254
255
256
257
    [kom-dashed-lines]
    [kom-long-lines]
    [kom-text-footer-format]
    [kom-text-header-dash-length]
    [kom-text-footer-dash-length]
    "\n"
    [kom-truncate-threshold]
    [kom-truncate-show-lines]
    "\n"
    [kom-ignore-message-senders]
    [kom-ignore-message-recipients]
    [kom-show-personal-message-date]
David Byers's avatar
David Byers committed
258
    [kom-filter-outgoing-messages]
259
260
261
262
263
    "\n\n"
    section
    (writing bold centered)
    section
    "\n"
264
    [kom-edit-hide-add-button]
265
266
267
268
269
270
271
    [kom-cite-string]
    [kom-ispell-dictionary]
    "\n"
    sending-doc
    "\n\n"
    [kom-confirm-multiple-recipients]
    [kom-check-commented-author-membership]
272
    [kom-dont-check-commented-authors]
273
274
275
276
277
278
279
    [kom-check-for-new-comments]

    "\n\n"
    section
    (urls bold centered)
    section
    "\n"
280
    [kom-text-links]
David Byers's avatar
David Byers committed
281
    [kom-url-transformation-rules]
282
    [kom-url-viewer-preferences]
283
    [kom-windows-browser-command]
284
285
    [kom-mosaic-command]
    [kom-netscape-command]
David Byers's avatar
David Byers committed
286
    [kom-netscape-variant]
Ulrik Haugen's avatar
Ulrik Haugen committed
287
    [kom-galeon-command]
288
289
290
291
    [kom-lynx-terminal]
    [kom-lynx-xterm-command]
    [kom-lynx-terminal-command]

292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307

    "\n\n"
    section
    (personal-messages bold centered)
    section
    "\n"
    [kom-show-personal-messages-in-buffer]
    [kom-pop-personal-messages]
    [kom-default-message-recipient]
    "\n"
    (automatic-replies bold centered)
    "\n"
    [kom-ansaphone-record-messages]
    [kom-ansaphone-show-messages]
    "\n"
    [kom-ansaphone-default-reply]
308
309
    "\n"
    [kom-ansaphone-replies]
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
    "\n\n"
    section
    (remote-control bold centered)
    section
    "\n"
    [kom-remote-control]
    [kom-self-control]
    "\n"
    [kom-remote-controllers]
    "\n\n"
    section
    (hooks bold centered)
    section
    "\n"
    [kom-login-hook]
    [kom-do-when-done]
326
327
328
    ))

;;; ======================================================================
David Byers's avatar
David Byers committed
329
330
331
332
333
334
335
336
337
338
;;;     User functions
;;;

(defun lyskom-customize-apply ()
  "Set the variables in the LysKOM buffer according to their values in the
customize buffer but do not save them to the server."
  (interactive)
  (let ((tmp lyskom-widgets))
    (save-excursion
      (set-buffer lyskom-buffer)
David Byers's avatar
David Byers committed
339
340
      (when (listp kom-dont-read-saved-variables)
        (setq kom-dont-read-saved-variables nil))
David Byers's avatar
David Byers committed
341
342
343
      (while tmp
        (set (car (car tmp))
             (widget-value (cdr (car tmp))))
David Byers's avatar
David Byers committed
344
345
346
347
348
        (when (not (widget-value (widget-get (cdr (car tmp)) 
                                             ':lyskom-storage-widget)))
          (set-default (car (car tmp)) (widget-value (cdr (car tmp))))
          (when (and (listp kom-dont-read-saved-variables)
                     (or (memq (car (car tmp)) lyskom-elisp-variables)
349
                         (lyskom-flag-global-variable-from-elisp (car (car tmp)))))
David Byers's avatar
David Byers committed
350
351
            (setq kom-dont-read-saved-variables 
                  (cons (car (car tmp)) kom-dont-read-saved-variables))))
David Byers's avatar
David Byers committed
352
353
        (setq tmp (cdr tmp))))))

David Byers's avatar
David Byers committed
354
355
(eval-when-compile (defvar save-options-init-file nil))

David Byers's avatar
David Byers committed
356
357
358
359
360
361
362
(defun lyskom-customize-send ()
  "Save variables to the server"
  (save-excursion
    (set-buffer lyskom-buffer)
    (lyskom-save-options (current-buffer)
                         (lyskom-get-string 'saving-settings)
                         (lyskom-get-string 'saving-settings-done)
David Byers's avatar
David Byers committed
363
364
365
366
367
368
369
                         (lyskom-get-string 'could-not-save-options))
    (let ((var-list nil))
      (mapcar 
       (function 
        (lambda (e)
          (when (and (vectorp e)
                     (symbolp (elt e 0))
David Byers's avatar
David Byers committed
370
371
                     (or 
                      (and (not (memq (elt e 0) lyskom-elisp-variables))
372
                           (not (lyskom-flag-global-variable-from-elisp (elt e 0))))
David Byers's avatar
David Byers committed
373
                      (memq (elt e 0) kom-dont-read-saved-variables))
David Byers's avatar
David Byers committed
374
375
376
377
378
                     (boundp (elt e 0)))
            (setq var-list (cons (cons (elt e 0)
                                       (symbol-value (elt e 0)))
                                 var-list)))))
       lyskom-customize-buffer-format)
379

David Byers's avatar
David Byers committed
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
      (let* ((actual-save-options-init-file
              (or (and (boundp 'save-options-init-file)
                       save-options-init-file)
                  (and (not (equal user-init-file ""))
                       user-init-file)
                  (and (eq system-type 'ms-dos)
                       (concat "~" (user-login-name) "/_emacs"))
                  (concat "~" (user-login-name) "/.emacs")))
             (init-output-buffer (find-file-noselect
                                  actual-save-options-init-file))
             (init-output-marker nil))

        (save-excursion
          (set-buffer init-output-buffer)
          ;;
          ;; Find and delete the previously saved data, and position to write.
          ;;
          (goto-char (point-min))
          (if (re-search-forward "^;;; LysKOM Settings *\n" nil 'move)
              (let ((p (match-beginning 0)))
                (goto-char p)
                (or (re-search-forward
                     "^;;; End of LysKOM Settings *\\(\n\\|\\'\\)"
                     nil t)
                    (error "can't find END of saved state in .emacs"))
                (delete-region p (match-end 0)))
            (goto-char (point-max))
            (insert "\n"))
          (setq init-output-marker (point-marker)))

    (let ((standard-output init-output-marker))
      (princ ";;; LysKOM Settings\n")
      (princ ";;; =====================\n")
David Byers's avatar
David Byers committed
413
414
415
416
417
418
419
420
421
      (mapcar (lambda (x)
                (princ (format "(setq-default %S %s%S)\n" 
                               (car x)
                               (cond ((eq (cdr x) t) "")
                                     ((null (cdr x)) "")
                                     ((symbolp (cdr x)) "'")
                                     ((listp (cdr x)) "'")
                                     (t ""))
                               (cdr x))))
David Byers's avatar
David Byers committed
422
423
424
425
426
427
428
429
430
       var-list)
      (princ ";;; ============================\n")
      (princ ";;; End of LysKOM Settings\n"))

    (set-marker init-output-marker nil)
    (save-excursion
      (set-buffer init-output-buffer)
      (save-buffer))
    ))))
David Byers's avatar
David Byers committed
431
432
433
434
435
436
437
438
439
440

(defun lyskom-customize-save ()
  "Apply changes and save them to the server."
  (interactive)
  (lyskom-customize-apply)
  (lyskom-customize-send))

(defun lyskom-customize-quit ()
  "Quit the customize buffer without saving"
  (interactive)
441
442
443
  (let ((buf (current-buffer)))
    (lyskom-undisplay-buffer buf)
    (kill-buffer buf)))
David Byers's avatar
David Byers committed
444
445
446
447
448
449
450
451

(defun lyskom-customize-save-and-quit ()
  "Save and quit the customize buffer"
  (interactive)
  (lyskom-customize-apply)
  (lyskom-customize-send)
  (lyskom-customize-quit))

David Byers's avatar
David Byers committed
452
453
454
455
(defun lyskom-customize-help ()
  (interactive)
  (message (lyskom-get-string 'customize-help)))

David Byers's avatar
David Byers committed
456
457
(defun lyskom-widget-click (event)
  (interactive "e")
458
  (let ((pos (lyskom-event-point event)))
David Byers's avatar
David Byers committed
459
460
461
462
    (if (and pos (widget-at pos))
        (widget-button-click event)
      (popup-mode-menu))))

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
(defun lyskom-customize-mode ()
  "Major mode for editing LysKOM settings.
See the top of the buffer for localized help.

These commands work outside editable text fields.
\\[lyskom-customize-save-and-quit] to save and quit,
\\[lyskom-customize-save-and-quit] to save and quit,
\\[lyskom-customize-save] to save without quitting,
\\[lyskom-customize-quit] to quit without saving.
\\[widget-forward] moves to the next setting
\\[widget-button-press] changes the value
Press C-h m for a complete list of commands.

Documentation:  [?] Show documentation    [!] Hide documentation
Lists etc.   :  [INS] Add a line   [DEL] Remove a line   [*] Modify

If the box before the name of the setting is selected, the setting will
be saved in the server. Otherwise it will be saved in your .emacs.

Click prompts with the middle mouse button to change values and bring 
up menus.

All key bindings:
\\{lyskom-customize-map}
"
  (kill-all-local-variables)
  (use-local-map lyskom-customize-map)
  (make-local-variable 'lyskom-widgets)
  (setq lyskom-widgets nil)
  (let ((inhibit-read-only t))
    (erase-buffer))
  (condition-case nil
      (lyskom-copy-face kom-active-face 'widget-button-face)
    (error nil))
  (mapcar 'lyskom-custom-insert lyskom-customize-buffer-format)
  (widget-setup)
  (mapcar (function
           (lambda (variable)
             (widget-value-set (cdr variable)
                               (save-excursion
                                 (set-buffer lyskom-buffer)
                                 (symbol-value (car variable))))))
          lyskom-widgets)
  (widget-setup)
  (setq mode-name "LysKOM Settings")
  (setq major-mode 'lyskom-customize-mode)
  )

David Byers's avatar
David Byers committed
511
512
513
(defun kom-customize ()
  "Open the customize buffer"
  (interactive)
David Byers's avatar
X    
David Byers committed
514
515
516
517
518
  (let ((buf (lyskom-get-buffer-create 'customize
                                       (lyskom-format
                                        (lyskom-custom-string 'buffer-name)
                                        lyskom-server-name)
                                       t)))
David Byers's avatar
David Byers committed
519
520
521
    (unwind-protect
        (progn
          (lyskom-start-of-command 'kom-customize)
522
523
524
525
          (sit-for 0)
          (save-excursion
            (set-buffer buf)
            (lyskom-customize-mode))
David Byers's avatar
X    
David Byers committed
526
           (lyskom-display-buffer buf))
David Byers's avatar
David Byers committed
527
528
529
530
531
      (save-excursion
        (set-buffer lyskom-buffer)
        (lyskom-end-of-command)))
    (goto-char (point-min))))

532

David Byers's avatar
David Byers committed
533
534
535
536
537
538
;;; ============================================================
;;; Non-user functions
;;;

(defun lyskom-custom-insert (w)
  (cond ((symbolp w)
539
         (widget-insert (substitute-command-keys (lyskom-custom-string w))))
David Byers's avatar
David Byers committed
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
        ((listp w)
         (let ((start (point))
               (end nil)
               (inhibit-read-only t))
           (widget-insert (lyskom-custom-string (car w)))
           (setq end (point))
           (mapcar (function
                    (lambda (fn)
                      (funcall (intern (concat "lyskom-custom-insert-"
                                               (symbol-name fn)))
                               start end)))
                   (cdr w))))
        ((stringp w)
         (widget-insert w))
        ((vectorp w)
         (setq lyskom-widgets (cons (cons (aref w 0)
                                          (lyskom-create-widget (aref w 0)))
                                    lyskom-widgets)))))

David Byers's avatar
David Byers committed
559
;;UNUSED: lyskom-custom-insert-bold
David Byers's avatar
David Byers committed
560
(defun lyskom-custom-insert-bold (s e)
David Byers's avatar
David Byers committed
561
  (add-text-properties s e (list 'face 'bold 'end-closed nil)))
David Byers's avatar
David Byers committed
562

David Byers's avatar
David Byers committed
563
;;UNUSED: lyskom-custom-insert-centered
David Byers's avatar
David Byers committed
564
565
566
567
568
569
570
571
572
573
574
(defun lyskom-custom-insert-centered (s e)
  (save-excursion (goto-char s)
                  (center-line 1)))


(defun lyskom-custom-get-value (var)
  (save-excursion
    (set-buffer lyskom-buffer)
    (symbol-value var)))

(defun lyskom-custom-string (s)
575
  (lyskom-get-string s 'lyskom-custom-strings))
David Byers's avatar
David Byers committed
576

577
(defvar lyskom-custom-variables-missing '(kom-permanent-filter-list
578
579
                                          kom-quit-hook 
                                          lyskom-last-known-conf-no
580
581
                                          lyskom-last-known-pers-no
                                          kom-presence-messages
582
583
                                          kom-dont-complain-about-missing-presentation
                                          lyskom-settings-version)
584
585
  "List of user variables not in lyskom-custom-variables.")

David Byers's avatar
David Byers committed
586
(defvar lyskom-custom-variables
587
  '(
588
589
590
591
    (kom-max-overlays (choice ((number nil
                                       :tag limited-number
                                       :format "%[%t%] (%v)")
                               (const (unlimited-number nil)))))
592
593
594
    (kom-highlight-first-line (toggle (on off)))
    (kom-highlight-dashed-lines (toggle (on off)))
    (kom-highlight-text-body (toggle (on off)))
595
596
    (kom-async-highlight-dashed-lines (toggle (on off)))
    (kom-async-highlight-text-body (toggle (on off)))
597
    (kom-personal-messages-in-window (open-window))
David Byers's avatar
David Byers committed
598
    (kom-write-texts-in-window (open-window))
David Byers's avatar
X    
David Byers committed
599
600
    (kom-list-membership-in-window (open-window))
    (kom-edit-filters-in-window (open-window))
David Byers's avatar
David Byers committed
601
602
    (kom-prioritize-in-window (open-window))
    (kom-customize-in-window (open-window))
David Byers's avatar
David Byers committed
603
604
605
    (kom-view-commented-in-window (open-window))
    (kom-edit-filters-in-window (open-window))
    (kom-list-membership-in-window (open-window))
606
607
    (kom-customize-format (choice ((const (long-format long))
                                   (const (short-format short)))))
608
    (kom-default-language (repeat (language-choice nil)))
David Byers's avatar
X    
David Byers committed
609
610
    (kom-user-prompt-format (string))
    (kom-user-prompt-format-executing (string))
611
612
613
614
    (kom-anonymous-prompt-format (string))
    (kom-anonymous-prompt-format-executing (string))
    (kom-enabled-prompt-format (string))
    (kom-enabled-prompt-format-executing (string))
David Byers's avatar
David Byers committed
615
616
    (kom-cite-string (string))
    (kom-created-texts-are-read (toggle (yes no)))
617
    (kom-mark-read-texts-as-read-in-new-recipient (toggle (yes no)))
618
    (kom-review-uses-cache (toggle (yes no)))
619
    (kom-review-marks-texts-as-read (toggle (yes no)))
620
621
    (kom-created-texts-are-saved (choice ((const (no nil))
                                          (file nil :tag to-file))))
David Byers's avatar
David Byers committed
622
    (kom-default-mark (choice ((number (0 255) 
David Byers's avatar
David Byers committed
623
                                       :tag selected-mark
624
625
                                       :format "%[%t%] (%v)"
                                       :size 0)
David Byers's avatar
David Byers committed
626
                               (const (ask nil)))))
627
628
629
630
    (kom-symbolic-marks-alist (repeat (mark-association
                                       nil
                                       :tag symbolic-mark-association
                                       :mark-key-prompt symbolic-mark-name
631
                                       :mark-value-prompt mark-type-to-assoc)))
632
    (kom-reading-puts-comments-in-pointers-last (toggle (after before)))
David Byers's avatar
David Byers committed
633
634
635
    (kom-autowrap (choice ((const (on t))
                           (const (off nil))
                           (number nil :tag max-text-length))))
636
637
    (kom-autowrap-timeout (choice ((const (no-timeout nil))
                                   (number nil :tag autowrap-timeout))))
638
639
    (kom-auto-list-faqs (toggle (on off)))
    (kom-auto-review-faqs (toggle (on off)))
David Byers's avatar
David Byers committed
640
    (kom-dashed-lines (toggle (on off)))
David Byers's avatar
David Byers committed
641
    (kom-show-author-at-end (toggle (on off)))
642
643
644
645
646

    (kom-truncate-threshold (choice ((const (off nil))
				     (number nil :tag truncate-threshold-lines))))
    (kom-truncate-show-lines (number nil))

David Byers's avatar
David Byers committed
647
648
    (kom-print-number-of-unread-on-entrance (toggle (yes no)))
    (kom-show-where-and-what (toggle (yes no)))
649
    (kom-show-since-and-when (toggle (yes no)))
650
    (kom-remember-password (toggle (yes no)))
David Byers's avatar
David Byers committed
651
652
653
654
655
656
657
658
659
    (kom-idle-hide (number))
    (kom-show-footnotes-immediately (toggle (yes no)))
    (kom-follow-comments-outside-membership (toggle (yes no)))
    (kom-read-depth-first (toggle (depth-first time-order)))
    (kom-continuous-scrolling  (toggle (on off)))
    (kom-deferred-printing (toggle (on off)))
    (kom-higher-priority-breaks (choice ((const (express-break express))
                                         (const (break t))
                                         (const (no-break nil)))))
660
    (kom-server-priority (number))
661
662
663
664
665
666
667
    (kom-server-priority-breaks (choice ((const (express-server-break express))
                                         (const (express-server-letters-break express-letters))
                                         (const (server-break t))
                                         (const (letters-server-break letters))
                                         (const (after-conf-server-break after-conf))
                                         (const (after-conf-letters-server-break after-conf-letters))
                                         (const (when-done-server-break when-done))
David Byers's avatar
David Byers committed
668
                                         (const (no-server-break nil)))))
669
670
671
672
673
    (kom-session-nickname (choice ((const (automatic-session-name nil))
				   (string nil 
					   :tag given-session-name
					   :help-echo select-buffer))))			 

674
675
    (kom-relogin-inhibit-commands (repeat (command nil :tag command)))
    (kom-login-hook (repeat (command nil :tag command)))
David Byers's avatar
David Byers committed
676
677
678
    (kom-do-when-done (repeat (choice ((command nil :tag command)
                                       (kbd-macro nil :tag kbd-macro))
                                      :tag execute
David Byers's avatar
David Byers committed
679
                                      :help-echo select-what-to-execute
680
                                      :format "%[%t%] %v")))
David Byers's avatar
David Byers committed
681
682
683
684
685
    (kom-page-before-command (choice ((const (page-none nil))
                                      (const (page-all t))
                                      (repeat (command nil
                                                       :tag command)
                                              :tag page-some
686
687
                                              :menu-tag page-some
                                              :value (kom-view-next-text)))
688
                                     ))
David Byers's avatar
David Byers committed
689
690
    (kom-permissive-completion (noggle (on off)))
    (kom-membership-default-priority
691
692
     (choice ((const (ask-every-time ask))
              (const (ask-every-time nil))
David Byers's avatar
David Byers committed
693
694
              (number (0 255)
                      :tag fixed-priority 
David Byers's avatar
David Byers committed
695
                      :help-echo select-priority
696
697
                      :format "%[%t%] (%v)"
                      :size 0))))
Pontus Freyhult's avatar
Pontus Freyhult committed
698
699
700
701
    (kom-membership-default-message-flag
     (choice ((const (ask-every-time ask))
              (const (yes t))
              (const (no nil)))))
David Byers's avatar
David Byers committed
702
703
704
    (kom-show-personal-messages-in-buffer
     (choice ((const (messages-in-lyskom-buffer t))
              (const (discard-messages nil))
David Byers's avatar
David Byers committed
705
              (string nil :tag in-named-buffer :help-echo select-buffer))))
David Byers's avatar
David Byers committed
706
707
708
    (kom-pop-personal-messages (choice ((const (yes t))
                                        (const (yes-dont-pop yes))
                                        (const (no nil)))))
709
    (kom-ding-on-new-letter (ding))
David Byers's avatar
David Byers committed
710
711
712
713
714
    (kom-ding-on-priority-break (ding))
    (kom-ding-on-wait-done (ding))
    (kom-ding-on-common-messages (ding))
    (kom-ding-on-group-messages (ding))
    (kom-ding-on-personal-messages (ding))
David Byers's avatar
David Byers committed
715
    (kom-ding-on-no-subject (ding))
David Byers's avatar
David Byers committed
716
717
718
719
    (kom-audio-player (file))
    (kom-default-message-recipient 
     (choice ((const (everybody-rcpt everybody))
              (const (group-rcpt group))
720
721
              (const (sender-rcpt sender))
              (const (last-recipient-recpt last-recipient)))))
David Byers's avatar
David Byers committed
722
    (kom-filter-outgoing-messages (noggle (yes no)))
723
    (kom-highlight-conferences
724
725
     (repeat (cons ((choice ((const (other-persons t))
			     (const (morons kom-morons))
726
727
                             (const (friends kom-friends))
                             (const (me lyskom-pers-no))
728
729
                             (const (i-am-supervisor lyskom-highlight-i-am-supervisor))
                             (const (has-no-presentation lyskom-highlight-has-no-presentation))
730
731
732
733
734
735
			     (const (pers-list-1 kom-person-list-1))
			     (const (pers-list-2 kom-person-list-2))
			     (const (pers-list-3 kom-person-list-3))
			     (const (pers-list-4 kom-person-list-4))
			     (symbol nil :tag other-list)
			     (person nil :tag name :lyskom-predicate (pers))
736
737
                             (repeat (person nil :tag name) 
                                     :indent 12
738
                                     :tag conflist
739
                                     :lyskom-predicate (pers conf)
740
                                     :menu-tag conflist)
741
742
                             )
                            :tag highlight-conferences
743
			    :format "%[%t%] %v\n"
744
                            )
745
746
747
748
749
750
                    (face (kom-active-face
                           kom-active-highlight-face
                           kom-active-strikethrough-face
                           kom-friends-face
                           kom-morons-face
                           kom-me-face) :tag highlight-face))
751
752
753
                   :format "%v"
                   )
             ))
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817

    (kom-presence-messages-in-buffer 
     (choice ((const (always-show-presence t))
	      (const (never-show-presence nil))
	      (symbol nil :tag obsolete-setting)
	      (repeat (cons ((choice ((const (other-persons t))
				      (const (me lyskom-pers-no))
				      (const (morons kom-morons))
				      (const (friends kom-friends))
				      (const (pers-list-1 kom-person-list-1))
				      (const (pers-list-2 kom-person-list-2))
				      (const (pers-list-3 kom-person-list-3))
				      (const (pers-list-4 kom-person-list-4))
				      (symbol nil :tag other-list)
				      (person nil :tag name :lyskom-predicate (pers))
				      (repeat (person nil :tag name) 
					      :indent 12
					      :tag conflist
					      :lyskom-predicate (pers)
					      :menu-tag conflist)
				      )
				     :tag some-persons
				     :format "%[%t%] %v\n"
				     )
			     (toggle (yes no) :tag show-presence))
			    )
		      :tag detailed-setting
		      ))))

    (kom-presence-messages-in-echo-area
     (choice ((const (always-show-presence t))
	      (const (never-show-presence nil))
	      (symbol nil :tag obsolete-setting)
	      (repeat (cons ((choice ((const (other-persons t))
				      (const (me lyskom-pers-no))
				      (const (morons kom-morons))
				      (const (friends kom-friends))
				      (const (pers-list-1 kom-person-list-1))
				      (const (pers-list-2 kom-person-list-2))
				      (const (pers-list-3 kom-person-list-3))
				      (const (pers-list-4 kom-person-list-4))
				      (symbol nil :tag other-list)
				      (person nil :tag name :lyskom-predicate (pers))
				      (repeat (person nil :tag name) 
					      :indent 12
					      :tag conflist
					      :lyskom-predicate (pers)
					      :menu-tag conflist)
				      )
				     :tag some-persons
				     :format "%[%t%] %v\n"
				     )
			     (toggle (yes no) :tag show-presence))
			    )
		      :tag detailed-setting
		      ))))

    (kom-friends (repeat (person nil :tag name)))
    (kom-morons (repeat (person nil :tag name)))
    (kom-person-list-1 (repeat (person nil :tag name)))
    (kom-person-list-2 (repeat (person nil :tag name)))
    (kom-person-list-3 (repeat (person nil :tag name)))
    (kom-person-list-4 (repeat (person nil :tag name)))
    (kom-url-viewer-preferences (repeat (url-viewer nil :tag viewer-program)))
818
    (kom-windows-browser-command (file))
819
820
    (kom-mosaic-command (choice ((file nil :tag ext-simple-command :format "%[%t:%] %v")
                                     (repeat (string nil :tag ext-complex-component :format "%[%t:%] %v")
821
822
                                             :tag ext-complex-command
                                             :menu-tag ext-complex-command))))
823
824
    (kom-netscape-command (choice ((file nil :tag ext-simple-command :format "%[%t:%] %v")
                                     (repeat (string nil :tag ext-complex-component :format "%[%t:%] %v")
825
826
                                             :tag ext-complex-command
                                             :menu-tag ext-complex-command))))
827
828
    (kom-galeon-command (choice ((file nil :tag ext-simple-command :format "%[%t:%] %v")
                                     (repeat (string nil :tag ext-complex-component :format "%[%t:%] %v")
829
830
831
832
833
                                             :tag ext-complex-command
                                             :menu-tag ext-complex-command))))
    (kom-lynx-terminal (choice ((const (lynx-xterm xterm))
                                (const (lynx-emacs terminal)))))
    (kom-lynx-terminal-command (file))
834
835
    (kom-lynx-xterm-command  (choice ((file nil :tag ext-simple-command :format "%[%t:%] %v")
                                     (repeat (string nil :tag ext-complex-component :format "%[%t:%] %v")
836
837
                                             :tag ext-complex-command
                                             :menu-tag ext-complex-command))))
David Byers's avatar
David Byers committed
838
839
840
841
842
843
    (kom-confirm-multiple-recipients
     (choice ((const (dont-check nil))
              (const (check-before-open before))
              (const (check-before-send after)
                     :match (lambda (w v) (and v (not (eq v 'before))))))))
    (kom-check-commented-author-membership (toggle (yes no)))
David Byers's avatar
David Byers committed
844
    (kom-check-for-new-comments (toggle (yes no)))
David Byers's avatar
David Byers committed
845
846
    (kom-inhibit-typeahead (noggle (yes no)))
    (kom-max-buffer-size (choice ((const (no-size-limit nil))
David Byers's avatar
David Byers committed
847
848
849
                                  (number nil 
                                          :tag max-size-in-bytes
                                          :help-echo select-buffer-size))))
David Byers's avatar
David Byers committed
850
851
852

    (kom-ansaphone-record-messages (toggle (yes no)))
    (kom-ansaphone-show-messages (toggle (yes no)))
David Byers's avatar
David Byers committed
853
    (kom-ansaphone-default-reply (string nil :format "%[%t%]\n%v"))
David Byers's avatar
David Byers committed
854
    (kom-remote-control (toggle (on off)))
855
    (kom-remote-controllers (repeat (person nil :tag name)))
David Byers's avatar
David Byers committed
856
    (kom-self-control (toggle (yes no)))
857
    (kom-ispell-dictionary (ispell-dictionary))
858
859
    (kom-show-namedays (choice ((const (off nil))
                                (const (default-namedays t))
860
861
                                (repeat (nameday nil :format "%[%t%]: `%v'" 
						     :tag specific-namedays)
David Byers's avatar
David Byers committed
862
                                        :tag several-name-lists
863
                                        :menu-tag several-name-lists)
864
                                (nameday nil :tag specific-namedays))))
865
866

    (kom-show-week-number (toggle (on off)))
867
868
869
870
871

    (kom-relogin-behaviour (choice ((const (off nil))
				    (const (ask ask))
				    (const (on t)))))

872
873
874
875
876
877
878
879
    (kom-membership-default-placement (choice ((const (last last))
                                               (const (first first))
                                               (number nil
                                                       :tag specific-placement
                                                       ))))
    (kom-show-imported-importer (toggle (on off)))
    (kom-show-imported-envelope-sender (toggle (on off)))
    (kom-show-imported-external-recipients (toggle (on off)))
880
    (kom-show-imported-message-id (toggle (on off)))
881
882
883
    (kom-agree-text (choice ((string nil :tag a-string)
                             (repeat (string nil
                                             :tag a-string
884
                                             :format "%[%t%] `%v'")
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
                                     :tag some-string
                                     :menu-tag some-string))))
    (kom-silent-ansaphone (noggle (on off)))
    (kom-default-session-priority (choice ((const (unspecified nil))
                                           (number nil
                                                   :tag priority))))
    (kom-unsubscribe-makes-passive (toggle (on off)))
    (kom-review-priority (choice ((const (same-as-conf nil))
                                  (number nil :tag fixed-priority))))
    (kom-show-creating-software (toggle (on off)))
    (kom-text-footer-format (choice ((const (default-format nil))
                                     (string nil :tag custom-format))))
    (kom-long-lines (toggle (on off)))
    (kom-postpone-default (number))
    (kom-allow-incompleteness (toggle (on off)))
    (kom-smileys (toggle (on off)))
901
    (kom-ignore-message-senders (repeat (person nil :tag name)))
902
903
    (kom-ignore-message-recipients (repeat (person nil 
                                                   :tag name
904
                                                   :lyskom-predicate (pers conf))))
905
906
907
    (kom-text-header-dash-length (number))
    (kom-text-footer-dash-length (number))
    (kom-show-personal-message-date (toggle (on off)))
908
909
    (kom-mercial (string))
    (kom-w3-simplify-body (toggle (on off)))
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
    (kom-format-html-authors 
     (repeat (cons ((choice ((const (other-persons t))
			     (const (me lyskom-pers-no))
			     (const (morons kom-morons))
			     (const (friends kom-friends))
			     (const (pers-list-1 kom-person-list-1))
			     (const (pers-list-2 kom-person-list-2))
			     (const (pers-list-3 kom-person-list-3))
			     (const (pers-list-4 kom-person-list-4))
			     (symbol nil :tag other-list)
			     (person nil :tag name   
					 :format "%[[*]%] %v"
					 :lyskom-predicate (pers))
			     (repeat (person nil :tag name) 
				     :indent 12
				     :tag conflist
				     :lyskom-predicate (pers)
				     :menu-tag conflist)
			     )
			    :tag some-persons
			    :format "%[%t%] %v\n"
			    )
		    (toggle (yes no) :tag format-html))
		   )
	     :tag detailed-setting
	     ))
936
    (kom-format-show-images (toggle (on off)))
937
938
    (kom-bury-buffers (toggle (on off)))
    (kom-ansaphone-replies (ansaphone))
939
    (kom-complete-numbers-before-names (toggle (on off)))
940
    (kom-keep-alive-interval (number))
Pontus Freyhult's avatar
Pontus Freyhult committed
941
942
943
    (kom-lost-session-notification (choice ((const (off nil))
					    (const (session-lost-all-buffers all-buffers))
					    (const (session-lost-beep beep)))))
944
    (kom-text-no-prompts (repeat (cons ((command nil :tag command :format "%[%t%]: %v\n")
945
946
                                        (toggle (yes no)  :tag prompt-for-text-no :format "%[%t%]: %v")
                                        ))))
947
    (kom-saved-file-name (file))
948
949
    (kom-follow-attachments (toggle (yes no)))
    (kom-show-unread-in-frame-title (toggle (yes no)))
950
951
952
953

    (kom-unread-mode-line-type (choice ((const (simple-unread-mode-line nil))
					(const (explicit-unread-mode-line t)))))

954
    (kom-confirm-add-recipients (toggle (yes no)))
955
    (kom-trim-buffer-minimum (number))
956
    (kom-dont-check-commented-authors (repeat (person nil :tag name)))
957
958
    (kom-print-relative-dates (toggle (yes no)))
    (kom-print-seconds-in-time-strings (toggle (yes no)))
959
960
961
962
963
964
965
966
967
    (kom-extended-status-information (choice ((const (yes t))
                                              (repeat (cons ((choice ((const (extended-conf-info server))
                                                                      (const (extended-pers-info pers))
                                                                      (const (extended-server-info server))
                                                                      (const (extended-read-faq-info read-faq))
                                                                      (const (extended-statistics-info raw-server-stats))
                                                                      (const (extended-all-other-info t))
                                                                      )
                                                                     :tag extended-info-type
968
                                                                     :format "%[%t%] %v\n")
969
970
971
                                                             (toggle (yes no) :tag extended-info-show)))
                                                      :tag specific-extended-info 
                                                      :menu-tag specific-extended-info))))
972
    (kom-edit-hide-add-button (noggle (yes no)))
973
    (kom-keyboard-menu-immediate-selection (noggle (yes no)))
974
    (kom-url-transformation-rules (repeat (cons ((string nil :tag url-transform-regexp :format "%[%t%] %v\n")
David Byers's avatar
David Byers committed
975
                                                 (string nil :tag url-transform-newtext)))))
976
977
978
979
980
981
982
983
    (kom-text-links (repeat (cons ((choice ((person nil :tag link-specific-rcpt :lyskom-predicate (pers conf))
                                            (const (all-conferences t)))
                                           :tag link-pattern-for
                                           :format "%[%t%]: %v")
                                   (repeat (list ((string nil :tag link-pattern :format "%[%t%]: %v\n")
                                                  (string nil :tag link-replace :format "%[%t%]: %v\n")
                                                  (number (0 9) :tag link-highlight-match :format "%[%t%]: %v\n")
                                                  (toggle (yes no) :tag link-fold-case :format "%[%t%]: %v"))
984
985
                                                 ) :indent 12 :tag "")
                                   ))))
986
987
988
    (kom-url-face (face))
    (kom-text-no-face (face))
    (kom-active-face (face))
989
990
    (kom-active-highlight-face (face))
    (kom-active-strikethrough-face (face))
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
    (kom-highlight-face (face))
    (kom-me-face (face))
    (kom-friends-face (face))
    (kom-morons-face (face))
    (kom-subject-face (face))
    (kom-presence-face (face))
    (kom-first-line-face (face))
    (kom-warning-face (face))
    (kom-mark-face (face))
    (kom-dim-face (face))
    (kom-text-body-face (face t))
    (kom-dashed-lines-face (face t))
    (kom-async-text-body-face (face t))
    (kom-async-dashed-lines-face (face t))
1005
    (kom-show-sync-messages (toggle (yes no)))
David Byers's avatar
David Byers committed
1006
1007
1008
    (kom-netscape-variant (choice ((const (default-netscape nil))
                                   (const (new-window-netscape new-window))
                                   (const (new-tab-netscape new-tab)))))
David Byers's avatar
David Byers committed
1009
    (kom-auto-confirm-new-conferences (toggle (yes no)))
David Byers's avatar
David Byers committed
1010
1011
    (kom-text-properties (toggle (yes no)))
    (kom-fontify-text (toggle (yes no)))
David Byers's avatar
David Byers committed
1012
1013
1014
1015
1016
1017
1018
1019
))

(defvar lyskom-widget-functions 
  '((toggle . lyskom-toggle-widget)
    (noggle . lyskom-toggle-widget-inverse)
    (ding   . lyskom-ding-widget)
    (choice . lyskom-choice-widget)
    (string . lyskom-string-widget)
1020
    (symbol . lyskom-symbol-widget)
David Byers's avatar
David Byers committed
1021
1022
1023
    (number . lyskom-number-widget)
    (const .  lyskom-item-widget)
    (repeat . lyskom-repeat-widget)
1024
    (cons . lyskom-cons-widget)
1025
    (list . lyskom-list-widget)
1026
    (face . lyskom-face-widget)
1027
    (nameday . lyskom-nameday-widget)
David Byers's avatar
David Byers committed
1028
1029
    (kbd-macro . lyskom-kbd-macro-widget)
    (url-viewer . lyskom-url-viewer-widget)
1030
    (ispell-dictionary . lyskom-ispell-dictionary-widget)
David Byers's avatar
David Byers committed
1031
1032
1033
    (open-window . lyskom-open-window-widget)
    (command . lyskom-command-widget)
    (person . lyskom-person-widget)
David Byers's avatar
David Byers committed
1034
    (language-choice . lyskom-language-widget)
David Byers's avatar
David Byers committed
1035
    (file . lyskom-file-widget)
1036
    (ext-command . lyskom-external-command-widget)
1037
    (ansaphone . lyskom-ansaphone-reply-widget)
1038
    (mark-association . lyskom-mark-association-widget)
David Byers's avatar
David Byers committed
1039
1040
))

David Byers's avatar
David Byers committed
1041
1042
1043
1044
1045
1046
(defun lyskom-make-menu-tag (str)
  "Make a menu tag from the string STR."
  (if (string-match "\\(.*\\):\\s-*" str)
      (match-string 1 str)
    str))

David Byers's avatar
David Byers committed
1047
1048
1049
(defun lyskom-create-widget (variable)
  (let* ((el (assq variable lyskom-custom-variables))
         (dummy (or el (error "Unknown variable: %S" variable)))
1050
         (spec (lyskom-widget-convert-specification (car (cdr el)) variable))
David Byers's avatar
David Byers committed
1051
1052
         (tag-sym (intern (concat (symbol-name variable) "-tag")))
         (doc-sym (intern (concat (symbol-name variable) "-doc")))
1053
         (help-sym (intern (concat (symbol-name variable) "-help")))
David Byers's avatar
David Byers committed
1054
         (value (save-excursion (set-buffer lyskom-buffer)
David Byers's avatar
David Byers committed
1055
1056
1057
                                (symbol-value variable)))
         (storage-widget nil))

1058
    (lyskom-ignore value help-sym dummy)       ; Are they ever used?
David Byers's avatar
David Byers committed
1059
1060

    (setq storage-widget
1061
1062
1063
1064
1065
1066
1067
1068
1069
	  (prog1
	      (widget-create 'checkbox
			     ':value (and (not (memq variable kom-dont-read-saved-variables))
					  (or (memq variable lyskom-elisp-variables)
					      (lyskom-flag-global-variable-from-elisp variable)))
			     ':args (list variable)
			     ':format "%[%v%]"
			     ':help-echo (lyskom-custom-string 'variable-type-help))
	    (widget-insert " ")))
David Byers's avatar
David Byers committed
1070

David Byers's avatar
David Byers committed
1071
1072
    (setq spec 
          (cons (car spec)
1073
1074
1075
                (append
                 (list ':tag
                       (lyskom-custom-string tag-sym)
David Byers's avatar
David Byers committed
1076
1077
                       ':menu-tag
                       (lyskom-make-menu-tag (lyskom-custom-string tag-sym))
1078
1079
                       ':value
                       (lyskom-custom-get-value variable)
David Byers's avatar
David Byers committed
1080
1081
1082
1083
                       ':help-echo
                       (lyskom-format 
                        (lyskom-custom-string 'default-help-echo)
                        (symbol-name variable))
David Byers's avatar
David Byers committed
1084
                       ':lyskom-storage-widget storage-widget
1085
1086
                       )
                 (cdr spec))))
1087

David Byers's avatar
David Byers committed
1088
    (let ((widget (apply 'widget-create spec)))
David Byers's avatar
David Byers committed
1089
1090
      (condition-case nil
          (progn
1091
            (if (string= "" (lyskom-custom-string doc-sym))
1092
1093
1094
1095
                (progn (widget-insert (lyskom-format " %#1@(%#2s)" 
                                                     `(face ,kom-dim-face)
                                                     (symbol-name variable)))
                       (widget-insert "\n"))
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
              (widget-insert "  ")
              (widget-create 'lyskom-widget-help
                             ':value (lyskom-default-value 'kom-customize-format)
                             ':help-echo
                             (if (eq (lyskom-default-value 'kom-customize-format)
                                     'long)
                                 (lyskom-custom-string 'hide-doc)
                               (lyskom-custom-string 'show-doc))
                             ':args
                             (list (list 'long
                                         "\n%s\n\n"
                                         (lyskom-custom-string doc-sym)
                                         (lyskom-custom-string 'hide-doc)
1109
                                         "-")
1110
1111
1112
1113
1114
                                   (list 'short 
                                         "%s"
                                         ""
                                         (lyskom-custom-string 'show-doc)
                                         "?"))
1115
1116
1117
                             ':format (lyskom-format "%%[[%%T]%%] %[%#1@(%#2s)%]\n%%D"
                                                     `(face ,kom-dim-face)
                                                     (symbol-name variable)))))
David Byers's avatar
David Byers committed
1118
1119
        (error (widget-insert "\n")))
        widget)))
David Byers's avatar
David Byers committed
1120
1121


1122
(defun lyskom-widget-convert-specification (spec var)
David Byers's avatar
David Byers committed
1123
1124
1125
1126
1127
1128
1129
  "Convert a LysKOM widget specification to something widget-create accepts"
  (let ((convertfn (assq (car spec) lyskom-widget-functions)))
    (if (null convertfn)
        (error "Unknown widget type: %S" spec))
    (nconc (funcall (cdr convertfn)
                    (car spec)
                    (car (cdr spec))
1130
1131
                    (cdr (cdr spec))
                    var)
David Byers's avatar
David Byers committed
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
           (lyskom-widget-convert-props spec))))

(defun lyskom-widget-convert-props (spec)
  "Convert widget properties to a format that widget-create likes"
  (let ((propl (nthcdr 2 spec))
        (result))
    (if (/= 0 (% (length propl) 2))
        (error "Widget property list has odd length: %S" spec))
    (while propl
      (setq result (cons (car propl) result))
      (setq propl (cdr propl))
      (setq result
            (cons (cond ((symbolp (car propl))
                         (cond ((eq (car propl) t) t)
                               ((eq (car propl) nil) nil)
                               (t (lyskom-custom-string (car propl)))))
                        ((and (consp (car propl))
                              (eq 'quote (car (car propl))))
                         (car (cdr (car propl))))
                        (t (car propl)))
                  result))
      (setq propl (cdr propl)))
    (nreverse result)))


David Byers's avatar
David Byers committed
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
(defun lyskom-build-simple-widget-spec (type defaults propl)
  (let (new-props)
    (while defaults
      (unless (plist-member propl (car defaults))
        (setq new-props (cons (car defaults)
                              (cons (car (cdr defaults)) new-props))))
      (setq defaults (cdr (cdr defaults))))
    (cons type new-props)))


1167
(defun lyskom-file-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1168
  (lyskom-build-simple-widget-spec 'file
1169
                                   '(:format "%[%t%] %v" :size 0)
David Byers's avatar
David Byers committed
1170
                                   propl))
David Byers's avatar
David Byers committed
1171

1172
(defun lyskom-person-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1173
  (lyskom-build-simple-widget-spec 'lyskom-name nil propl))
David Byers's avatar
David Byers committed
1174

1175
(defun lyskom-mark-association-widget (type &optional args propl ar)
1176
1177
  (lyskom-build-simple-widget-spec 'lyskom-mark-association nil propl))

1178
(defun lyskom-command-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1179
  (lyskom-build-simple-widget-spec 'lyskom-command nil propl))
David Byers's avatar
David Byers committed
1180

1181
(defun lyskom-kbd-macro-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1182
1183
1184
  (lyskom-build-simple-widget-spec 'lyskom-kbd-macro
                                   (list ':macro-buffer lyskom-buffer)
                                   propl))
David Byers's avatar
David Byers committed
1185

1186
(defun lyskom-item-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1187
1188
1189
1190
1191
1192
  (lyskom-build-simple-widget-spec 'item
                                   (list ':format "%t"
                                         ':tag (lyskom-custom-string 
                                                (elt args 0))
                                         ':value (elt args 1))
                                   propl))
David Byers's avatar
David Byers committed
1193

1194
(defun lyskom-language-widget (type &optional args propl var)
David Byers's avatar
David Byers committed
1195
1196
1197
1198
  (lyskom-build-simple-widget-spec
   'menu-choice
   (list ':format "%[%t%] %v"
         ':case-fold t
1199
         ':tag (lyskom-custom-string 'language)
David Byers's avatar
David Byers committed
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
         ':args
         (mapcar
          (function
           (lambda (x)
             (list 'item
                   ':tag (lyskom-language-name (car x))
                   ':format "%t"
                   ':value (elt x 0))))
          lyskom-languages))
   propl))
David Byers's avatar
David Byers committed
1210

1211
(defun lyskom-nameday-widget (type &optional args propl var)
1212
1213
1214
1215