A while back, I committed a diff that fixed scrolling backwards by paragraph in mg. I thought I would give it a while before writing the corresponding diff for going forwards, just to make sure there were no problems with the first diff.
So here it is. Before you compile this diff, (and if you are using mg) put your cursor on the very first character of the first paragraph - an 'A', then do M-} your cursor stops on the 2nd line. In emacs it would stop on the 5th line. Currently mg stops moving forward when it finds a new line with a space on the first character, this diff checks the whole line before determinig if the line is a paragraph break or not. ok? mark Index: paragraph.c =================================================================== RCS file: /cvs/src/usr.bin/mg/paragraph.c,v retrieving revision 1.24 diff -u -p -r1.24 paragraph.c --- paragraph.c 19 May 2013 10:27:11 -0000 1.24 +++ paragraph.c 1 Jun 2013 05:40:02 -0000 @@ -63,37 +63,32 @@ gotobop(int f, int n) int gotoeop(int f, int n) { + int col; + int nospace = 0; + /* the other way... */ if (n < 0) return (gotobop(f, -n)); /* for each one asked for */ while (n-- > 0) { - /* Find the first word on/after the current line */ - curwp->w_doto = 0; - while (forwchar(FFRAND, 1) && inword() == 0); + while (lforw(curwp->w_dotp) != curbp->b_headp) { + col = 0; + curwp->w_doto = 0; - curwp->w_doto = 0; - curwp->w_dotp = lforw(curwp->w_dotp); + while (col < llength(curwp->w_dotp) && + (isspace(lgetc(curwp->w_dotp, col)))) + col++; - /* and scan forword until we hit a <NL><SP> or ... */ - while (curwp->w_dotp != curbp->b_headp) { - if (llength(curwp->w_dotp) && - lgetc(curwp->w_dotp, 0) != ' ' && - lgetc(curwp->w_dotp, 0) != '.' && - lgetc(curwp->w_dotp, 0) != '\t') { - curwp->w_dotp = lforw(curwp->w_dotp); - curwp->w_dotline++; + if (col >= llength(curwp->w_dotp)) { + if (nospace) + break; } else - break; - } - if (curwp->w_dotp == curbp->b_headp) { - /* beyond end of buffer, cleanup time */ - curwp->w_dotp = lback(curwp->w_dotp); - curwp->w_doto = llength(curwp->w_dotp); - break; - } else + nospace = 1; + + curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_dotline++; + } } /* force screen update */ curwp->w_rflag |= WFMOVE;