From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19797 invoked by alias); 20 Jul 2015 16:29:31 -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: 35840 Received: (qmail 22346 invoked from network); 20 Jul 2015 16:29:29 -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=0SkxSXO/+npkM6gwtsA4fNRBQHItN4KtfI5b1lCF9Ao=; b=aWdmolPxUt5YLRzuVgEBH5qW083IgEqqyEXTmXw94IpWBrF8sl0jpjr6bEwO49tRzt WXle+29WyHCG/yR0UAfGM+RXrMHk4D3VxKMS20wo4uAlmp8qkmpf+jWu6aDPyvlah3uX XgDlOfiU8FjW0qXDkWVKaqmCWCP5oBdgrh2knmAy3LWuDVr/HITB3oB4JLa3HBbTUIBn ld28/ZlT6MZgBuEHCrZJBiqDlJEj8kCvvXjXQfA9e/6AFEQymyMmjZRRzinCDcL6bt3F PB9DfZ1ZClMlxwCOJvoTzTjaWWmSzan04g/IESTspr+Ez0XXZOv2rItnF0PnwGAn9Rdx xdGg== X-Gm-Message-State: ALoCoQnscQKAX2aFMBXuW2kANDpUbBNHPEQcmOyXcZem6DhtSc1PPLx4g0ustnb2GF0WyJt9UNpm X-Received: by 10.182.142.202 with SMTP id ry10mr26867471obb.27.1437409764758; Mon, 20 Jul 2015 09:29:24 -0700 (PDT) From: Bart Schaefer Message-Id: <150720092920.ZM13868@torch.brasslantern.com> Date: Mon, 20 Jul 2015 09:29:20 -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: Re: PATCH: narrow-to-region (was Re: This widget implementation feels a bit clunky) 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 } } Bart wrote: } > } It'd also be good for the function to use the new undo limit features. } > } > I was going to send a follow-up message about undo-ing and whether a call } > to split-undo is needed before (and/or after) the recursive-edit. } } It is needed immediately after you've setup PREDISPLAY and emptied } BUFFER. The sourceforge outage is getting a bit annoying with respect to passing these patches back and forth. } > Related, should -S / -R implicitly set undo points? } } I've never used those two options and am not sure I quite understand } what they're for. At least not without digging in the archives. With the } patch below, it is fairly obviously broken for them because } _ntr_changeno is set in a different block from the one which does zle } undo to revert to it. The -S and -R options are basically a hack to because there's no good way to do a callback mechansim. What you'd like is to replace recursive-edit with a call back into the invoking scope, but you can't do that without real closures or at least real namerefs, so "narrow-to-region -S" does everything up to recursive-edit and then saves state, followed by -R which restores state and picks up where -S left off. If you introduce new variables _ntr_savelim and _ntr_changeno those are going to have to be added to the state save/restore, or else they have to be localized to the part where recursive-edit is called and NOT the parts where state is saved/restored. Also this -- } PREDISPLAY=$_ntr_predisplay } POSTDISPLAY=$_ntr_postdisplay } - LBUFFER="$_ntr_lbuffer$BUFFER" } - RBUFFER="$_ntr_rbuffer" } + LBUFFER="$_ntr_lbuffer$_ntr_newlbuf" } + RBUFFER="$_ntr_newrbuf$_ntr_rbuffer" } MARK=${#_ntr_lbuffer} -- breaks MARK and CURSOR again, you need LBUFFER="$_ntr_lbuffer$_ntr_newlbuf$_ntr_newrbuf" RBUFFER="$_ntr_rbuffer" to get CURSOR in the right place. Which means you may as well not save the left and right buffers separately to begin with.