Just to make the review easier.

The point I was missing and that made it hard for me to understand how
endword() works:

   If your cursor is already sitting at the end of a word, pressing 'e'
   must jump to the end of the next word.


Let's take a word that ends with a UTF-8 ntilde (\xc3\xb1):

  ++ncursor moves to \xb1:

                while (++ncursor < es->linelen) {
                        uc = es->cbuf[ncursor];

  isspace(\xb1) returns false:

                        if (isspace(uc)) {
                                if (skip_space)
                                        continue;
                                else
                                        break;
                        }

  Tracking state is cleared:

                        skip_space = 0;

  The next round of the loop (uc == ' ') breaks here:

                        if (isspace(uc)) {
                                if (skip_space)
                                        continue;
                                else
                                        break;
                        }


   Finally domove() counts the continuation bytes backward, dragging the
   cursor to the beginning of ntilde '\xc3':

        case 'e':
        case 'E':
                if (!sub && es->cursor + 1 >= es->linelen)
                        return -1;
                ncursor = (*cmd == 'e' ? endword : Endword)(argcnt);
                if (!sub)
                        while (isu8cont((unsigned char)es->cbuf[--ncursor]))
                                continue;
                break;


You're again where you started.  Next time you type 'e' your cursor will
end on that same space. :-)


-- 
Walter

Reply via email to