/todo

To get this branch, use:
bzr branch http://bzr.ed.am/todo

« back to all changes in this revision

Viewing changes to todo

  • Committer: edam
  • Date: 2012-01-04 12:46:10 UTC
  • Revision ID: edam@waxworlds.org-20120104124610-nrrs6mv1btg390ni
rewrite file parsing to cache the last line and only display it when we know the current line is not a section heading "underline" line.

Show diffs side-by-side

added added

removed removed

25
25
    'a|all' => \$display_all,
26
26
    'e|edit' => \$mode_edit,
27
27
    'h|headers' => \$display_headers,
28
 
    's|section=s' => \$display_section,
 
28
    'section=s' => \$display_section,
29
29
    'help' => \$mode_help,
30
30
    'version' => \$mode_version,
31
 
) || @ARGV > 0 ) {
 
31
) ) {
32
32
    print "Try `$app_name --help' for more information.\n";
33
33
    exit( 1 );
34
34
}
36
36
# help mode
37
37
if( $mode_help ) {
38
38
    print "todo - display your todo file\n\n".
39
 
        #01234567890123456789012345678901234567890123456789012345678901234567890123456789
40
39
    "Usage: $app_name [OPTIONS]\n\n".
41
40
    "Options:\n".
42
41
    "  -a, --all              display all sections\n".
43
42
    "  -e, --edit             edit your todo file\n".
44
43
    "  -h, --headers          show setion headers\n".
45
 
    "  -s, --section=SECTION  display sections matching the regular expression\n".
 
44
    "      --section=SECTION  display this named section\n".
46
45
    "      --help     display this help and exit\n".
47
 
    "      --version  output version information and exit\n".
48
 
        "\n".
49
 
        "Running without any options is the same as running with --section=TODO and\n".
50
 
        "lists the default section of the todo file.\n".
51
 
        "\n".
52
 
        "The environment variables EDITOR is used.\n".
53
 
        "\n".
54
 
        "Please report bugs to Tim Marston <tim\@ed.am>.\n";
 
46
    "      --version  output version information and exit\n";
55
47
    exit( 0 );
56
48
}
57
49
 
58
50
# version mode
59
51
if( $mode_version ) {
60
52
    print "todo 1.0\n".
61
 
        "Copyright (C) 2011, 2012 Tim Marston.\n".
 
53
        "Copyright (C) 2011 Tim Marston.\n".
62
54
        "http://ed.am/software/todo\n";
63
55
    exit( 0 );
64
56
}
110
102
    }
111
103
 
112
104
    # determine editor from environment, default to "emacs -nw"
113
 
        my $editor;
114
 
        $editor = $ENV{ 'EDITOR' };
115
 
        defined $editor or $editor = 'emacs -nw';
 
105
    my $editor = $ENV{ 'EDITOR' };
 
106
    defined $editor or $editor = 'emacs -nw';
116
107
    my @exec_array = split( / +/, $editor );
117
108
    push( @exec_array, "$todo_dir/todo" );
118
109
 
191
182
        display_line( $last_line, $section ) if( $last_line ne '' );
192
183
 
193
184
    # display line
194
 
        if( ( lc( $section ) eq lc( $display_section ) ) ||
 
185
        if( ( $section eq $display_section ) ||
195
186
                ( $section && $display_all ) )
196
187
        {
197
188
                $last_line = $_;