This patch to elogapply() silences "elogapply: can't happen ..." messages that occur under the following somewhat rare circumstance: 1. a text selection near the end of file, 2. a command is executed that replaces the selected text, and 3. the length of the replacement text is sufficiently smaller than the selection. This can result in the saved 'q0'/'q1' value exceeding the new buffer cache length, even though the textdelete call did the right thing. The proposed change updates 'q0' and 'q1' after the call to textdelete under "case Delete". It doesn't appear to break anything, but I am by no means a 'power' acme user, so further investigation would be prudent. "Case Replace" may also require some fiddling but I couldn't figure out how to exercise that case. Notes: Wed Mar 23 14:41:57 EST 2005 rsc Thank you for sending instructions to reproduce this problem! I've never been able to do that. Your patch treated the symptom instead of the actual disease. I finally understand the disease and I think I've cured it. New version on sources. Russ Reference: /n/sources/patch/sorry/acme-elog Date: Wed Mar 23 08:04:08 CET 2005 Reviewed-by: rsc --- /sys/src/cmd/acme/elog.c Wed Mar 23 08:03:50 2005 +++ /sys/src/cmd/acme/elog.c Wed Mar 23 08:03:41 2005 @@ -284,6 +284,8 @@ } textconstrain(t, b.q0, b.q0+b.nd, &tq0, &tq1); textdelete(t, tq0, tq1, TRUE); + q0 = t->q0; + q1 = t->q1; break; case Insert: