Various improvements so that TODO's scheduled for current day appear.
This commit is contained in:
parent
e6a901057f
commit
46edc5c63f
1 changed files with 53 additions and 32 deletions
|
@ -36,7 +36,7 @@ if ($? != 0) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
my $now = ParseDate("now");
|
my $now = ParseDate("now");
|
||||||
open(ORG_MODE_AGENDA, "-|", "/usr/bin/emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"a\" org-agenda-files (mapcar (lambda (arg) (replace-regexp-in-string \"~/Crypt/Orgs/\" \"~/Crypt/.org-backup/\" arg)) org-agenda-files) org-agenda-span (quote 10) org-agenda-overriding-header \"\" org-agenda-repeating-timestamp-show-all t org-agenda-time-grid nil org-agenda-repeating-timestamp-show-all t org-agenda-entry-types (quote (:sexp :scheduled))))' 2>/dev/null") or
|
open(ORG_MODE_AGENDA, "-|", "/usr/bin/emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"a\" org-agenda-files (mapcar (lambda (arg) (replace-regexp-in-string \"~/Crypt/Orgs/\" \"~/Crypt/.org-backup/\" arg)) org-agenda-files) org-agenda-span (quote 10) org-agenda-overriding-header \"\" org-agenda-repeating-timestamp-show-all t org-agenda-time-grid nil org-agenda-repeating-timestamp-show-all t org-agenda-entry-types (quote (:sexp :scheduled)))' 2>/dev/null") or
|
||||||
die "Unable to run emacs: $!";
|
die "Unable to run emacs: $!";
|
||||||
|
|
||||||
my $firstDay;
|
my $firstDay;
|
||||||
|
@ -52,16 +52,33 @@ while (my $line = <ORG_MODE_AGENDA>) {
|
||||||
$dayLine =~ s/\s*W\d+\s*$//;
|
$dayLine =~ s/\s*W\d+\s*$//;
|
||||||
$prettyDayLine = "\${color3}$dayLine\${color}\n";
|
$prettyDayLine = "\${color3}$dayLine\${color}\n";
|
||||||
}
|
}
|
||||||
elsif ($line =~ /^\s+([^:]+)\s*:\s+(\d+)\s*:\s*(\d+)\s*[\-\.]+(?:\s*(\d+)\s*:\s*(\d+))?(.*)$/) {
|
elsif ($line =~ /^\s+([^:]+)\s*:\s*(\d+)\s*:\s*(\d+)\s*[\-\.]+(?:\s*(\d+)\s*:\s*(\d+))?(.*)$/) {
|
||||||
my($source, $startHour, $startMin, $endHour, $endMin, $rest) =
|
my($source, $startHour, $startMin, $endHour, $endMin, $rest) =
|
||||||
($1, $2, $3, $4, $5, $6);
|
($1, $2, $3, $4, $5, $6);
|
||||||
|
next if $rest =~ /Sched.*\d+x\s*:/; # Skip overdue TODOs, because I have lot.
|
||||||
|
my $type;
|
||||||
|
if ($rest =~ s/^\s*Scheduled?\s*:\s*(WAITING|TODO|APPT|DELEGATED|DONE|DEFFERRED|CANCELLED|STARTED)\s*//i) {
|
||||||
|
$type = $1;
|
||||||
|
} else {
|
||||||
|
$type = $source;
|
||||||
|
}
|
||||||
|
$startHour = "0$startHour" if length($startHour) == 1;
|
||||||
my $start = "$startHour:$startMin";
|
my $start = "$startHour:$startMin";
|
||||||
my $end = "$endHour:$endMin";
|
|
||||||
my $date = ParseDate("$dayLine $start");
|
my $date = ParseDate("$dayLine $start");
|
||||||
my $endDate = ParseDate("$dayLine $end");
|
my($endDate, $end);
|
||||||
$endDate = DateCalc($date, "+ 1 hour") unless defined $endDate;
|
if (not defined $endHour) {
|
||||||
$thisLinePrintable = " $start-$end $rest\${alignr 10}(from $source)"
|
$endDate = DateCalc($date, "+ 8 hour");
|
||||||
unless $endDate lt $now;
|
$end = "";
|
||||||
|
} else {
|
||||||
|
$endMin = "00" if (not defined $endMin);
|
||||||
|
$end = "$endHour:$endMin";
|
||||||
|
$endDate = ParseDate("$dayLine $end");
|
||||||
|
$end = "-$end";
|
||||||
|
}
|
||||||
|
# Diaries and appointments are always printed, and have notifier.
|
||||||
|
if ($source =~ /(Diary|APPT)/i or $type =~ /(Diary|APPT)/i) {
|
||||||
|
$thisLinePrintable = " $start$end $rest\${alignr 10} (from $source)"
|
||||||
|
if ($endDate gt $now);
|
||||||
# At this point, we'd hope we'd hit a "\S+" line, which would indicate
|
# At this point, we'd hope we'd hit a "\S+" line, which would indicate
|
||||||
# that there's a date in this output, as they start at column 0 on the
|
# that there's a date in this output, as they start at column 0 on the
|
||||||
# output. However, if we happen to find something odd in the output,
|
# output. However, if we happen to find something odd in the output,
|
||||||
|
@ -84,8 +101,12 @@ while (my $line = <ORG_MODE_AGENDA>) {
|
||||||
'Appointment', "You have an appointment at $start: $rest");
|
'Appointment', "You have an appointment at $start: $rest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elsif ($line =~ /^\s+(?:birthday|anniversary)\s*:\s*(\S.+)\s*$/i) {
|
} else { # Source isn't a diary or appointment
|
||||||
$thisLinePrintable = " $1";
|
$thisLinePrintable = " $start$end $rest\${alignr 10}(from $source)"
|
||||||
|
if (($endDate gt $now) and
|
||||||
|
($firstDay or $type =~ /(birthday|anniversary)/i
|
||||||
|
or $source =~ /(birthday|anniversary)/i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (defined $thisLinePrintable) {
|
if (defined $thisLinePrintable) {
|
||||||
if (defined $prettyDayLine) {
|
if (defined $prettyDayLine) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue