From d1c1bfe0023f014a4f19db6d459f0677a4561acc Mon Sep 17 00:00:00 2001 From: op Date: Tue, 24 May 2022 16:24:31 +0000 Subject: [PATCH] automatically delete trailing whitespaces on RET in c-mode and auto-indent-mode (only after computing the auto indent.) tested also by Mikhail (thanks!). ok tb@ --- usr.bin/mg/cmode.c | 4 +++- usr.bin/mg/util.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/mg/cmode.c b/usr.bin/mg/cmode.c index 6c0ef5b8975..bd231d12d14 100644 --- a/usr.bin/mg/cmode.c +++ b/usr.bin/mg/cmode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmode.c,v 1.17 2019/07/11 18:20:18 lum Exp $ */ +/* $OpenBSD: cmode.c,v 1.18 2022/05/24 16:24:31 op Exp $ */ /* * This file is in the public domain. * @@ -205,6 +205,8 @@ cc_lfindent(int f, int n) { if (n < 0) return (FALSE); + if (cc_strip_trailp) + (void)delwhite(FFRAND, 1); if (enewline(FFRAND, 1) == FALSE) return (FALSE); return (cc_indent(FFRAND, n)); diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index 4d38284f3b8..06e71358fb0 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.43 2021/03/01 10:51:14 lum Exp $ */ +/* $OpenBSD: util.c,v 1.44 2022/05/24 16:24:31 op Exp $ */ /* This file is in the public domain. */ @@ -373,6 +373,7 @@ lfindent(int f, int n) nicol |= 0x07; ++nicol; } + (void)delwhite(FFRAND, 1); if (lnewline() == FALSE || (( #ifdef NOTAB curbp->b_flag & BFNOTAB) ? linsert(nicol, ' ') == FALSE : ( -- 2.20.1