From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11015 invoked by alias); 23 Jul 2015 05:41:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35869 Received: (qmail 9038 invoked from network); 23 Jul 2015 05:41:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=7/Fj2sT3mFvRXw0VX+OxpscHSLOojJD3to3SQIqAKMg=; b=SioWXMi1GcLdiL1xvoFvCV2tqxxj1YznblVqum/MdyIEOoEjN8ksh9xWxaPR5FYHNz JNgdKc92TG48kcs54mko3w2wiFPGFpw9XBaAR5XUm9VReBezd01V29IllskduQEg4Crh ymKqKmuLG22qFhfYKv8taliuCm9RFm1UoMiKAHsBw/c4ivrB+wjCF/Ocje+MIl7m5lPT PxTXDMk+37nWgfyci3iRaPlLFiA+J0bTubMsi9OScCDD8i4YSTZHnJkEOAWARpAQGhfd VmKeAhYJrA5VoXVCUVpnWrb75xlk8XI2UGT2NSVe03MyK9otYl20URhpSTi0kc1lsDyn ICBQ== X-Gm-Message-State: ALoCoQkT3dXTgzjZf1y3ZBxmSZgRNuHn2AmHF+gSuSJFvpFzNnxooFR+7kpTKkh/rbqAvwDoPAOP X-Received: by 10.60.176.37 with SMTP id cf5mr6090695oec.19.1437630065072; Wed, 22 Jul 2015 22:41:05 -0700 (PDT) From: Bart Schaefer Message-Id: <150722224101.ZM14105@torch.brasslantern.com> Date: Wed, 22 Jul 2015 22:41:01 -0700 In-Reply-To: <9927.1437383950@thecus.kiddle.eu> Comments: In reply to Oliver Kiddle "Re: PATCH: narrow-to-region (was Re: This widget implementation feels a bit clunky)" (Jul 20, 11:19am) References: <150620102144.ZM5618@torch.brasslantern.com> <150718164224.ZM4759@torch.brasslantern.com> <19747.1437278114@thecus.kiddle.eu> <150719012304.ZM18439@torch.brasslantern.com> <9927.1437383950@thecus.kiddle.eu> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Undo and narrow-to-region (was Re: PATCH: narrow-to-region (was ...)) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jul 20, 11:19am, Oliver Kiddle wrote: } Subject: Re: PATCH: narrow-to-region (was Re: This widget implementation f } } My main use of narrow-to-region is to retrieve history lines into the } middle of the current line. And it is just this situation that is } breaking it. When doing: } zle undo $_ntr_changeno } it is falling foul of the first line of unapplychange which is: } if(ch->hist != histline) { } and not undoing enough changes. } } This is a consequence of the fix in 10328. If I comment out the two } lines of undo() which do else break; it appears to work fine and the } problem that 10328 targetted doesn't seem to come back. But it is hard } to know how that was failing at the time. So you mean that part of undo becomes if (unapplychange(prev)) curchange = prev; } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV)); ?? What must be happening is that unapplychange() alters the history line, returns zero, and then is called again with exactly the same struct, which now succeeds on the adjusted history line. Pre-10328, the call to unapplychange() would fail but curchange was moved to ->prev either way, skipping over the change that failed. So the "else break;" looks like paranoia to prevent an infinite loop in the event that unapplychange() fails every time. Which could happen if quietgethist() is a no-op? Perhaps when a line has fallen out of the history because of HISTSIZE? Anyway modulo infinite-loop-prevention, it looks to me as if removing that else-clause is the right thing to do, and similarly in redo() a bit further along. I'll let Oliver do the patch if we all agree.