From 769b78df078d0287a10166ce828941a491858ff2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 9 Oct 2009 13:02:10 -0400 Subject: [PATCH] pagespec_match_list allow additional pagespec limit parameters again --- IkiWiki.pm | 12 ++++++++---- doc/plugins/write.mdwn | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 475e278c3..f959d868b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2019,21 +2019,25 @@ sub pagespec_match_list ($$;@) { @candidates=reverse(@candidates) if $params{reverse}; + $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); + + # clear params, remainder is passed to pagespec + my $num=$params{num}; + delete @params{qw{num deptype reverse sort limit}}; + my @matches; my $firstfail; my $count=0; foreach my $p (@candidates) { - my $r=$sub->($p, location => $page); + my $r=$sub->($p, %params, location => $page); if ($r) { push @matches, [$p, $r]; - last if defined $params{num} && ++$count == $params{num}; + last if defined $num && ++$count == $num; } elsif (! defined $firstfail) { $firstfail=$r; } } - - $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); my @ret; if (@matches) { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index f6ea76c36..9661bf4de 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -636,6 +636,9 @@ is significantly more efficient than calling `add_depends` and `pagespec_match` in a loop. You should use this anytime a plugin needs to match a set of pages and do something based on that list. +Unlike pagespec_match, this may throw an error if there is an error in +the pagespec. + Additional named parameters can be specified: * `deptype` optionally specifies the type of dependency to add. Use the @@ -650,8 +653,8 @@ Additional named parameters can be specified: * `list` makes it only match amoung the specified list of pages. Default is to match amoung all pages in the wiki. -Unlike pagespec_match, this may throw an error if there is an error in -the pagespec. +Any other named parameters are passed on to `pagespec_match`, to further +limit the match. #### `add_depends($$;$)` -- 2.44.0