diff --git a/contrib/remind-conf-mode/remind-conf-mode.el b/contrib/remind-conf-mode/remind-conf-mode.el index 2d9dba04..75c88d8d 100644 --- a/contrib/remind-conf-mode/remind-conf-mode.el +++ b/contrib/remind-conf-mode/remind-conf-mode.el @@ -147,7 +147,7 @@ "$May" "$MinsFromUTC" "$Minute" "$Monday" "$Mplu" "$NextMode" "$November" "$Now" "$NumFullOmits" "$NumPartialOmits" "$NumQueued" "$NumTrig" "$October" "$On" "$OnceFile" "$ParseUntriggered" "$Pm" - "$PrefixLineNo" "$PSCal" "$RunOff" "$Saturday" "$September" + "$PrefixLineNo" "$PSCal" "$RunOff" "$Saturday" "$September" "$Shaded" "$SimpleCal" "$SortByDate" "$SortByPrio" "$SortByTime" "$SubsIndent" "$Sunday" "$SuppressImplicitWarnings" "$SuppressLRM" "$SysInclude" "$T" "$Tb" "$Td" "$TerminalBackground" "$TerminalHyperlinks" "$Thursday" "$TimeSep" "$TimetIs64bit" "$Tm" "$Today" "$TodoFilter" diff --git a/man/remind.1.in b/man/remind.1.in index d0dc6083..d3d3b753 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -3361,6 +3361,30 @@ If non-zero, then the \fB\-p\fR option was supplied on the command line. .B $RunOff (read-only) If non-zero, the \fBRUN\fR directives are disabled. .TP +.B $Shaded (read-only) +Returns the number of times a \fBSHADE\fR special reminder has triggered. +\fIThis variable is set only in calendar mode, not agenda mode\fR. You +can use this variable to avoid shading a calendar day that has already +been shaded. +.RS +.PP +For example, suppose you want to shade all calendar boxes yellow +\fIif\fR any reminders have triggered on that day. But if a box has +been explicitly shaded, you don't want to overwrite that shading. +You could use something like this: +.PP +.nf + SET n $NumTrig + # Do all your reminders here... + + # If anything has triggered and the box is + # not already shaded, then shade it yellow + IF $NumTrig > n && !$Shaded + REM SPECIAL SHADE 255 255 128 + ENDIF +.fi +.RE +.TP .B $SimpleCal (read-only) Set to a non-zero value if \fIeither\fR of the \fB\-p\fR or \fB\-s\fR command-line options was supplied. diff --git a/src/calendar.c b/src/calendar.c index a58c18b7..2fe8491e 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -2123,8 +2123,9 @@ static int DoCalRem(ParsePtr p, int col) } } if (trig.typ == PASSTHRU_TYPE) { - if (!PsCal && !strcasecmp(trig.passthru, "SHADE")) { - if (dse == DSEToday) { + if (!strcasecmp(trig.passthru, "SHADE") && dse == DSEToday) { + Shaded++; + if (!PsCal) { DBufInit(&obuf); r = DoSubst(p, &obuf, &trig, &tim, dse, CAL_MODE); if (r) { diff --git a/src/globals.h b/src/globals.h index 701c71da..3645341c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -106,6 +106,7 @@ EXTERN INIT( int DefaultPrio, NO_PRIORITY); EXTERN INIT( int SysTime, -1); EXTERN INIT( int LocalSysTime, -1); EXTERN INIT( int ParseUntriggered, 0); +EXTERN INIT( int Shaded, 0); EXTERN char const *InitialFile; EXTERN char const *LocalTimeZone; diff --git a/src/main.c b/src/main.c index 444c6ee5..20812be3 100644 --- a/src/main.c +++ b/src/main.c @@ -295,6 +295,7 @@ PerIterationInit(void) DefaultColorG = -1; DefaultColorB = -1; NumTriggered = 0; + Shaded = 0; JSONLinesEmitted = 0; ClearLastTriggers(); ClearDedupeTable(); diff --git a/src/var.c b/src/var.c index b019e65b..57c0fce1 100644 --- a/src/var.c +++ b/src/var.c @@ -1101,6 +1101,7 @@ static SysVar SysVarArr[] = { {"RunOff", 0, INT_TYPE, &RunDisabled, 0, 0 }, {"Saturday", 1, TRANS_TYPE, "Saturday", 0, 0 }, {"September", 1, TRANS_TYPE, "September", 0, 0 }, + {"Shaded" , 0, INT_TYPE, &Shaded, 0, 0 }, {"SimpleCal", 0, INT_TYPE, &DoSimpleCalendar, 0, 0 }, {"SortByDate", 0, INT_TYPE, &SortByDate, 0, 0 }, {"SortByPrio", 0, INT_TYPE, &SortByPrio, 0, 0 }, diff --git a/tests/shaded.rem b/tests/shaded.rem new file mode 100644 index 00000000..e014d3cc --- /dev/null +++ b/tests/shaded.rem @@ -0,0 +1,15 @@ +REM Wed SPECIAL SHADE 255 0 0 +IF !$Shaded + REM 15 SPECIAL SHADE 0 255 0 +ENDIF +IF !$Shaded + REM SATISFY [$Td % 4 == 0] SPECIAL SHADE 0 0 255 +ENDIF + +IF !$Shaded + REM Sunday SPECIAL SHADE 0 255 255 +ENDIF + +IF !$Shaded + REM SPECIAL SHADE 255 255 0 +ENDIF diff --git a/tests/test-rem b/tests/test-rem index 4cc0ccf9..bce8441c 100644 --- a/tests/test-rem +++ b/tests/test-rem @@ -987,6 +987,9 @@ REM 15 INFO "Url: https://dianne.skoll.ca" CAL Hello, linky 3! REM 15 INFO "Url: https://dianne.skoll.ca" SPECIAL COLOR 255 0 0 Hello, linky 4! EOF +# Test the $Shaded system variable +$REMIND -pp ../tests/shaded.rem >> $OUT 2>&1 + cmp -s $OUT $CMP if [ "$?" = "0" ]; then echo "Remind: Acceptance tests ${GRN}PASSED${NRM}" diff --git a/tests/test.cmp b/tests/test.cmp index 398cf718..c178b90c 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -24951,6 +24951,7 @@ $PSCal $RunOff $Saturday $September +$Shaded $SimpleCal $SortByDate $SortByPrio @@ -40236,4 +40237,39 @@ February 28 +----------+----------+----------+----------+----------+----------+----------+ |26 ‎ |27 ‎ |28 ‎ |29 ‎ |30 ‎ |31 ‎ | | +----------+----------+----------+----------+----------+----------+----------+ - \ No newline at end of file + # translations +{"LANGID":"en"} +# rem2ps2 begin +February 2026 28 0 0 +Sunday Monday Tuesday Wednesday Thursday Friday Saturday +January 31 +March 31 +{"date":"2026-02-01","filename":"../tests/shaded.rem","lineno":10,"passthru":"SHADE","wd":["Sunday"],"is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":255,"b":255,"body":"0 255 255"} +{"date":"2026-02-02","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-03","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-04","filename":"../tests/shaded.rem","lineno":1,"passthru":"SHADE","wd":["Wednesday"],"is_todo":0,"priority":5000,"r":255,"g":0,"b":0,"body":"255 0 0"} +{"date":"2026-02-05","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-06","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-07","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-08","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +{"date":"2026-02-09","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-10","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-11","filename":"../tests/shaded.rem","lineno":1,"passthru":"SHADE","wd":["Wednesday"],"is_todo":0,"priority":5000,"r":255,"g":0,"b":0,"body":"255 0 0"} +{"date":"2026-02-12","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +{"date":"2026-02-13","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-14","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-15","filename":"../tests/shaded.rem","lineno":3,"passthru":"SHADE","d":15,"is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":255,"b":0,"body":"0 255 0"} +{"date":"2026-02-16","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +{"date":"2026-02-17","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-18","filename":"../tests/shaded.rem","lineno":1,"passthru":"SHADE","wd":["Wednesday"],"is_todo":0,"priority":5000,"r":255,"g":0,"b":0,"body":"255 0 0"} +{"date":"2026-02-19","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-20","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +{"date":"2026-02-21","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-22","filename":"../tests/shaded.rem","lineno":10,"passthru":"SHADE","wd":["Sunday"],"is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":255,"b":255,"body":"0 255 255"} +{"date":"2026-02-23","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-24","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +{"date":"2026-02-25","filename":"../tests/shaded.rem","lineno":1,"passthru":"SHADE","wd":["Wednesday"],"is_todo":0,"priority":5000,"r":255,"g":0,"b":0,"body":"255 0 0"} +{"date":"2026-02-26","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-27","filename":"../tests/shaded.rem","lineno":14,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":255,"g":255,"b":0,"body":"255 255 0"} +{"date":"2026-02-28","filename":"../tests/shaded.rem","lineno":6,"passthru":"SHADE","is_todo":0,"priority":5000,"if_depth":1,"r":0,"g":0,"b":255,"body":"0 0 255"} +# rem2ps2 end