From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18928 invoked by alias); 12 Jan 2016 09:23:59 -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: 37580 Received: (qmail 14912 invoked from network); 12 Jan 2016 09:23:58 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=SV74K+yf2IMnNbIuHFS7ZbCK3LASctvnic/EID+72zA=; b=LyYeyA0J71YlUp664/1Iu3mQl/0QAWqTeLlD9LZcGWFVIw4AExtMKSrmWApY3UnZpt joUQw508Ml2oun+rFcg68gWBzZkjmz9UVmDWs6MJ18YsKIIZDznTIvC6qrsSqDYA9fNw IFVPRxL2ZOStbDpBjFMs4dO8B53xqHMYeraBAZzYRw3U85BJiq5pkDFbWThgmMkOx0VV vrRLs4z/vkPzCwaRvNPS8QlFl0HNRrRw6TGLNbbrYq9c9TZyOxRrdlhY6S/EF/HaB+PG I1kPBgiEdVEygYvy2i16bYA+HahQeJ1/BHTICZXDx8wFAFvQXP3fh8x7+DvO5GqFhWKE GZTA== X-Received: by 10.112.64.5 with SMTP id k5mr30009409lbs.133.1452590636011; Tue, 12 Jan 2016 01:23:56 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <160111222623.ZM6334@torch.brasslantern.com> References: <160109092258.ZM3394@torch.brasslantern.com> <160109094833.ZM3453@torch.brasslantern.com> <160109101801.ZM3561@torch.brasslantern.com> <160111222623.ZM6334@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Tue, 12 Jan 2016 10:23:36 +0100 Message-ID: Subject: Re: transpose-words-match (Re: New widget "transpose-segments") To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12 January 2016 at 07:26, Bart Schaefer wrot= e: > On Jan 11, 2:13pm, Sebastian Gniazdowski wrote: > } > } Bart there already is "copy-prev-shell-word". It's good to not be > } bound to global select-word-style setting. > > Just for the record, although there is a global select-word-style > setting for convenience, you can also select different word styles > for different contexts. There are a few examples in the manual. > > The word styles can also handle things like swapping CapsLikeThis > to CapsThisLike where the only "word break" is a case difference. Tried googling but no success. Could you give name of the man page and what to look for? > Further, copy-prev-shell-word is a built-in widget; and it appears to > have a bug when the previous shell word is a single character with no > whitespace between it and the cursor. (The transpose-words builtin > has a similar difficulty with one-character words, I think.) Really a bug, it reproduces here. Yesterday I switched to copy-earlier-word (still bind copy-prev-shell-word to ^[M). It integrates with insert-last-word and allows to copy arbitrary word from arbitrary previous history event. For the record: bindkey "^[." insert-last-word autoload -Uz copy-earlier-word zle -N copy-earlier-word bindkey "^[m" copy-earlier-word It's interesting that insert-last-word operates on shell words although this is not stated in manual. > } That said I tested your bksw and it doesn't fully work for following > [...] > } There is a space after "". When cursor is positioned after this space, > } invoking bksw joins lines "" and a\ b instead of deleting "". > > select-in-shell-word is intended to emulate some vim functionality that > excludes quotes (only selects what's inside them) so empty quotes might > be expected to confuse it. Other lines, when ended with space, will also cause the unexpected behavior. I should have stated this that it's about space at the end. > I have to thank you for this example, because it allowed me to realize > why newlines confuse match-words-by-style. It needs to be using the > (Z:n:) flag rather than the (z) flag; the latter converts newlines into > semicolons, but this wants newlines as whitespace. Cool. I tested transpose-words with shell word style and now it works on the multi line command I gave, e.g. I can transpose 'a\ b' with '""' when I position cursor at 'a'. I've missed the (Z) flag, wrote much code in transpose-shell-words to track which arguments correspond to which spaces to be able to glue the command back, and had to handle the "\n" -> ";" semicolons which complicated things. Seems that (Z:n:) would discard the new lines like any other white spaces and the code would be simpler. And this works even in zsh 4.3.17. BTW. I discovered that following multi line command can make various versions of zsh hang on it: a=3D${(j:,:)a} a=3D"${(r:100000:: _:)a}" =E8=A9=A6=E5=8F=A5=E7=9B=B8=E7=95=B6=E9=95=B7 "" a\ b c\ b Does it reproduce to you? It was fully reproducible on my setup however first it started to work for a second - and I thought that it's connected to $SHLVL>1, then it worked again, and then pasting broke up in my terminal, and I thought it might be connected to zle -N self-insert url-quote-magic. Now pasting works and again it hangs zsh-5.2-dev-0 and 5.0.8, even when I provide it with history operations (cursor up). However, $SHLVL has to be 2 or more. Best regards, Sebastian Gniazdowski