From 5e333f6162bf86c866e3a9602b4049e229ef91a2 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Fri, 13 Dec 2024 08:18:22 -0500 Subject: [PATCH] Add the SYSINCLUDE directive. --- contrib/remind-conf-mode/remind-conf-mode.el | 3 ++- man/remind.1.in | 11 ++++++++--- src/calendar.c | 1 + src/files.c | 17 +++++++++++++---- src/main.c | 1 + src/token.c | 1 + src/types.h | 2 +- tests/test.cmp | 1 + 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/contrib/remind-conf-mode/remind-conf-mode.el b/contrib/remind-conf-mode/remind-conf-mode.el index 7df69d55..3fe4c66b 100644 --- a/contrib/remind-conf-mode/remind-conf-mode.el +++ b/contrib/remind-conf-mode/remind-conf-mode.el @@ -117,7 +117,8 @@ "NOQUEUE" "OMIT" "OMITFUNC" "ONCE" "POP" "POP-OMIT-CONTEXT" "PRESERVE" "PRIORITY" "PS" "PSFILE" "PUSH" "PUSH-OMIT-CONTEXT" "REM" "RUN" "SATISFY" "SCAN" "SCANFROM" "SCHED" "SECOND" "SET" "SKIP" "SPECIAL" - "TAG" "THIRD" "THROUGH" "TRANSLATE" "TRANS" "UNSET" "UNTIL" "WARN") + "SYSINCLUDE" "TAG" "THIRD" "THROUGH" "TRANSLATE" "TRANS" "UNSET" + "UNTIL" "WARN") #'(lambda (a b) (> (length a) (length b))))) diff --git a/man/remind.1.in b/man/remind.1.in index ab6e122e..72602fe8 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -1924,7 +1924,7 @@ the first day of the month. The local \fBOMIT\fR keyword causes the Finally, the \fBAFTER\fR keyword will keep moving the reminder forward until it has passed any holidays specified with global \fBOMIT\fR commands. -.SH THE DO AND INCLUDE COMMANDS +.SH THE DO, INCLUDE AND SYSINCLUDE COMMANDS .PP \fBRemind\fR allows you to include other files in your reminder script, similar to the C preprocessor #include directive. For example, your @@ -1981,6 +1981,11 @@ symbolic link itself, \fBDO\fR will fail. \fBRemind\fR does \fInot\fR resolve the real path of symbolic links, so you should avoid using symbolic links to files. .PP +The \fBSYSINCLUDE\fR command is similar to \fBDO\fR, but it looks for +relative pathnames under the system directory containing standard reminder +scripts. For thie version of \fBRemind\fR, the system directory is +"@prefix@/share/remind". +.PP .SH THE RUN COMMAND .PP If you include other files in your reminder script, you may not always @@ -5804,14 +5809,14 @@ To use a language pack (in this example, de.rem), simply place this at the top of your reminders file: .PP .nf - INCLUDE [$SysInclude]/lang/de.rem + SYSINCLUDE lang/de.rem .fi .PP If you want \fBRemind\fR to try to find the language pack appropriate for your locale settings, use: .PP .nf - INCLUDE [$SysInclude]/lang/auto.rem + SYSINCLUDE lang/auto.rem .fi .PP You are encouraged to study the language packs to see how to translate diff --git a/src/calendar.c b/src/calendar.c index 916246cf..2e05e922 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -1708,6 +1708,7 @@ static void GenerateCalEntries(int col) case T_EndIf: r=DoEndif(&p); break; case T_Include: + case T_IncludeSys: case T_IncludeR: r=DoInclude(&p, tok.type); break; case T_IncludeCmd: r=DoIncludeCmd(&p); break; diff --git a/src/files.c b/src/files.c index b1819b4e..2b649fe7 100644 --- a/src/files.c +++ b/src/files.c @@ -612,12 +612,21 @@ int DoInclude(ParsePtr p, enum TokTypes tok) e = VerifyEoln(p); if (e) Eprint("%s", GetErr(e)); - if (tok == T_IncludeR && *(DBufValue(&buf)) != '/') { + if ((tok == T_IncludeR || tok == T_IncludeSys) && + *(DBufValue(&buf)) != '/') { /* Relative include: Include relative to dir containing current file */ - if (DBufPuts(&path, FileName) != OK) { - r = E_NO_MEM; - goto bailout; + if (tok == T_IncludeR) { + if (DBufPuts(&path, FileName) != OK) { + r = E_NO_MEM; + goto bailout; + } + } else { + if (DBufPuts(&path, SysDir) != OK || + DBufPutc(&path, '/') != OK) { + r = E_NO_MEM; + goto bailout; + } } if (DBufLen(&path) == 0) { s = DBufValue(&buf); diff --git a/src/main.c b/src/main.c index 56e5683d..7555d1f7 100644 --- a/src/main.c +++ b/src/main.c @@ -314,6 +314,7 @@ static void DoReminders(void) case T_EndIf: r=DoEndif(&p); break; case T_Include: case T_IncludeR: + case T_IncludeSys: /* In purge mode, include closes file, so we need to echo it here! */ if (PurgeMode) { diff --git a/src/token.c b/src/token.c index a29267d5..0174d0a6 100644 --- a/src/token.c +++ b/src/token.c @@ -107,6 +107,7 @@ Token TokArray[] = { { "skip", 4, T_Skip, SKIP_SKIP }, { "special", 7, T_RemType, PASSTHRU_TYPE }, { "sunday", 3, T_WkDay, 6 }, + { "sysinclude", 10, T_IncludeSys, 0 }, { "tag", 3, T_Tag, 0 }, { "third", 5, T_Ordinal, 2 }, { "through", 7, T_Through, 0 }, diff --git a/src/types.h b/src/types.h index c38e1bd2..68107ee6 100644 --- a/src/types.h +++ b/src/types.h @@ -215,7 +215,7 @@ enum TokTypes T_Date, T_DateTime, T_Day, T_Debug, T_Delta, T_Dumpvars, T_Duration, T_Else, T_Empty, T_EndIf, T_ErrMsg, T_Exit, T_Expr, T_Flush, T_Frename, T_Fset, T_Funset, T_If, T_IfTrig, T_In, - T_Include, T_IncludeCmd, T_IncludeR, T_LastBack, T_LongTime, + T_Include, T_IncludeCmd, T_IncludeR, T_IncludeSys, T_LastBack, T_LongTime, T_MaybeUncomputable, T_Month, T_NoQueue, T_Number, T_Omit, T_OmitFunc, T_Once, T_Ordinal, T_Pop, T_Preserve, T_Priority, T_Push,T_Rem, T_RemType, T_Rep, T_Scanfrom, T_Sched, T_Set, T_Skip, T_Tag, T_Through, diff --git a/tests/test.cmp b/tests/test.cmp index 0dc4f303..a93848a8 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -23942,6 +23942,7 @@ second set skip special +sysinclude tag third through