From: op Date: Mon, 8 Jul 2024 14:33:29 +0000 (+0000) Subject: mg: fix auto-indent-mode with custom tab widths X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e0c4ea72833a8372f60e408e801051df76e33274;p=openbsd mg: fix auto-indent-mode with custom tab widths dointent() didn't know about set-tab-width so it was mis-indenting the lines. Diff from Mark Willson (mark dot willson at hydrus.org.uk), with a tiny change by me. --- diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index dd42085a24a..19b19a5b5a4 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.50 2023/04/28 10:02:03 op Exp $ */ +/* $OpenBSD: util.c,v 1.51 2024/07/08 14:33:29 op Exp $ */ /* This file is in the public domain. */ @@ -354,9 +354,9 @@ doindent(int cols) if (curbp->b_flag & BFNOTAB) return (linsert(cols, ' ')); - if ((n = cols / 8) != 0 && linsert(n, '\t') == FALSE) + if ((n = cols / curbp->b_tabw) != 0 && linsert(n, '\t') == FALSE) return (FALSE); - if ((n = cols % 8) != 0 && linsert(n, ' ') == FALSE) + if ((n = cols % curbp->b_tabw) != 0 && linsert(n, ' ') == FALSE) return (FALSE); return (TRUE); }