/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: 2011-12-10 20:34:05 UTC
  • Revision ID: edam@waxworlds.org-20111210203405-tfo68eb3s7hwmhld
added default todo file content and changed main todo section name to "TODO"

Show diffs side-by-side

added added

removed removed

11
11
# option defaults
12
12
my $todo_dir = "~/.todo";
13
13
my $display_all = 0;
14
 
my $display_section = "IMMEDIATE";
 
14
my $display_section = "TODO";
15
15
my $display_headers = 0;
16
16
my $mode_edit = 0;
17
17
my $mode_help = 0;
72
72
                mkdir $todo_dir or die "couldn't create todo directory";
73
73
                `bzr init --no-aliases -q "$todo_dir"`;
74
74
                $? == 0 or die "couldn't init bzr repo";
75
 
                `> "$todo_dir/todo"`;
76
 
                $? == 0 or die "couldn't create initial todo file";
 
75
        }
 
76
        
 
77
        # create a default todo file, as necessary
 
78
        if( ! -f "$todo_dir/todo" ) {
 
79
                open FILE, ">$todo_dir/todo" or die "couldn't create default todo file";
 
80
                my $content = <<"EOT";
 
81
<!-- This file uses Markdown syntax. For more info about Markdown
 
82
     syntax, see http://daringfireball.net/projects/markdown/syntax.
 
83
 
 
84
     There should be a main H1 header called "TODO" for the main todo
 
85
     list section (one has been added for you below). You can also add
 
86
     as many more sections as you like for other lists. And feel free
 
87
     to delete this comment! -->
 
88
 
 
89
TODO
 
90
====
 
91
 
 
92
* make a list of things to do
 
93
 
 
94
EOT
 
95
        print FILE $content or die "couldn't write default todo file";
 
96
                close FILE;
77
97
                `bzr add --no-aliases -q "$todo_dir/todo"`;
78
98
                $? == 0 or die "couldn't add todo file to bzr repo";
79
99
        }
85
105
    push( @exec_array, "$todo_dir/todo" );
86
106
 
87
107
        # detect emacs and try to use markdown-mode
88
 
        $exec_array[ 0 ] eq "emacs" and push( @exec_array, '--funcall=markdown-mode' );
 
108
        $exec_array[ 0 ] eq "emacs" and
 
109
                push( @exec_array, '--funcall=markdown-mode' );
89
110
 
90
111
    # edit todo file
91
112
    system( @exec_array );
99
120
                `bzr commit --no-aliases -q -m - "$todo_dir/todo"`;
100
121
                $? == 0 or die "couldn't commit to bzr repo";
101
122
        }
102
 
        
103
 
        # exit
 
123
 
 
124
        # after editing, exit
104
125
        exit
105
126
}
106
127
 
127
148
                $next_section = '';
128
149
 
129
150
                # display line
130
 
                if( $section eq $display_section ||
131
 
                        $display_all )
 
151
                if( ( $section eq $display_section ) ||
 
152
                        ( $section && $display_all ) )
132
153
                {
133
154
                        # detect section change
134
155
                        if( $section ne $old_section ) {
138
159
                                if( $display_headers ||
139
160
                                        $display_all )
140
161
                                {
141
 
                                        my $heading = 'TODO';
142
 
                                        $heading .= ' ('.lc( $section ).')' if $section ne "IMMEDIATE";
143
 
                                        print "$heading\n".
144
 
                                                ( "=" x length( $heading ) )."\n";
 
162
                                        print "$section\n".
 
163
                                                ( "=" x length( $section ) )."\n";
145
164
                                }
146
165
                        }
147
166