From 089ec08b3cb17edf37bda0d17a60adf446f40305 Mon Sep 17 00:00:00 2001 From: lum Date: Tue, 20 Apr 2021 16:34:20 +0000 Subject: [PATCH] Indicate if an mg function is unsuitable for a startup file (requires user interaction). --- usr.bin/mg/funmap.c | 8 ++++---- usr.bin/mg/interpreter.c | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c index b9207c6b772..c6c59272ed8 100644 --- a/usr.bin/mg/funmap.c +++ b/usr.bin/mg/funmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: funmap.c,v 1.61 2021/04/20 10:02:50 lum Exp $ */ +/* $OpenBSD: funmap.c,v 1.62 2021/04/20 16:34:20 lum Exp $ */ /* This file is in the public domain */ @@ -34,7 +34,7 @@ static struct funmap *funs; * 0 = a toggle, non-modifiable insert/delete, region modifier, etc * 1 = value can be string or number value (like: file/buf name, search string) * 2 = multiple type value required, see auto-execute, or global-set-key, etc - * -1 = variable length # parameters (unused at moment) + * -1 = error: interactive commmand, unsuitable for interpreter * * Some functions when used interactively may ask for a 'y' or 'n' (or another * character) to continue, in excline, a 'y' is assumed. Functions like this @@ -168,9 +168,9 @@ static struct funmap functnames[] = { {prevwind, "previous-window", 0}, {spawncli, "push-shell", 0}, {showcwdir, "pwd", 0}, - {queryrepl, "query-replace", 1}, + {queryrepl, "query-replace", -1}, #ifdef REGEX - {re_queryrepl, "query-replace-regexp", 1}, + {re_queryrepl, "query-replace-regexp", -1}, #endif /* REGEX */ {quote, "quoted-insert", 1}, #ifdef REGEX diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c index e41da1c3696..3d6500be032 100644 --- a/usr.bin/mg/interpreter.c +++ b/usr.bin/mg/interpreter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interpreter.c,v 1.21 2021/04/20 14:26:19 lum Exp $ */ +/* $OpenBSD: interpreter.c,v 1.22 2021/04/20 16:34:20 lum Exp $ */ /* * This file is in the public domain. * @@ -370,6 +370,9 @@ parsexp(char *begp, const char *par1, const char *par2, int blkid, int expctr) if (numparams == 0) return (dobeep_msgs("Command takes no arguments:", cmdp)); + if (numparams == -1) + return (dobeep_msgs("Interactive command found:", cmdp)); + if ((e1 = malloc(sizeof(struct expentry))) == NULL) { cleanup(); return (dobeep_msg("malloc Error")); -- 2.20.1