version 1.25, 2010/02/13 23:26:44 |
version 1.26, 2010/02/14 06:08:07 |
|
|
package Text::Todo; |
package Text::Todo; |
|
|
# $AFresh1: Todo.pm,v 1.24 2010/01/22 18:15:06 andrew Exp $ |
# $AFresh1: Todo.pm,v 1.25 2010/02/13 23:26:44 andrew Exp $ |
|
|
use warnings; |
use warnings; |
use strict; |
use strict; |
|
|
done_file => undef, |
done_file => undef, |
}; |
}; |
|
|
$known_tags_of{$ident} = { |
my %tags = ( |
context => '@', |
context => q{@}, |
project => '+', |
project => q{+}, |
}; |
); |
|
|
if ($options) { |
if ($options) { |
if ( ref $options eq 'HASH' ) { |
if ( ref $options eq 'HASH' ) { |
|
|
if ( exists $path_of{$ident}{$opt} ) { |
if ( exists $path_of{$ident}{$opt} ) { |
$self->_path_to( $opt, $options->{$opt} ); |
$self->_path_to( $opt, $options->{$opt} ); |
} |
} |
elsif ( $opt eq 'tags' ) { |
elsif ( $opt eq 'tags' |
foreach my $tag ( keys %{ $options->{$opt} } ) { |
&& ref $options->{$opt} eq 'HASH' ) |
$known_tags_of{$ident}{$tag} |
{ |
= $options->{$opt}{$tag}; |
%tags = ( %tags, %{ $options->{$opt} } ); |
} |
|
} |
} |
else { |
else { |
|
|
|
|
} |
} |
} |
} |
|
|
|
$known_tags_of{$ident} = \%tags; |
|
|
my $file = $self->_path_to('todo_file'); |
my $file = $self->_path_to('todo_file'); |
if ( defined $file && -e $file ) { |
if ( defined $file && -e $file ) { |
$self->load(); |
$self->load(); |
|
|
$file = $self->file($file); |
$file = $self->file($file); |
|
|
if ( $list_of{$ident} = $self->listfile($file) ) { |
if ( $list_of{$ident} = $self->listfile($file) ) { |
|
$self->known_tags; |
$loaded_of{$ident} = $file; |
$loaded_of{$ident} = $file; |
return 1; |
return 1; |
} |
} |
|
|
if ( !ref $entry ) { |
if ( !ref $entry ) { |
$entry = Text::Todo::Entry->new( |
$entry = Text::Todo::Entry->new( |
{ text => $entry, |
{ text => $entry, |
tags => $self->_known_tags, |
tags => $known_tags_of{$ident}, |
} |
} |
); |
); |
} |
} |
|
|
|
|
push @{ $list_of{$ident} }, $entry; |
push @{ $list_of{$ident} }, $entry; |
|
|
|
$self->known_tags; |
|
|
return $entry; |
return $entry; |
} |
} |
|
|
|
|
return wantarray ? @tags : \@tags; |
return wantarray ? @tags : \@tags; |
} |
} |
|
|
sub _known_tags { |
sub learn_tag { |
|
my ( $self, $tag, $sigal ) = @_; |
|
|
|
$known_tags_of{ ident $self}{$tag} = $sigal; |
|
$self->known_tags; |
|
|
|
return 1; |
|
} |
|
|
|
sub known_tags { |
my ($self) = @_; |
my ($self) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
|
|
my @list = $self->list; |
my @list = $self->list; |
|
my %tags = %{ $known_tags_of{$ident} }; |
|
|
foreach my $e (@list) { |
foreach my $e (@list) { |
my $kt = $e->known_tags; |
my $kt = $e->known_tags; |
foreach my $t ( keys %{$kt} ) { |
foreach my $t ( keys %{$kt} ) { |
if ( !exists $known_tags_of{$ident}{$t} ) { |
if ( !exists $tags{$t} ) { |
$known_tags_of{$ident}{$t} = $kt->{$t}; |
$tags{$t} = $kt->{$t}; |
} |
} |
} |
} |
} |
} |
|
|
return $known_tags_of{$ident}; |
foreach my $e (@list) { |
} |
my $kt = $e->known_tags; |
|
foreach my $t ( keys %tags ) { |
|
if ( !exists $kt->{$t} || $tags{$t} ne $kt->{$t} ) { |
|
$e->learn_tag( $t, $tags{$t} ); |
|
} |
|
} |
|
} |
|
|
sub listtags { |
$known_tags_of{$ident} = \%tags; |
my ($self) = @_; |
|
my $ident = ident($self); |
|
|
|
my @list = sort keys %{ $self->_known_tags }; |
return $known_tags_of{$ident}; |
|
|
return wantarray ? @list : \@list; |
|
} |
} |
|
|
sub archive { |
sub archive { |
|
|
|
|
I think it may become depreciated unless there is demand. |
I think it may become depreciated unless there is demand. |
|
|
=head2 listtags |
=head2 known_tags |
|
|
Returns a list of the tags known to the list. |
Returns a reference to a hash of the tags known to the list. |
|
|
|
=head2 learn_tag($tag, $sigal) |
|
|
|
Let the entire list learn a new tag. |
|
If you are working with a list you should use this instead of |
|
$entry->learn_tag because it will update all entries. |
|
|
=head2 listtag($tag) |
=head2 listtag($tag) |
|
|