diff --git a/contrib/remind-conf-mode/remind-conf-mode.el b/contrib/remind-conf-mode/remind-conf-mode.el index dc4b08cb..bd9148b0 100644 --- a/contrib/remind-conf-mode/remind-conf-mode.el +++ b/contrib/remind-conf-mode/remind-conf-mode.el @@ -164,7 +164,7 @@ (defconst remind-builtin-functions (sort (list "_" "abs" "access" "adawn" "adusk" "ampm" "ansicolor" "args" "asc" - "baseyr" "catch" "catcherr" "char" "choose" "coerce" "columns" "current" "date" + "baseyr" "catch" "catcherr" "char" "choose" "coerce" "columns" "const" "current" "date" "datepart" "datetime" "dawn" "day" "daysinmon" "defined" "dosubst" "dusk" "easterdate" "escape" "eval" "evaltrig" "filedate" "filedatetime" "filedir" "filename" "getenv" "hebdate" "hebday" "hebmon" "hebyear" diff --git a/man/remind.1.in b/man/remind.1.in index 4ac6ece9..7cfeb621 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -3038,7 +3038,7 @@ Equivalent to \fBday(trigdate())\fR. .B $Tm (read-only) Equivalent to \fBmonnum(trigdate())\fR. .TP -.B $Tu (read-only) +.B $Tu (read-only, DATE type) Equivalent to \fBtriguntil()\fR. .TP .B $Tw (read-only) @@ -3400,7 +3400,12 @@ characters occupy two columns. \fBcolumns(str)\fR takes all of that into account. Note that if \fBRemind\fR was compiled without Unicode support, \fBcolumns(str)\fR returns a type mismatch error. .RE - +.TP +.B const(x_arg) +Evaluates \fIarg\fR and returns it, but also ensures that the result +is marked "constant". Use with caution; incorrect use could result +in unwanted reminders being purged in Purge Mode. See also the section +"NON-CONSTANT EXPRESSIONS" .TP .B current() Returns the current date and time as a DATETIME object. This may be the diff --git a/src/expr.c b/src/expr.c index dd8191ae..8dbee2c1 100644 --- a/src/expr.c +++ b/src/expr.c @@ -568,6 +568,10 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) /* All went well; copy the result destructively */ (*ans) = info.retval; + /* Special case of const cunction */ + if (!strcmp(f->name, "const")) { + *nonconst = 0; + } /* Don't allow retval to be destroyed! */ info.retval.type = ERR_TYPE; } diff --git a/src/funcs.c b/src/funcs.c index 3a5e632d..a5717309 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -258,6 +258,7 @@ BuiltinFunc Func[] = { { "choose", 2, NO_MAX, 1, NULL, FChoose }, /*NEW-STYLE*/ { "coerce", 2, 2, 1, FCoerce, NULL }, { "columns", 0, 1, 0, FColumns, NULL }, + { "const", 1, 1, 1, FNonconst, NULL }, { "current", 0, 0, 0, FCurrent, NULL }, { "date", 3, 3, 1, FDate, NULL }, { "datepart", 1, 1, 1, FDatepart, NULL }, diff --git a/tests/test.cmp b/tests/test.cmp index 19345b79..94a17d45 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -20253,6 +20253,7 @@ Timed Untimed Purge Test +../tests/purge_dir/f3.rem(62): Attempt to redefine built-in function: `const' ../tests/purge_dir/f3.rem(76): `/': Division by zero ../tests/purge_dir/f3.rem(76): `/': Division by zero F1 @@ -24460,6 +24461,7 @@ char choose coerce columns +const current date datepart