GNU bug report logs -
#13384
gnus-treat-predicate: allow function predicates
Previous Next
Reported by: Geoff Kuenning <geoff <at> cs.hmc.edu>
Date: Tue, 8 Jan 2013 02:33:02 UTC
Severity: normal
Tags: fixed
Found in version 5.13
Fixed in version 24.4
Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Gnus v5.13
GNU Emacs 24.2.1 (x86_64-suse-linux-gnu, GTK+ Version 3.4.4)
of 2012-10-10 on build20
Gnus-treat-predicate is a bit silly, because it limits you predicates
the author thought of. It's easy to extend it to be generalized, which
is what elisp is for in the first place. This version lets any function
be called; it can access things via free variables. See "TWO NEW LINES"
below:
(defun gnus-treat-predicate (val)
(cond
((null val)
nil)
(gnus-treat-condition
(eq gnus-treat-condition val))
((and (listp val)
(stringp (car val)))
(apply 'gnus-or (mapcar `(lambda (s)
(string-match s ,(or gnus-newsgroup-name "")))
val)))
((listp val)
(let ((pred (pop val)))
(cond
((eq pred 'or)
(apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
((eq pred 'and)
(apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
((eq pred 'not)
(not (gnus-treat-predicate (car val))))
((eq pred 'typep)
(equal (car val) gnus-treat-type))
; TWO NEW LINES
((functionp pred)
(funcall pred))
(t
(error "%S is not a valid predicate" pred)))))
((eq val t)
t)
((eq val 'head)
nil)
((eq val 'first)
(eq part-number 1))
((eq val 'last)
(eq part-number total-parts))
((numberp val)
(< gnus-treat-length val))
(t
(error "%S is not a valid value" val))))
--
Geoff Kuenning geoff <at> cs.hmc.edu http://www.cs.hmc.edu/~geoff/
Orchestra retrospectively extremely satisfied with symphony [No. 1] as
result of barrel of free beer.
-- Gustav Mahler, post-premiere letter to Arnold Berliner
This bug report was last modified 11 years and 304 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.