From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11738 invoked by alias); 9 Oct 2012 11:28:17 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17312 Received: (qmail 1542 invoked from network); 9 Oct 2012 11:28:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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 autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.219.43 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=IICUheUXnNOhxQdi/O+r69LdKnTOQCmTZeCIz/Sl/jE=; b=EznvlDjO+z2KRnAOVt/wS37yMH0SLUmW2CTq5Eexj9XkD6LlZYQ6mAwjzXJmhots0q FxINwZtS4ubaHgU5TnDmIb9o7RRaZQg9vIuBjVffTeLiRQOn8lHI64vuLdtePhRn/NrT uC5NqXsbfWkRUhZYJPwFYhrdk7vh6WeyafvQE+088KCfapMWkHqMa9xCx/VKvzWjN3iX PT+fBa9CqtgMhAabME5PsJvQgnI4gbOnTLs7KqMLo+dKUTuA3k7PtaEKbaQAG+47esYf GXvk5eDW661KYruDEH8VGLIeURwjDVtjLyju3CkFG31wjg6+WB2+7LpRM+ZpNssbv+bm rnQw== MIME-Version: 1.0 X-Originating-IP: [80.239.194.50] In-Reply-To: References: Date: Tue, 9 Oct 2012 12:22:58 +0100 Message-ID: Subject: Re: bug in replace-string: widget loses characters From: Peter Stephenson To: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmGfZp7ucJecgBewTjY2/vPyY+fApirPrD9066bCmj4PQes+TqOLOCBYV8mQ1GFhhShhHBw On 8 October 2012 19:19, Moritz Bunkus wrote: > zsh 5.0.0 on Arch Linux here. I'm using the replace-string widget and > have the problem that often it loses characters from the current input > when I use it. Not always, but often enough. > > In order to demonstrate what I mean, do the following: > > * Start zsh with --no-rcs: > > sweet-chili% zsh --no-rcs > sweet-chili% zsh --version > zsh 5.0.0 (x86_64-unknown-linux-gnu) > > * load the widget and bind it to a key, e.g. Alt-R: > > sweet-chili% autoload replace-string > sweet-chili% zle -N replace-regex replace-string > sweet-chili% bindkey '^[r' replace-regex > > * Next enter some text with several arguments, don't hit enter. In > this example I've used the following: > > sweet-chili% somecmd 64/ubuntu/precise 64/ubuntu/quantal argab > > * Hit Alt-R. Replace 64 with 32, and the result will be: > > sweet-chili% somecmd 32/ubuntu/precise 32/ubuntu/quantal arga Good news! Your problem is now officially classified as "weird". (To be honest, "weird and interesting" is the one to go for, but we're half way there.) I think it's a problem with "undo". After the function has read the original and replacement strings from the area under the command line, it's supposed to undo all that, so that you don't see it as part of the normal undo history (undo should take you back through the replacement, then immediately back through any changes you made before invoking the replace widget). It looks like that undo can go one change too far, which means I've got the counting of undo changes wrong somewhere. I didn't really properly get to grips with the undo system, so this isn't that surprising. I suppose it's no use hoping anybody else is going to understand it. I'll take a look later. Anyway, it's not a problem with the function itself; you could work around it by removing the "zle undo" line, which will expose the previous unhelpful undo behaviour of the replacement widgets but should mean the replacement itself works OK. pws