zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: transpose-words-match (Re: New widget "transpose-segments")
Date: Mon, 11 Jan 2016 22:26:23 -0800	[thread overview]
Message-ID: <160111222623.ZM6334@torch.brasslantern.com> (raw)
In-Reply-To: <CAKc7PVC9TBCVtC=ijqJMtcVqcojEi+4Zf4rW_R_gqDgr4NOvAg@mail.gmail.com>

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.

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.)

} 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.

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.

I see Daniel has also done something for interactive_comments, I'm not
sure whether that's needed in match-words-by-style.  [By the way, Daniel,
(zZ:c:) is redundant, you only need (Z:c:).]

diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style
index b387828..7ba6157 100644
--- a/Functions/Zle/match-words-by-style
+++ b/Functions/Zle/match-words-by-style
@@ -111,20 +111,20 @@ done
 case $wordstyle in
   (*shell*) local bufwords
 	  # This splits the line into words as the shell understands them.
-	  bufwords=(${(z)LBUFFER})
+	  bufwords=(${(Z:n:)LBUFFER})
 	  nwords=${#bufwords}
 	  wordpat1="${(q)bufwords[-1]}"
 
 	  # Take substring of RBUFFER to skip over $skip characters
 	  # from the cursor position.
-	  bufwords=(${(z)RBUFFER[1+$skip,-1]})
+	  bufwords=(${(Z:n:)RBUFFER[1+$skip,-1]})
 	  wordpat2="${(q)bufwords[1]}"
 	  spacepat='[[:space:]]#'
 
 	  # Assume the words are at the top level, i.e. if we are inside
 	  # 'something with spaces' then we need to ignore the embedded
 	  # spaces and consider the whole word.
-	  bufwords=(${(z)BUFFER})
+	  bufwords=(${(Z:n:)BUFFER})
 	  if (( ${#bufwords[$nwords]} > ${#wordpat1} )); then
 	    # Yes, we're in the middle of a shell word.
 	    # Find out what's in front.


  reply	other threads:[~2016-01-12  6:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-09 11:03 New widget "transpose-segments" Sebastian Gniazdowski
2016-01-09 12:19 ` Jérémie Roquet
2016-01-09 15:56   ` Sebastian Gniazdowski
2016-01-09 15:55 ` Sebastian Gniazdowski
2016-01-09 15:57   ` Sebastian Gniazdowski
2016-01-09 17:22 ` Bart Schaefer
2016-01-09 17:48   ` transpose-words-match (Re: New widget "transpose-segments") Bart Schaefer
2016-01-09 18:03     ` Sebastian Gniazdowski
2016-01-09 18:18       ` Bart Schaefer
2016-01-11 13:13         ` Sebastian Gniazdowski
2016-01-12  6:26           ` Bart Schaefer [this message]
2016-01-12  6:46             ` Bart Schaefer
2016-01-12  9:09               ` Sebastian Gniazdowski
2016-01-12  9:39                 ` Sebastian Gniazdowski
2016-01-12  9:23             ` Sebastian Gniazdowski
2016-01-12  9:38               ` Sebastian Gniazdowski
2016-01-12  9:46               ` Peter Stephenson
2016-01-12 19:12               ` Bart Schaefer
2016-01-09 17:59   ` New widget "transpose-segments" Sebastian Gniazdowski
2016-01-09 19:06     ` Sebastian Gniazdowski
2016-01-12  8:13       ` Bart Schaefer
2016-01-12  8:09     ` Bart Schaefer
2016-01-12  9:50       ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160111222623.ZM6334@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).