Subject: Re: "drop-in replacement" and transpose-words-match
From: Bart Schaefer <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Mon, 18 Jan 2016 22:31:26 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Jan 18,  6:04pm, Sebastian Gniazdowski wrote:
}
} My point is: isn't it that sticking to LBUFFER is the source of
} various problems? Its use is always more or less hackish and has
} effects like "you should position cursor on beginning of a word to
} swap it". Implementation generates features while it should be the
} opposite.

Sorry, I can't agree.  By *FAR* the most common editing operation is
to either either insert or delete to the left of the cursor position,
which means at the end of LBUFFER.

Furthermore, zew-process-buffer always manipulates whatever the (z)
flag's idea of a "word" is, which [as the "bufferwords()" thread has
demonstrated] is somewhat tenuously defined, and may not correspond
to what the user wants to consider a "word" (see e.g. $WORDCHARS).

[I would probably save CURSOR and MARK, set CURSOR to zero, then loop
on "zle forward-word" until I reached or passed the old CURSOR, rather
than try to match up the results of (Z:n:) to $BUFFER.  Then restore
CURSOR and MARK, of course.]