filter.el 24.2 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
;;;;; 
;;;;; LysKOM is free software; you can redistribute it and/or modify it
;;;;; under the terms of the GNU General Public License as published by 
10
;;;;; the Free Software Foundation; either version 2, or (at your option) 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;;;;; 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. 
;;;;;
;;;; ================================================================
;;;; ================================================================
;;;;
29
;;;; File: filter.el
30
31
32
33
;;;;
;;;; Contains the support functions for text filtering.
;;;;

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

38
39
(eval-when-compile
  (require 'lyskom-command "command"))
40

41
42
43
44
45
46
;;;============================================================
;;;
;;; Filter pattern accessors
;;;
;;; Filters are lists with the following structure
;;;
47
;;;   (filter [ PATTERNS ATTRIBUTES FUNCTION])
48
49
;;;
;;; Where PATTERNS is a list of filter patterns and ATTRIBUTES is
50
51
;;; an association list. FUNCTION is a lisp function implementing
;;; the filter.
52
53
54
55
56
57
58
59
60
61
62
;;;
;;; The following attributes are reserved
;;;
;;; action -- What action to take when the pattern matches. Currently
;;;           one of dontshow, skip or skip-comments.
;;; expire -- When the filter expires. Not used.
;;;

(defun make-filter (&optional p a)
  "Creates and returns a filter structure.
Optional P and A initialize pattern and attributes, respectively."
David Byers's avatar
David Byers committed
63
64
65
66
  (lyskom-create-filter p a (lyskom-create-compile-filter-function p)))

(defun lyskom-create-filter (pattern attribute-list function)
  (list 'filter (vector pattern attribute-list function)))
67

David Byers's avatar
David Byers committed
68
69
70
71
72
73
(defun lyskom-recompile-filter (filter)
  "Re-compile the filter FILTER"
  (set-filter->function filter
                        (lyskom-create-compile-filter-function
                         (filter->pattern filter))))

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(defun copy-filter (f)
  "Create a copy of the filter F"
  (make-filter (copy-tree (filter->pattern f))
               (copy-tree (filter->attribute-list f))))

(defun filter-p (f)
  "Returns T if f looks like a filter"
  (and (listp f)
       (eq 'filter (car f))))

(defun filter->pattern (f)
  "Extract the patterns part of a filter F"
  (elt (elt f 1) 0))

(defun filter->attribute-list (f)
  "Extract the attribute list of F."
  (elt (elt f 1) 1))

(defun filter->attribute (f a)
  "From filter F, extract the value of attribute A. 
Returns nil if no such attribute is present."
  (cdr (assq a (filter->attribute-list f))))

(defun set-filter->pattern (f p)
  "Set the patterns part of F to P."
  (aset (elt f 1) 0 p))

(defun set-filter->attribute-list (f l)
  "Set the attribute list of filter F to L"
  (aset (elt f 1) 1 l))

(defun set-filter->attribute (f a v)
  "Set the value in filter F of attribute A to V."
  (let ((x (assq a (filter->attribute-list f))))
    (if x
        (setcdr x v)
      (set-filter->attribute-list f
       (cons (cons a v) (filter->attribute-list f))))))

113
114
115
116
117
118
119
120
121
(defun filter->function (f)
  "Get the function for filter F"
  (elt (elt f 1) 2))

(defun set-filter->function (f fn)
  "Set the function for filter F to FN"
  (aset (elt f 1) 2 fn))


122
123
124
125
126
;;;============================================================
;;;
;;;


127
128
129
(defvar lyskom-filter-hack nil
  "Variable to busy-wait on to get the filter action. Set to
invalid-value until a filter action has been selected.")
130
131
132
133
134
135
136
137
138
139
140

(defun lyskom-filter-text-p (text-no)
  (if (null lyskom-filter-list)
      nil
    (progn
      (setq lyskom-filter-hack 'invalid-value)
      (initiate-get-text-stat 'filter 'lyskom-filter-text-p-2 text-no)
      ;;
      ;; Block until done
      ;;
      (while (eq lyskom-filter-hack 'invalid-value)
David Byers's avatar
David Byers committed
141
        (lyskom-accept-process-output))
142
      lyskom-filter-hack)))
143
144
145
    
(defun lyskom-filter-text-p-2 (text-stat)
  (if (null text-stat)
David Byers's avatar
David Byers committed
146
      (setq lyskom-filter-hack nil)
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    (progn
      ;;
      ;; Collect information from the server
      ;;
      (lyskom-collect 'filter)
      
      ;;
      ;; Get the conf-stat of the author of the text
      ;; Get the text body
      ;;
      
      (initiate-get-conf-stat 'filter nil (text-stat->author text-stat))
      (initiate-get-text 'filter nil (text-stat->text-no text-stat))
      
      ;;
      ;; Get the conf-stat of the recipients
      ;;
      
      (lyskom-traverse
          misc
          (text-stat->misc-info-list text-stat)
        (let ((type (misc-info->type misc)))
169
          (if (memq type lyskom-recpt-types-list)
170
171
172
173
174
175
176
177
178
179
180
              (initiate-get-conf-stat 'filter 
                                      nil
                                      (misc-info->recipient-no misc)))))
      
      ;;
      ;; Use the results
      ;;
      
      (lyskom-use 'filter 'lyskom-filter-text-p-3 text-stat))))
    
(defun lyskom-filter-text-p-3 (author text &rest data)
181
182
  (if (or (null text)
	  (null author))
183
      (setq lyskom-filter-hack nil)
184
    (let (subject text-stat)
185
186
      
      ;;
187
188
      ;; Extract the text-stat which is the last element of data
      ;; Next shorten the list in data to exclude the text-stat.
189
190
191
192
193
194
195
      ;;
      
      (setq text-stat (elt data (- (length data) 1)))
      (if (= (length data) 1)
	  (setq data nil)
	(rplacd (nthcdr (- (length data) 2) data) nil))
      
196
197
198
199
200
201
202
203
204
      ;;
      ;; Extract the subject
      ;;
      
      (let ((str (text->decoded-text-mass text text-stat)))
        (cond ((string-match "\n" str)
               (setq subject (substring str 0 (match-beginning 0))))
              (t (setq subject ""))))
      
205
206
207
208
209
210
211
212
213
      ;;
      ;; Do the checking
      ;;
      
      (setq lyskom-filter-hack
	    (lyskom-check-filter-list text-stat
				      author
				      data
				      subject
214
                                      (text->decoded-text-mass text text-stat)
215
				      lyskom-filter-list)))))
216
217
218
219
220
221
222
223
224

(defun lyskom-check-filter-list (text-stat
                                 author
                                 recipient-list
                                 subject
                                 text
                                 filter-list)
  (let (tmp)
    (while filter-list
225
      (condition-case nil
226
227
228
229
230
231
232
233
234
235
236
237
          (if (functionp (filter->function (car filter-list)))
              (setq tmp (funcall (filter->function (car filter-list))
                                 (car filter-list)
                                 author
                                 recipient-list
                                 subject
                                 text-stat
                                 text)))
        (error nil))
      (if tmp
          (setq filter-list nil)
        (setq filter-list (cdr filter-list))))
238
239
    tmp))

240
241


242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259

;;;========================================
;;;  The filter compiler.
;;;


(defmacro lyskom-filter-is-member (testfn arg list selector)
  (` (let (found
           (objlist (, list)))
       (while (and objlist (not found))
         (and ((, testfn) (, arg) ((, selector) (car objlist)))
           (setq found t))
      (setq objlist (cdr objlist)))
    found)))


(defun lyskom-create-compile-filter-function (pattern)
  (if (null pattern)
260
261
      (byte-compile 
       '(lambda (filter author recipient-list subject text-stat text) nil))
David Byers's avatar
David Byers committed
262
    (byte-compile (lyskom-create-filter-function pattern))))
263
264
265
266
267
268
269


(defun lyskom-create-filter-function (pattern)
  (` (lambda (filter author recipient-list subject text-stat text)
       (, (cons 'and (lyskom-create-filter-function-body pattern))))))

(defun lyskom-create-filter-function-body (pattern)
270
  (let (inverse)
271
    (cond
272
273
     ;;
     ;; End of pattern
274
275
276
     ;; 
     
     ((null pattern) '((filter->attribute filter 'action)))
277
278
279
280

     ;;
     ;; Bad pattern
     ;;
281
282
283
284
285
286
287
     
     ((or (not (listp pattern))
          (not (listp (car pattern)))) 
      (lyskom-error 
       "%s"
       (lyskom-get-string 'filter-error-specification)))
     
288
289
290
     ;;
     ;; Assume valid pattern
     ;;
291
292
293
294
295
     
     (t
      (let ((key (car (car pattern)))
            (args (cdr (car pattern)))
            (form nil))
296
297
        (if (eq key 'not)
            (if (not (listp args))
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                (lyskom-error "%s" (lyskom-get-string 'filter-error-bad-not))
              (setq key (car args) args (cdr args) inverse t)))

        (setq form
              (cond 
               ((eq key 'author)
                (lyskom-filter-check-args 'stringp args)
                (` (string-match (, (regexp-quote args))
                                 (conf-stat->name author))))

               ((eq key 'author-re)
                (lyskom-filter-check-args 'regexpp args)
                (` (string-match (, args)
                                 (conf-stat->name author))))

               ((eq key 'author-no)
                (lyskom-filter-check-args 'integerp args)
                (` (= (, args) (conf-stat->conf-no author))))

               ((eq key 'recipient)
                (lyskom-filter-check-args 'stringp args)
                (` (lyskom-filter-is-member
                    string-match
                    (, (regexp-quote args))
                    recipient-list
                    conf-stat->name)))
               ((eq key 'recipient-re)
                (lyskom-filter-check-args 'regexpp args)
                (` (lyskom-filter-is-member
                    string-match
                    (,  args)
                    recipient-list
                    conf-stat->name)))
               ((eq key 'recipient-no)
                (lyskom-filter-check-args 'integerp args)
                (` (lyskom-filter-is-member
                    =
                    (,  args)
                    recipient-list
                    conf-stat->conf-no)))

               ((eq key 'subject)
                (lyskom-filter-check-args 'stringp args)
                (` (string-match (, (regexp-quote args))
                                 subject)))
               ((eq key 'subject-re)
                (lyskom-filter-check-args 'regexpp args)
                (` (string-match (, args)
                                 subject)))

               ((eq key 'text)
                (lyskom-filter-check-args 'stringp args)
                (` (string-match (, (regexp-quote args))
                                 text)))
               ((eq key 'text-re)
                (lyskom-filter-check-args 'regexpp args)
                (` (string-match (, args)
                                 text)))
               (t (lyskom-error 
                   (lyskom-get-string 'filter-error-unknown-key)
                   key
                   ))))
        
        (if inverse (setq form (list 'not form)))
        (cons form (lyskom-create-filter-function-body (cdr pattern))))))))

      
365

366
367
368
369
370
371
372
373
(defun lyskom-filter-check-args (fn arg)
  (if (not (funcall fn arg))
      (lyskom-error (lyskom-get-string 'filter-error-key-arg)
                    fn arg)))




374
375
376
377
;;; ============================================================
;;; lyskom-filter-prompt
;;;
;;; Print a notice that a text has been filtered. 
378
;;;
379
380
381

(defun lyskom-filter-prompt (text-no prompt)
  (setq lyskom-filter-hack t)
382
383
384
385
  (let ((text-stat (blocking-do 'get-text-stat text-no))
	(subject nil))
    (if text-stat
	(blocking-do-multiple 
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
            ((text (get-text text-no))
             (conf-stat (get-conf-stat 
                         (text-stat->author text-stat))))
          (if text
              (let ((str (text->decoded-text-mass text text-stat)))
                (setq subject
                      (if (string-match "\n" str)
                          (substring str 0 (match-beginning 0))
                        str))
                (lyskom-format-insert prompt
                                      text-stat
                                      subject
                                      (or conf-stat
                                          (text-stat->author text-stat)))
                (lyskom-scroll))))))
401
402
  (setq lyskom-filter-hack nil))

403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428


;;;========================================
;;; User functions and support functions
;;;

(defun lyskom-add-filter (filter)
  "Add the filter FILTER to the LysKOM filtering mechanism."
  (if (filter->attribute filter 'expire)
      (setq kom-session-filter-list (cons filter
                                          kom-session-filter-list))
    (progn
      (setq kom-permanent-filter-list (cons filter kom-permanent-filter-list))
      (lyskom-save-options (current-buffer)
                           (lyskom-get-string 'filter-edit-saving)
                           (lyskom-get-string 'filter-edit-saving-done)
                           (lyskom-get-string 'filter-edit-saving-error))))
  (setq lyskom-filter-list
        (cons filter lyskom-filter-list)))


(defun lyskom-filter-read-action ()
  "Read a filter action from the minibuffer, returning its symbol"
  (let ((completion-ignore-case t))
    (car
     (rassoc
David Byers's avatar
David Byers committed
429
430
431
432
433
434
435
436
      (lyskom-completing-read (lyskom-get-string 'filter-action)
                              (lyskom-maybe-frob-completion-table
                               (lyskom-reverse-pairs 
                                lyskom-filter-actions))
                              nil
                              nil
                              (cdr (car lyskom-filter-actions))
                              t)
Niels Möller's avatar
Niels Möller committed
437
      lyskom-filter-actions))))
438
439
440
441
442
443
444
445
446
447
448
449
450


(defun lyskom-filter-read-permanent ()
  "Ask the user is a filter is permanent and return t in this case.
Otherwise return nil."
  (lyskom-j-or-n-p (lyskom-get-string 'filter-permanent)))



;;;========================================
;;; Filtrera ärende --- Filter subject
;;; 

451
(def-kom-command kom-filter-subject (&optional subject)
452
453
454
455
456
457
  "Interactively filter a subject. This creates a permanent or temporary
filter for a single subject in one conference or all conferences.

An alternative to this is `kom-super-jump'.

To change existing filters, use `kom-filter-edit'."
458
  (interactive)
459
  (if (/= 0 lyskom-current-conf)
460
461
462
	  (let ((conf-stat (blocking-do 'get-conf-stat lyskom-current-conf)))
	    (let (conf perm filter action)
	      (if (null subject)
463
              (setq subject lyskom-current-subject))
464
	      (setq subject 
465
466
467
                (lyskom-read-from-minibuffer 
		 (lyskom-get-string 'filter-subject)
		 subject))
468
469
	      (setq filter (cons (cons 'subject subject) filter))
	      (setq conf (lyskom-read-conf-no
470
                      (lyskom-get-string 'filter-in-conf)
471
                      '(all)
472
473
                      t
                      (or (and (conf-stat->conf-no conf-stat)
474
                               (cons (conf-stat->name conf-stat) 0))
475
476
                          "")
                      t))
477
	      (if (/= conf 0)
478
              (setq filter (cons (cons 'recipient-no conf) filter)))
479
480
481
482
483
	      (setq action (lyskom-filter-read-action))
	      (setq perm (lyskom-filter-read-permanent))
	      
	      (lyskom-add-filter
	       (make-filter filter
484
485
                        (list (cons 'action action)
                              (cons 'expire (not perm)))))))))
486
487
488
489
490
491
492
  

     
;;;========================================
;;; Filtrera författare --- Filter author
;;;

493
494

(def-kom-command kom-filter-author ()
495
496
497
498
499
  "Interactively filter an author. This creates a permanent or
temporary filter on a single author in one conference or all
conferences.

To change existing filters, use `kom-filter-edit'."
500
  (interactive)
501
  (let (auth-stat author conf filter action permanent)
502
	(blocking-do-multiple ((text-stat (get-text-stat 
503
504
505
506
507
508
509
510
                                       (or lyskom-current-text 0)))
                           (conf-stat (get-conf-stat
                                       lyskom-current-conf)))
      (if text-stat
          (setq auth-stat (blocking-do 'get-conf-stat
                                       (text-stat->author text-stat))))
      (setq author 
            (lyskom-read-conf-no (lyskom-get-string 'filter-author)
511
                                 '(pers)
512
513
                                 t
                                 (or (and auth-stat
514
                                          (cons (conf-stat->name auth-stat) 0))
515
516
517
518
519
520
                                     "")
                                 t))
      (if (/= author 0)
          (setq filter (cons (cons 'author-no author) filter)))
      (setq conf (lyskom-read-conf-no
                  (lyskom-get-string 'filter-in-conf)
521
                  '(all)
522
523
524
                  t
                  (or 
                   (and conf-stat
525
                        (cons (conf-stat->name conf-stat) 0))
526
527
528
529
530
531
532
533
534
535
                   "")
                  t))
      (if (/= conf 0)
          (setq filter (cons (cons 'recipient-no conf) filter)))
      (setq action (lyskom-filter-read-action))
      (setq permanent (lyskom-filter-read-permanent))
      (lyskom-add-filter
       (make-filter filter
                    (list (cons 'action action)
                          (cons 'expire (not permanent))))))))
536

David Byers's avatar
David Byers committed
537
(def-kom-command kom-filter-recipient ()
538
539
540
541
  "Interactively filter a recipient. This creates a permanent or
temporary filter on a particular recipient.

To change existing filters, use `kom-filter-edit'."
David Byers's avatar
David Byers committed
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
  (interactive)
  (let ((conf-no (lyskom-read-conf-no 'filter-recipient
                                      '(all)
                                      nil
                                      nil
                                      t))
        (action (lyskom-filter-read-action))
        (permanent (lyskom-filter-read-permanent)))
    (cond ((and conf-no (not (zerop conf-no)))
           (lyskom-add-filter
            (make-filter (list (cons 'recipient-no conf-no))
                         (list (cons 'action action)
                               (cons 'expire (not permanent)))))
           ))))

557
558
559
560
561
562
563
564



;;;============================================================
;;;
;;; Superhoppa
;;;

565
566
567
568
569
570
571
572
573
574
(def-kom-command kom-super-jump (text-no)
  "Skip all texts and comments that share the subject and recipient of
the selected text. This creates a temporary filter on the subject of
the selected text in one of its recipients. The recipient is selected
automatically: if the current conference is a recipient, then filter
in that conference. Otherwise filter in the first recipient that the
user is a member of.

To change existing filters, use `kom-filter-edit'.

575
This command accepts text number prefix arguments \(see
576
`lyskom-read-text-no-prefix-arg')."
577
  (interactive (list (lyskom-read-text-no-prefix-arg 'super-jump-q)))
578
579
580
581
  (if (or (null lyskom-current-text)
          (zerop lyskom-current-text))
      (lyskom-insert-string 'have-to-read)
    (let ((text-stat (blocking-do 'get-text-stat lyskom-current-text))
582
583
584
585
586
587
588
          (all-recipients nil)
          (recipients-member nil)
          (cc-recipients-member nil)
          (bcc-recipients-member nil)
          (recipients-nonmember nil)
          (cc-recipients-nonmember nil)
          (bcc-recipients-nonmember nil)
David Byers's avatar
David Byers committed
589
          (filter-recipient nil))
590
591

      ;; Extract recipients into different lists
592
      (lyskom-traverse misc
David Byers's avatar
David Byers committed
593
                       (text-stat->misc-info-list text-stat)
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
        (when (memq (misc-info->type misc) lyskom-recpt-types-list)
          (let* ((conf-no (misc-info->recipient-no misc))
                 (symbol
                  (if (lyskom-get-membership conf-no)
                      (cond ((eq (misc-info->type misc) 'RECPT)
                             'recipients-member)
                            ((eq (misc-info->type misc) 'CC-RECPT)
                             'cc-recipients-member)
                            ((eq (misc-info->type misc) 'BCC-RECPT)
                             'bcc-recipients-member))
                    (cond ((eq (misc-info->type misc) 'RECPT)
                           'recipients-nonmember)
                          ((eq (misc-info->type misc) 'CC-RECPT)
                           'cc-recipients-nonmember)
                          ((eq (misc-info->type misc) 'BCC-RECPT)
                           'bcc-recipients-nonmember)))))
            (set symbol (cons conf-no (symbol-value symbol)))
            (setq all-recipients (cons conf-no all-recipients)))))

      ;; Get the recipient to filter in
      (setq filter-recipient 
            (or (and (memq lyskom-current-conf all-recipients) lyskom-current-conf)
                (car (nreverse recipients-member))
                (car (nreverse cc-recipients-member))
                (car (nreverse bcc-recipients-member))
                (car (nreverse recipients-nonmember))
                (car (nreverse cc-recipients-nonmember))
                (car (nreverse bcc-recipients-nonmember))))
622
623
624

      (if (null filter-recipient)
          (lyskom-insert-string 'no-recipient)
625

David Byers's avatar
David Byers committed
626
        (let ((text lyskom-current-subject))
David Byers's avatar
David Byers committed
627
          (when (string-match "^\\s-*$" lyskom-current-subject) (setq text ""))
David Byers's avatar
David Byers committed
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643

          (lyskom-add-filter
           (make-filter (list 
                         (cons 'subject-re 
                               (concat (if (string-equal text "") "^" "")
                                       "\\([rR][eE]: *\\|[Ff][Ww][Dd]: *\\)*"
                                       (replace-in-string
                                        (regexp-quote text)
                                        "[ \t]+" "[ \t]+")
                                       (if (string-equal text "") "$" "")))
                         (cons 'recipient-no filter-recipient))
                        (list (cons 'action 'skip-tree)
                              (cons 'expire t))))
          (lyskom-format-insert 'super-jump
                                (copy-sequence lyskom-current-subject)
                                filter-recipient))))))
644
645
646
647
648
649
650
651
652




;;;============================================================
;;;
;;; Filtrera text
;;;

653
(def-kom-command kom-filter-text (&optional text)
654
655
656
657
658
  "Interactively filter on text contents. This creates a permanent or
temporary filter on the contents of texts in all conferences or in a
single conference.

To change existing filters, use `kom-filter-edit'."
659
  (interactive)
660
  (if (/= 0 lyskom-current-conf)
661
	  (let ((conf-stat (blocking-do 'get-conf-stat lyskom-current-conf))
662
663
664
665
            (conf nil)
            (action nil)
            (perm nil)
            (filter nil))
666
	    (if conf-stat
667
668
            (progn
              (setq text 
669
670
671
                    (lyskom-read-from-minibuffer (lyskom-get-string 
						  'filter-which-text)
						 (or text "")))
672
673
674
              (setq filter (cons (cons 'text text) filter))
              (setq conf (lyskom-read-conf-no
                          (lyskom-get-string 'filter-in-conf)
675
                          '(all) t
676
                          (or (and (conf-stat->conf-no conf-stat)
677
                                   (cons (conf-stat->name conf-stat) 0))
678
679
680
681
682
683
684
685
686
687
                              "")
                          t))
              (if (/= conf 0)
                  (setq filter (cons (cons 'recipient-no conf) filter)))
              (setq action (lyskom-filter-read-action))
              (setq perm (lyskom-filter-read-permanent))
              (lyskom-add-filter
               (make-filter filter
                            (list (cons 'action action)
                                  (cons 'expire (not perm))))))))))
688
689
690
691
692
693
694
695
696


;;;============================================================
;;; Lista filter                         (kom-list-filters)
;;;
;;; Author: David Byers
;;; Calls internal functions in filter-edit mode. This may or
;;; may not be a good idea, but it works...

697
(def-kom-command kom-list-filters ()
698
699
700
  "Display all filters. This lists all filters in the LysKOM buffer.

To change existing filters, use `kom-filter-edit'."
701
  (interactive)
702
  (let ((filters lyskom-filter-list))
703
704
705
706
707
708
    (goto-char (point-max))
    (if (null filters)
        (lyskom-insert (lyskom-get-string 'no-filters))
      (progn
        (lyskom-insert (lyskom-get-string 'view-filters-header))
        (while filters
709
          (goto-char (point-max))
710
711
712
          (lyskom-format-filter-pattern (car filters))
          (setq filters (cdr filters)))
        (lyskom-insert (lyskom-get-string 'view-filters-footer))))))
713