Mark Willson <mark.will...@hydrus.org.uk> wrote: > Hi, > > When the tab width is other than 8, auto-indent-mode can > miscompute the indentation column. E.g. when (set-tab-width 4): > > aaaa > bbbb > cccc > . > ^ > | > Cursor positioned here following return after cccc > > This seems to be due to the value 8 being hard-coded in the the > doindent function in util.c. This patch appears to fix the issue: > > --- util.c.orig Tue Jul 2 08:10:09 2024 > +++ util.c Tue Jul 2 08:11:32 2024 > @@ -354,9 +354,10 @@
Unfortunately the diff is mangled. Your MUA changed the spaces to some fancy unicode space and also folded the lines. Also, we don't need to reach the current buffer via curwp->w_bufp, we can use curbp instead. Here's what I've committed: diff /usr/src commit - 4c7d098a070e7b62a8fa6d4ab5c28a4665fbc9af path + /usr/src blob - dd42085a24a8075c6182dc9a3bb04d73cde0184f file + usr.bin/mg/util.c --- usr.bin/mg/util.c +++ usr.bin/mg/util.c @@ -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); } Thanks, Omar Polo