Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: delete-whole-word-match fails on words starting with -, patch



On Fri, 9 Nov 2007 23:38:55 +0100
"Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
> By that, if you mean the problem with words starting with -, i
> realized it only happens if you call it as kill-whole-word-match.

I should have realised that, but didn't, because I was looking at the
wrong test for *kill*  (the $LASTWIDGET one, which is in the opposite
sense).

> +delete-whole-word-match:53> zle copy-region-as-kill '-test '
> 
> delete-whole-word-match:zle:53: unknown option: test

The penny has finally dropped:  I was also trying it out with words
beginning "--" in a GNUish fashion, which already look like an end of
option list marker, so I didn't see this.

Yes, your patch is entirely correct and the option handling is for
setting the numeric prefix and the widget name locally; these follow the
widget name to distinguish them from options to zle instead of to the
widget call.  Here's a more complete version.  I think the various
places where "$@" gets passed to widgets in ZLE functions are intended
to include options passed, so need to be left alone.

I haven't looked at the other problems yet.

Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.56
diff -u -r1.56 zle.yo
--- Doc/Zsh/zle.yo	19 Apr 2007 14:16:23 -0000	1.56
+++ Doc/Zsh/zle.yo	10 Nov 2007 14:19:19 -0000
@@ -554,7 +554,9 @@
 active.  With the option tt(-w), tt(WIDGET) and related parameters are set
 to reflect the widget being executed by the tt(zle) call.
 
-Any further arguments will be passed to the widget.  If it is a shell
+Any further arguments will be passed to the widget; note that as
+standard argument handling is performed, any general argument list
+should be preceded by tt(-)tt(-).  If it is a shell
 function, these are passed down as positional parameters; for builtin
 widgets it is up to the widget in question what it does with them.
 Currently arguments are only handled by the incremental-search commands,
Index: Functions/Zle/backward-kill-word-match
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/backward-kill-word-match,v
retrieving revision 1.2
diff -u -r1.2 backward-kill-word-match
--- Functions/Zle/backward-kill-word-match	19 Apr 2007 14:16:23 -0000	1.2
+++ Functions/Zle/backward-kill-word-match	10 Nov 2007 14:19:19 -0000
@@ -23,7 +23,7 @@
     if [[ -n $done || $LASTWIDGET = *kill* ]]; then
       CUTBUFFER="$word$CUTBUFFER"
     else
-      zle copy-region-as-kill "$word"
+      zle copy-region-as-kill -- "$word"
     fi
     LBUFFER=$matched_words[1]
   else
Index: Functions/Zle/delete-whole-word-match
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/delete-whole-word-match,v
retrieving revision 1.3
diff -u -r1.3 delete-whole-word-match
--- Functions/Zle/delete-whole-word-match	19 Apr 2007 14:16:23 -0000	1.3
+++ Functions/Zle/delete-whole-word-match	10 Nov 2007 14:19:19 -0000
@@ -9,7 +9,7 @@
 # saved for future yanking in the normal way.
 
 emulate -L zsh
-setopt extendedglob
+setopt extendedglob xtrace
 
 local curcontext=:zle:$WIDGET
 local -a matched_words
@@ -49,7 +49,7 @@
   if [[ $LASTWIDGET = *kill* ]]; then
     CUTBUFFER="$CUTBUFFER$word"
   else
-    zle copy-region-as-kill "$word"
+    zle copy-region-as-kill -- "$word"
   fi
 fi
 BUFFER="${BUFFER[1,pos1]}${BUFFER[pos2,-1]}"
Index: Functions/Zle/kill-word-match
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/kill-word-match,v
retrieving revision 1.3
diff -u -r1.3 kill-word-match
--- Functions/Zle/kill-word-match	19 Apr 2007 14:16:23 -0000	1.3
+++ Functions/Zle/kill-word-match	10 Nov 2007 14:19:19 -0000
@@ -22,7 +22,7 @@
     if [[ -n $done || $LASTWIDGET = *kill* ]]; then
       CUTBUFFER="$CUTBUFFER$word"
     else
-      zle copy-region-as-kill $word
+      zle copy-region-as-kill -- $word
     fi
     RBUFFER=${(j..)matched_words[6,7]}
   else


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author