| 1 | package App::ListOrgHeadlines; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Log::ger; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use App::OrgUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | our $DATE = '2026-07-22'; # DATE | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | our $DIST = 'App-OrgUtils'; # DIST | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = '0.489'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our @EXPORT_OK = qw(list_org_headlines); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | our %SPEC; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | my $today; | |||||||||||||||||||||||||||||||||||||||||
| 25 | my $yest; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub _process_hl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_hl: not called CC=62 SCAR=82.7
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($file, $hl, $args, $res, $is_raw) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return if $args->{from_level} && $hl->level < $args->{from_level}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"from_level"} and $hl->level < $args->{"from_level"}
MC/DC0%0/2
$args->{"from_level"} and $hl->level < $args->{"from_level"}
$args->{"from_level"}
$hl->level < $args->{"from_level"}
Truth table0%0/3
A and B
A= $args->{"from_level"}B= $hl->level < $args->{"from_level"}
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return if $args->{to_level} && $hl->level > $args->{to_level}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"to_level"} and $hl->level > $args->{"to_level"}
MC/DC0%0/2
$args->{"to_level"} and $hl->level > $args->{"to_level"}
$args->{"to_level"}
$hl->level > $args->{"to_level"}
Truth table0%0/3
A and B
A= $args->{"to_level"}B= $hl->level > $args->{"to_level"}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if (defined $args->{todo}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return if $args->{todo} xor $hl->is_todo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$args->{"todo"} xor $hl->is_todo
MC/DC0%0/2
$args->{"todo"} xor $hl->is_todo
$args->{"todo"}
$hl->is_todo
Truth table0%0/4
A xor B
A= $args->{"todo"}B= $hl->is_todo
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if (defined $args->{done}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return if $args->{done} xor $hl->is_done; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$args->{"done"} xor $hl->is_done
MC/DC0%0/2
$args->{"done"} xor $hl->is_done
$args->{"done"}
$hl->is_done
Truth table0%0/4
A xor B
A= $args->{"done"}B= $hl->is_done
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (defined $args->{state}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | return unless $hl->is_todo && | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $hl->todo_state eq $args->{state}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hl->is_todo and $hl->todo_state eq $args->{"state"}
MC/DC0%0/2
$hl->is_todo and $hl->todo_state eq $args->{"state"}
$hl->is_todo
$hl->todo_state eq $args->{"state"}
Truth table0%0/3
A and B
A= $hl->is_todoB= $hl->todo_state eq $args->{"state"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($args->{has_tags} || $args->{lacks_tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"has_tags"} or $args->{"lacks_tags"}
MC/DC0%0/2
$args->{"has_tags"} or $args->{"lacks_tags"}
$args->{"has_tags"}
$args->{"lacks_tags"}
Truth table0%0/3
A or B
A= $args->{"has_tags"}B= $args->{"lacks_tags"}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $tags = [$hl->get_tags]; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($args->{has_tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | for my $tag (@{ $args->{has_tags} }) { | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return unless grep { $_ eq $tag } @$tags; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($args->{lacks_tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | for my $tag (@{ $args->{lacks_tags} }) { | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return if grep { $_ eq $tag } @$tags; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if (defined $args->{priority}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $p = $hl->todo_priority; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return unless defined($p) && $args->{priority} eq $p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $p and $args->{"priority"} eq $p
MC/DC0%0/2
defined $p and $args->{"priority"} eq $p
defined $p
$args->{"priority"} eq $p
Truth table0%0/3
A and B
A= defined $pB= $args->{"priority"} eq $p
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if (defined $args->{minimum_priority}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $p = $hl->todo_priority; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (defined $p) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | my $cmp = $hl->document->cmp_priorities( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $p, $args->{minimum_priority}); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return if defined($cmp) && $cmp > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmp and $cmp > 0
MC/DC0%0/2
defined $cmp and $cmp > 0
defined $cmp
$cmp > 0
Truth table0%0/3
A and B
A= defined $cmpB= $cmp > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return if !defined($cmp) && !$args->{with_unknown_priority}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmp or $args->{"with_unknown_priority"}
MC/DC0%0/2
defined $cmp or $args->{"with_unknown_priority"}
defined $cmp
$args->{"with_unknown_priority"}
Truth table0%0/3
A or B
A= defined $cmpB= $args->{"with_unknown_priority"}
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return unless $args->{with_unknown_priority}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (defined $args->{maximum_priority}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $p = $hl->todo_priority; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if (defined $p) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | my $cmp = $hl->document->cmp_priorities( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $p, $args->{maximum_priority}); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return if defined($cmp) && $cmp < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmp and $cmp < 0
MC/DC0%0/2
defined $cmp and $cmp < 0
defined $cmp
$cmp < 0
Truth table0%0/3
A and B
A= defined $cmpB= $cmp < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return if !defined($cmp) && !$args->{with_unknown_priority}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmp or $args->{"with_unknown_priority"}
MC/DC0%0/2
defined $cmp or $args->{"with_unknown_priority"}
defined $cmp
$args->{"with_unknown_priority"}
Truth table0%0/3
A or B
A= defined $cmpB= $args->{"with_unknown_priority"}
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return unless $args->{with_unknown_priority}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $ats = $hl->get_active_timestamp; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $days; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $days = ($ats->datetime < $today ? -1:1) * $ats->datetime->delta_days($today)->in_units('days') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | if $ats; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (exists $args->{due_in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return unless $ats; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $met; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (defined $args->{due_in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $met = $days <= $args->{due_in}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if (!$met && $ats->_warning_period) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $met and $ats->_warning_period
MC/DC0%0/2
not $met and $ats->_warning_period
not $met
$ats->_warning_period
Truth table0%0/3
not(A) and B
A= not $metB= $ats->_warning_period
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | # try the warning period | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $dt = $ats->datetime->clone; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $wp = $ats->_warning_period; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $wp =~ s/(\w)$//; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $unit = $1; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $wp = abs($wp); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($unit eq 'd') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $dt->subtract(days => $wp); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } elsif ($unit eq 'w') { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $dt->subtract(weeks => $wp); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } elsif ($unit eq 'm') { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $dt->subtract(months => $wp); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } elsif ($unit eq 'y') { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $dt->subtract(years => $wp); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | die "Can't understand unit '$unit' in timestamp's ". | |||||||||||||||||||||||||||||||||||||||||
| 111 | "warning period: " . $ats->as_string; | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $met++ if DateTime->compare($dt, $today) <= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if (!$met && !$ats->_warning_period && !defined($args->{due_in})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$met or $ats->_warning_period or defined $args->{"due_in"}
$met or $ats->_warning_period
MC/DC0%0/3
$met or $ats->_warning_period or defined $args->{"due_in"}
$met
$ats->_warning_period
defined $args->{"due_in"}
Truth table0%0/4
A or B or C
A= $metB= $ats->_warning_periodC= defined $args->{"due_in"}
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | # try the default 14 days | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $met = $days <= 14; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return unless $met; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||
| 123 | my $date; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($args->{detail}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $r = {}; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $r->{file} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $r->{title} = $hl->title->as_string; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $r->{due_date} = $ats ? $ats->datetime : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $r->{priority} = $hl->todo_priority; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $r->{tags} = [$hl->get_tags]; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $r->{is_todo} = $hl->is_todo; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $r->{is_done} = $hl->is_done; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $r->{todo_state} = $hl->todo_state; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $r->{progress} = $hl->progress; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $r->{level} = $hl->level; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $date = $r->{due_date}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($is_raw) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | chomp($r = $hl->header_as_string); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } elsif ($ats) { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $pl = abs($days) > 1 ? "s" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $r = sprintf("%s (%s): %s (%s)", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | $days == 0 ? "today" : | ||||||||||||||||||||||||||||||||||||||||||
| 144 | $days < 0 ? abs($days)." day$pl ago" : | ||||||||||||||||||||||||||||||||||||||||||
| 145 | "in $days day$pl", | ||||||||||||||||||||||||||||||||||||||||||
| 146 | $ats->datetime->strftime("%a"), | ||||||||||||||||||||||||||||||||||||||||||
| 147 | $hl->title->as_string, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | $ats->datetime->ymd); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $date = $ats->datetime; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | chomp($r = $hl->title->as_string); | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | push @$res, [$r, $date, $hl]; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | $SPEC{list_org_headlines} = { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | v => 1.1, | |||||||||||||||||||||||||||||||||||||||||
| 159 | summary => 'List all headlines in all Org files', | ||||||||||||||||||||||||||||||||||||||||||
| 160 | args => { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | %App::OrgUtils::common_args1, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | todo => { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | schema => ['bool'], | ||||||||||||||||||||||||||||||||||||||||||
| 164 | summary => 'Only show headlines that are todos', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 166 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | done => { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | schema => ['bool'], | ||||||||||||||||||||||||||||||||||||||||||
| 169 | summary => 'Only show todo items that are done', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 171 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | due_in => { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | schema => ['int'], | ||||||||||||||||||||||||||||||||||||||||||
| 174 | summary => 'Only show todo items that are (nearing|passed) due', | ||||||||||||||||||||||||||||||||||||||||||
| 175 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | If value is not set, then will use todo item's warning period (or, if todo item | ||||||||||||||||||||||||||||||||||||||||||
| 178 | does not have due date or warning period in its due date, will use the default | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 14 days). | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | If value is set to something smaller than the warning period, the todo item will | ||||||||||||||||||||||||||||||||||||||||||
| 182 | still be considered nearing due when the warning period is passed. For example, | ||||||||||||||||||||||||||||||||||||||||||
| 183 | if today is 2011-06-30 and due_in is set to 7, then todo item with due date | ||||||||||||||||||||||||||||||||||||||||||
| 184 | <2011-07-10 > won't pass the filter (it's still 10 days in the future, larger | ||||||||||||||||||||||||||||||||||||||||||
| 185 | than 7) but <2011-07-10 Sun +1y -14d> will (warning period 14 days is already | ||||||||||||||||||||||||||||||||||||||||||
| 186 | passed by that time). | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 189 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 190 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | from_level => { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | schema => [int => {default=>1, min=>1}], | ||||||||||||||||||||||||||||||||||||||||||
| 193 | summary => 'Only show headlines having this level as the minimum', | ||||||||||||||||||||||||||||||||||||||||||
| 194 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 195 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | to_level => { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | schema => ['int' => {min=>1}], | ||||||||||||||||||||||||||||||||||||||||||
| 198 | summary => 'Only show headlines having this level as the maximum', | ||||||||||||||||||||||||||||||||||||||||||
| 199 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 200 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | state => { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | schema => ['str'], | ||||||||||||||||||||||||||||||||||||||||||
| 203 | summary => 'Only show todo items that have this state', | ||||||||||||||||||||||||||||||||||||||||||
| 204 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 205 | completion => $App::OrgUtils::_complete_state, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | detail => { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | schema => [bool => default => 0], | ||||||||||||||||||||||||||||||||||||||||||
| 209 | summary => 'Show details instead of just titles', | ||||||||||||||||||||||||||||||||||||||||||
| 210 | cmdline_aliases => {l=>{}}, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | tags => ['format'], | ||||||||||||||||||||||||||||||||||||||||||
| 212 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | has_tags => { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 'x.name.singular' => 'has_tag', | ||||||||||||||||||||||||||||||||||||||||||
| 216 | schema => ['array', of=>'str*'], | ||||||||||||||||||||||||||||||||||||||||||
| 217 | summary => 'Only show headlines that have the specified tags', | ||||||||||||||||||||||||||||||||||||||||||
| 218 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 219 | element_completion => $App::OrgUtils::_complete_tags, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | lacks_tags => { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 'x.name.singular' => 'lacks_tag', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | schema => ['array', of=>'str*'], | ||||||||||||||||||||||||||||||||||||||||||
| 225 | summary=> 'Only show headlines that don\'t have the specified tags', | ||||||||||||||||||||||||||||||||||||||||||
| 226 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 227 | element_completion => $App::OrgUtils::_complete_tags, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | group_by_tags => { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | schema => [bool => default => 0], | ||||||||||||||||||||||||||||||||||||||||||
| 231 | summary => 'Whether to group result by tags', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | If set to true, instead of returning a list, this function will return a hash of | ||||||||||||||||||||||||||||||||||||||||||
| 235 | lists, keyed by tag: {tag1: [hl1, hl2, ...], tag2: [...]}. Note that a headline | ||||||||||||||||||||||||||||||||||||||||||
| 236 | that has several tags will only be listed under its first tag, unless when | ||||||||||||||||||||||||||||||||||||||||||
| 237 | `allow_duplicates` is set to true, in which case the headline will be listed | ||||||||||||||||||||||||||||||||||||||||||
| 238 | under each of its tag. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 241 | tags => ['format'], | ||||||||||||||||||||||||||||||||||||||||||
| 242 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | allow_duplicates => { | ||||||||||||||||||||||||||||||||||||||||||
| 244 | schema => ['bool'], | ||||||||||||||||||||||||||||||||||||||||||
| 245 | summary => 'Whether to allow headline to be listed more than once', | ||||||||||||||||||||||||||||||||||||||||||
| 246 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | This is only relevant when `group_by_tags` is on. Normally when a headline has | ||||||||||||||||||||||||||||||||||||||||||
| 249 | several tags, it will only be listed under its first tag. But when this option | ||||||||||||||||||||||||||||||||||||||||||
| 250 | is turned on, the headline will be listed under each of its tag (which mean a | ||||||||||||||||||||||||||||||||||||||||||
| 251 | single headline will be listed several times). | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 254 | tags => ['format'], | ||||||||||||||||||||||||||||||||||||||||||
| 255 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | priority => { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | schema => ['str'], | ||||||||||||||||||||||||||||||||||||||||||
| 258 | summary => 'Only show todo items that have this priority', | ||||||||||||||||||||||||||||||||||||||||||
| 259 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 260 | completion => $App::OrgUtils::_complete_priority, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | minimum_priority => { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | schema => ['str'], | ||||||||||||||||||||||||||||||||||||||||||
| 264 | summary => 'Only show todo items that have at least this priority', | ||||||||||||||||||||||||||||||||||||||||||
| 265 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 266 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | Note that the default priority list is [A, B, C] (A being the highest) and it | ||||||||||||||||||||||||||||||||||||||||||
| 269 | can be customized using the `#+PRIORITIES` setting. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 272 | links => ['maximum_priority'], | ||||||||||||||||||||||||||||||||||||||||||
| 273 | completion => $App::OrgUtils::_complete_priority, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | maximum_priority => { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | schema => ['str'], | ||||||||||||||||||||||||||||||||||||||||||
| 277 | summary => 'Only show todo items that have at most this priority', | ||||||||||||||||||||||||||||||||||||||||||
| 278 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 279 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | Note that the default priority list is [A, B, C] (A being the highest) and it | ||||||||||||||||||||||||||||||||||||||||||
| 282 | can be customized using the `#+PRIORITIES` setting. | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 285 | links => ['minimum_priority'], | ||||||||||||||||||||||||||||||||||||||||||
| 286 | completion => $App::OrgUtils::_complete_priority, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | with_unknown_priority => { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | schema => ['bool'], | ||||||||||||||||||||||||||||||||||||||||||
| 290 | summary => 'Also show items with no/unknown priority', | ||||||||||||||||||||||||||||||||||||||||||
| 291 | tags => ['filter'], | ||||||||||||||||||||||||||||||||||||||||||
| 292 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | Relevant only when used with `minimum_priority` and/or `maximum_priority`. | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | If this option is turned on, todo items that does not have any priority or have | ||||||||||||||||||||||||||||||||||||||||||
| 297 | unknown priorities will *still* be included. Otherwise they will not be | ||||||||||||||||||||||||||||||||||||||||||
| 298 | included. | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 301 | links => ['minimum_priority', 'maximum_priority'], | ||||||||||||||||||||||||||||||||||||||||||
| 302 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | today => { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | schema => [obj => isa=>'DateTime'], | ||||||||||||||||||||||||||||||||||||||||||
| 305 | summary => 'Assume today\'s date', | ||||||||||||||||||||||||||||||||||||||||||
| 306 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | You can provide Unix timestamp or DateTime object. If you provide a DateTime | ||||||||||||||||||||||||||||||||||||||||||
| 309 | object, remember to set the correct time zone. | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 312 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | sort => { | ||||||||||||||||||||||||||||||||||||||||||
| 314 | schema => [any => { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | of => [ | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ['str*' => {in=>['due_date', '-due_date']}], | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 'code*', | ||||||||||||||||||||||||||||||||||||||||||
| 318 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 319 | default => 'due_date', | ||||||||||||||||||||||||||||||||||||||||||
| 320 | }], | ||||||||||||||||||||||||||||||||||||||||||
| 321 | summary => 'Specify sorting', | ||||||||||||||||||||||||||||||||||||||||||
| 322 | description => <<'MARKDOWN', | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | If string, must be one of 'due_date', '-due_date' (descending). | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare, | ||||||||||||||||||||||||||||||||||||||||||
| 327 | where REC is the final record that will be returned as final result (can be a | ||||||||||||||||||||||||||||||||||||||||||
| 328 | string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if | ||||||||||||||||||||||||||||||||||||||||||
| 329 | any), and HL is the Org::Headline object. | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | MARKDOWN | ||||||||||||||||||||||||||||||||||||||||||
| 332 | tags => ['format'], | ||||||||||||||||||||||||||||||||||||||||||
| 333 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 334 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 335 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub list_org_headlines { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_org_headlines: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $sort = $args{sort}; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | my $tz = $args{time_zone} // $ENV{TZ} // "UTC"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($args{"time_zone"} // $ENV{"TZ"}) // "UTC"
$args{"time_zone"} // $ENV{"TZ"}
MC/DC0%0/2
($args{"time_zone"} // $ENV{"TZ"}) // "UTC"
$args{"time_zone"}
$ENV{"TZ"}
Truth table0%0/3
A // B
A= $args{"time_zone"}B= $ENV{"TZ"}
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $files = $args{files}; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $args{_raw} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"_raw"} //= 1
MC/DC0%0/1
$args{"_raw"} //= 1
$args{"_raw"}
Truth table0%0/2
A
A= $args{"_raw"}
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | $today = $args{today} // DateTime->today(time_zone => $tz); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"today"} // "DateTime"->today("time_zone", $tz)
MC/DC0%0/2
$args{"today"} // "DateTime"->today("time_zone", $tz)
$args{"today"}
"DateTime"->today("time_zone", $tz)
Truth table0%0/3
A // B
A= $args{"today"}B= "DateTime"->today("time_zone", $tz)
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $yest = $today->clone->add(days => -1); | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my %docs = App::OrgUtils::_load_org_files( | |||||||||||||||||||||||||||||||||||||||||
| 351 | $files, {time_zone=>$tz}); | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | for my $file (keys %docs) { | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $doc = $docs{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 354 | $doc->walk( | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my ($el) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | return unless $el->isa('Org::Element::Headline'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | _process_hl($file, $el, \%args, \@res, $args{_raw}) | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if ($sort) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if (ref($sort) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | @res = sort $sort @res; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } elsif ($sort =~ /^-?due_date$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | @res = sort { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $dt1 = $a->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $dt2 = $b->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $comp; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if ($dt1 && !$dt2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$dt1 and not $dt2
MC/DC0%0/2
$dt1 and not $dt2
$dt1
not $dt2
Truth table0%0/3
A and not(B)
A= $dt1B= not $dt2
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $comp = -1; | |||||||||||||||||||||||||||||||||||||||||
| 372 | ▶ | } elsif (!$dt1 && $dt2) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $dt1 and $dt2
MC/DC0%0/2
not $dt1 and $dt2
not $dt1
$dt2
Truth table0%0/3
not(A) and B
A= not $dt1B= $dt2
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $comp = 1; | |||||||||||||||||||||||||||||||||||||||||
| 374 | ▶ | } elsif (!$dt1 && !$dt2) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$dt1 || $dt2
MC/DC0%0/2
$dt1 || $dt2
$dt1
$dt2
Truth table0%0/3
A || B
A= $dt1B= $dt2
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $comp = 0; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $comp = DateTime->compare($dt1, $dt2); | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | ($sort =~ /^-/ ? -1 : 1) * $comp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | } @res; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($args{group_by_tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | # cache tags in each @res element's [3] element | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | for (@res) { $_->[3] = [$_->[2]->get_tags] } | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my @tags = sort(uniq(map {@{$_->[3]}} @res)); | |||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $res = {}; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | for my $tag ('', @tags) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $res->{$tag} = []; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | for (@res) { | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($tag eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | next if @{$_->[3]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | next unless grep { $_ eq $tag } @{$_->[3]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | next if !$args{allow_duplicates} && $seen{$_->[0]}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $args{"allow_duplicates"} and $seen{$_->[0]}++
MC/DC0%0/2
not $args{"allow_duplicates"} and $seen{$_->[0]}++
not $args{"allow_duplicates"}
$seen{$_->[0]}++
Truth table0%0/3
not(A) and B
A= not $args{"allow_duplicates"}B= $seen{$_->[0]}++
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | push @{ $res->{$tag} }, $_->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $res = [map {$_->[0]} @res]; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | [200, "OK", $res]; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 412 | # ABSTRACT: List all headlines in all Org files | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | __END__ | ||||||||||||||||||||||||||||||||||||||||||