From 07fd9759358d95975c4af5e7f6c3fe36ff4e9cfc Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Mon, 10 Oct 2022 22:49:28 -0400 Subject: [PATCH] Add the $AddBlankLines system variable. --- man/remind.1.in | 18 +++++++++++++----- src/dorem.c | 4 ++-- src/dosubst.c | 7 +++++-- src/globals.h | 1 + src/var.c | 1 + tests/blanks.rem | 5 +++++ tests/test-rem | 5 +++++ tests/test.cmp | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 tests/blanks.rem diff --git a/man/remind.1.in b/man/remind.1.in index 7f5b10b3..6ba203d0 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -1526,7 +1526,8 @@ Notes: o .B Remind normally prints a blank line after each reminder; if the last character -of the body is "%", the blank line will not be printed. +of the body is "%", the blank line will not be printed. You can globally +suppress the extra blank lines by setting \fB$AddBlankLines\fR to 0. .TP o Substitutions a, b, c, e, f, g, h, i, j, k, l, u and v all are replaced @@ -2275,6 +2276,13 @@ The following system variables are defined. Those marked All system variables hold values of type \fBINT\fR, unless otherwise specified. .TP +.B $AddBlankLines +If set to 1 (the default), then \fBRemind\fR normally prints a blank +line after the banner and each reminder. (This can be suppressed by +ending the reminder or banner with a single percent sign.) If +$AddBlankLines is set to 0, then Remind does not print the blank line. +In this case, ending a reminder with % has no effect. +.TP .B $CalcUTC If 1 (the default), then \fBRemind\fR uses C library functions to calculate the number of minutes between local and Universal Time @@ -3753,7 +3761,7 @@ defined, and the value of XY if it is defined. .TP .B version() Returns a string specifying the version of \fBRemind\fR. For version -03.00.04, returns "03.00.04". It is guaranteed that as new versions of +@VERSION@, returns "@VERSION@". It is guaranteed that as new versions of \fBRemind\fR are released, the value returned by \fBversion()\fR will strictly increase, according to the rules for string ordering. .TP @@ -4086,13 +4094,13 @@ Notes: .TP o If you access a variable in \fIexpr\fR that is not in the list of arguments, -the "global" value (if any) is used. +the global value (if any) is used. .TP o -Function and parameter names are significant only to 12 characters. +Function and parameter names are significant to 64 characters. .TP o -The \fBvalue()\fR function \fIalways\fR accesses the "global" value of a +The \fBvalue()\fR function \fIalways\fR accesses the global value of a variable, even if it has the same name as an argument. For example: .RS .PP diff --git a/src/dorem.c b/src/dorem.c index e103582a..7871e670 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -945,8 +945,8 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) if (!DoSubstFromString(DBufValue(&Banner), &buf, JulianToday, NO_TIME) && DBufLen(&buf)) { - printf("%s\n", DBufValue(&buf)); - } + printf("%s\n", DBufValue(&buf)); + } DBufFree(&buf); } diff --git a/src/dosubst.c b/src/dosubst.c index 33e66fc1..f68d654b 100644 --- a/src/dosubst.c +++ b/src/dosubst.c @@ -190,8 +190,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, } if (c == '\n') continue; if (!c) { - if (mode != CAL_MODE && mode != ADVANCE_MODE && - t->typ != RUN_TYPE && !MsgCommand) { + if (AddBlankLines && + mode != CAL_MODE && + mode != ADVANCE_MODE && + t->typ != RUN_TYPE && + !MsgCommand) { if (DBufPutc(dbuf, '\n') != OK) return E_NO_MEM; } break; diff --git a/src/globals.h b/src/globals.h index 8fc0ef35..1cc6a279 100644 --- a/src/globals.h +++ b/src/globals.h @@ -58,6 +58,7 @@ EXTERN INIT( int DoSimpleCalendar, 0); EXTERN INIT( int DoSimpleCalDelta, 0); EXTERN INIT( int DoPrefixLineNo, 0); EXTERN INIT( int MondayFirst, 0); +EXTERN INIT( int AddBlankLines, 1); EXTERN INIT( int Iterations, 1); EXTERN INIT( int PsCal, 0); EXTERN INIT( int CalWidth, 80); diff --git a/src/var.c b/src/var.c index 3ec2a192..2ab7c8b6 100644 --- a/src/var.c +++ b/src/var.c @@ -776,6 +776,7 @@ typedef struct { /* All of the system variables sorted alphabetically */ static SysVar SysVarArr[] = { /* name mod type value min/mal max validate*/ + {"AddBlankLines", 1, INT_TYPE, &AddBlankLines, 0, 1, NULL }, {"Ago", 1, STR_TYPE, &DynamicAgo, 0, 0, NULL }, {"Am", 1, STR_TYPE, &DynamicAm, 0, 0, NULL }, {"And", 1, STR_TYPE, &DynamicAnd, 0, 0, NULL }, diff --git a/tests/blanks.rem b/tests/blanks.rem new file mode 100644 index 00000000..44d5586e --- /dev/null +++ b/tests/blanks.rem @@ -0,0 +1,5 @@ +MSG $AddBlankLines=[$AddBlankLines] +MSG Hello +MSG Hi +MSF How are you? +MSG OK diff --git a/tests/test-rem b/tests/test-rem index f1f1aee6..44ce2441 100644 --- a/tests/test-rem +++ b/tests/test-rem @@ -116,6 +116,11 @@ echo "ANSI Color Test" >> ../tests/test.out ../src/remind -@1,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1 ../src/remind -@2,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1 +echo '$AddBlankLines test' >> ../tests/test.out +../src/remind ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1 +../src/remind '-i$AddBlankLines=1' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1 +../src/remind '-i$AddBlankLines=0' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1 + echo "MON WKDAY DAY across year test" >> ../tests/test.out echo 'REM Mon 29 Dec MSG x' | ../src/remind -dt - 1 Jan 2000 >> ../tests/test.out 2>&1 diff --git a/tests/test.cmp b/tests/test.cmp index b3de0a29..1a470831 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -2723,6 +2723,7 @@ a125 -1 dump $ Variable Value + $AddBlankLines 1 [0, 1] $Ago "ago" $Am "am" $And "and" @@ -6618,6 +6619,37 @@ keyword will[38;2;0 ../tests/ansicolors.rem(41): ansicolor(): Number too low ../tests/ansicolors.rem(42): ansicolor(): Number too high ../tests/ansicolors.rem(43): ansicolor(): Number too low +$AddBlankLines test +Reminders for Saturday, 1st January, 2022: + +$AddBlankLines=1 + +Hello + +Hi + +How are you? + +OK + +Reminders for Saturday, 1st January, 2022: + +$AddBlankLines=1 + +Hello + +Hi + +How are you? + +OK + +Reminders for Saturday, 1st January, 2022: +$AddBlankLines=0 +Hello +Hi +How are you? +OK MON WKDAY DAY across year test -(1): Trig = Monday, 3 January, 2000 No reminders.