mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Proper trigger logic for TODOs.
This commit is contained in:
@@ -2427,7 +2427,7 @@ WriteJSONInfoChain(TrigInfo *ti)
|
||||
}
|
||||
printf("},");
|
||||
}
|
||||
void WriteJSONTrigger(Trigger const *t, int include_tags, int today)
|
||||
void WriteJSONTrigger(Trigger const *t, int include_tags)
|
||||
{
|
||||
/* wd is an array of days from 0=monday to 6=sunday.
|
||||
We convert to array of strings */
|
||||
@@ -2556,7 +2556,7 @@ static void WriteSimpleEntryProtocol2(CalEntry *e, int today)
|
||||
PrintJSONKeyPairInt("trep", e->tt.rep);
|
||||
}
|
||||
}
|
||||
WriteJSONTrigger(&e->trig, 0, today);
|
||||
WriteJSONTrigger(&e->trig, 0);
|
||||
if (e->nonconst_expr) {
|
||||
PrintJSONKeyPairInt("nonconst_expr", e->nonconst_expr);
|
||||
}
|
||||
|
||||
18
src/dorem.c
18
src/dorem.c
@@ -341,7 +341,7 @@ int DoRem(ParsePtr p)
|
||||
}
|
||||
}
|
||||
if (PurgeMode) {
|
||||
if (trig.expired || dse < DSEToday) {
|
||||
if (trig.expired || (!trig.is_todo && dse < DSEToday)) {
|
||||
if (p->expr_happened) {
|
||||
if (p->nonconst_expr) {
|
||||
if (!Hush) {
|
||||
@@ -1515,6 +1515,11 @@ int ShouldTriggerReminder(Trigger const *t, TimeTrig const *tim, int dse, int *e
|
||||
if (t->complete_through != NO_DATE && t->complete_through >= DSEToday) {
|
||||
return 0;
|
||||
}
|
||||
if (t->complete_through == NO_DATE || t->complete_through < dse) {
|
||||
if (dse < DSEToday) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (dse < DSEToday) return 0;
|
||||
}
|
||||
@@ -1794,6 +1799,17 @@ static int ShouldTriggerBasedOnWarn(Trigger const *t, int dse, int *err)
|
||||
Value v;
|
||||
int lastReturnVal = 0; /* Silence compiler warning */
|
||||
|
||||
if (t->is_todo) {
|
||||
if (t->complete_through != NO_DATE && t->complete_through >= DSEToday) {
|
||||
return 0;
|
||||
}
|
||||
if (t->complete_through == NO_DATE || t->complete_through < dse) {
|
||||
if (dse < DSEToday) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If no proper function exists, barf... */
|
||||
if (UserFuncExists(t->warn) != 1) {
|
||||
Eprint("%s: `%s'", GetErr(M_BAD_WARN_FUNC), t->warn);
|
||||
|
||||
@@ -426,7 +426,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig const *tt, int
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
snprintf(s, sizeof(s), "in %d days' time", diff);
|
||||
if (diff > 0) {
|
||||
snprintf(s, sizeof(s), "in %d days' time", diff);
|
||||
} else {
|
||||
snprintf(s, sizeof(s), "%d days ago", -diff);
|
||||
}
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ void clear_callstack(void);
|
||||
int print_callstack(FILE *fp);
|
||||
void pop_call(void);
|
||||
void FixSpecialType(Trigger *trig);
|
||||
void WriteJSONTrigger(Trigger const *t, int include_tags, int today);
|
||||
void WriteJSONTrigger(Trigger const *t, int include_tags);
|
||||
void WriteJSONTimeTrigger(TimeTrig const *tt);
|
||||
int GetOnceDate(void);
|
||||
#ifdef REM_USE_WCHAR
|
||||
|
||||
@@ -704,7 +704,7 @@ json_queue(QueuedRem const *q)
|
||||
}
|
||||
done = 1;
|
||||
printf("{");
|
||||
WriteJSONTrigger(&(q->t), 1, DSEToday);
|
||||
WriteJSONTrigger(&(q->t), 1);
|
||||
WriteJSONTimeTrigger(&(q->tt));
|
||||
if (TestMode) {
|
||||
snprintf(idbuf, sizeof(idbuf), "42424242");
|
||||
|
||||
@@ -313,12 +313,21 @@ static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart
|
||||
int simple, mod, omit;
|
||||
|
||||
/* First: Have we passed the UNTIL date? */
|
||||
if (trig->until != NO_UNTIL &&
|
||||
if (!trig->is_todo &&
|
||||
trig->until != NO_UNTIL &&
|
||||
trig->until < start) {
|
||||
trig->expired = 1;
|
||||
return -1; /* expired */
|
||||
}
|
||||
|
||||
/* If it's a TODO and complete_through is past today, we're good */
|
||||
if (trig->is_todo &&
|
||||
trig->complete_through != NO_DATE &&
|
||||
trig->complete_through >= start) {
|
||||
trig->expired = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Next: If it's an "AFTER"-type skip, back up
|
||||
until we're at the start of a block of holidays */
|
||||
if (trig->skip == AFTER_SKIP) {
|
||||
|
||||
Reference in New Issue
Block a user