summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--match.c12
-rw-r--r--txr.115
3 files changed, 21 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 353e258a..0f35be54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-11-19 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (v_deffilter): Even better. Just evaluate
+ the arguments individually. Now @(deffilter a b ..)
+ is possible where these evaluate to suitable
+ lists of strings.
+
+ * txr.1: Documented.
+
+2011-11-19 Kaz Kylheku <kaz@kylheku.com>
+
deffilter grows in power: it can take quasistrings.
* lib.c (cdr_f): New global variable.
diff --git a/match.c b/match.c
index 2b78cc8e..bb3da027 100644
--- a/match.c
+++ b/match.c
@@ -2899,18 +2899,8 @@ static val v_deffilter(match_files_ctx *c)
sem_error(specline, lit("deffilter: ~a is not a symbol"),
first(first_spec), nao);
- if (!all_satisfy(table, func_n1(listp), nil))
- sem_error(specline,
- lit("deffilter arguments must be lists"),
- nao);
-
{
- val table_evaled = mapcar(curry_12_2(func_n2(mapcar),
- chain(curry_123_2(func_n3(eval_form),
- specline, c->bindings),
- cdr_f,
- nao)),
- table);
+ val table_evaled = cdr(eval_form(specline, table, c->bindings));
if (!all_satisfy(table_evaled, andf(func_n1(listp),
chain(func_n1(length),
diff --git a/txr.1 b/txr.1
index cd30c208..f108639d 100644
--- a/txr.1
+++ b/txr.1
@@ -3564,10 +3564,10 @@ This directive's syntax is illustrated in this example:
The deffilter symbol must be followed by the name of the filter to be defined,
-followed by tuples of forms which evaluate to strings. Each tuple specifies one
-or more texts which are mapped to a replacement text. For instance, the
-following specifies a telephone keypad mapping from upper case letters to
-digits. Quasiliterals may be used.
+followed by forms which evaluate to lists of strings. Each list must
+be at least two elements long and specifies one or more texts which are mapped
+to a replacement text. For instance, the following specifies a telephone keypad
+mapping from upper case letters to digits.
@(deffilter alpha_to_phone ("E" "0")
("J" "N" "Q" "1")
@@ -3582,6 +3582,13 @@ digits. Quasiliterals may be used.
@(deffilter foo (`@a` `@b`) ("c" `->@d`))
+ @(bind x ("from" "to"))
+ @(bind y ("---" "+++"))
+ @(deffilter sub x y)
+
+The last deffilter above equivalent to
+@(deffilter sub ("from" "to") ("---" "+++")).
+
Filtering works using a longest match algorithm. The input is scanned from left
to right, and the longest piece of text is identified at every character
position which matches a string on the left hand side, and that text is