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

Re: delete-word does not delete the entire word...

Bart Schaefer wrote:
> One question:
> } +local curcontext=:zle:delete-whole-word
> Wouldn't
> 	local curcontext=:zle:$WIDGET
> or
> 	local curcontext=:zle:${WIDGET%-match}
> be better?

Yes.  The former is how all the others work.

Talking of underwhelming responses :-), did anyone ever look at the
additions I posted to match-words-by-style which would allow you to have
different subcontexts in different bits of the command line?  The one
where you could do

   zstyle ':zle:*' word-context "[[:space:]]" whitespace "*/*" \
       filename "" end "*" other
   zstyle ':zle:transpose-words:whitespace' word-style shell
   zstyle ':zle:transpose-words:filename' word-style normal
   zstyle ':zle:transpose-words:filename' word-chars ''

Anyway, I'm not happy with this; I think there must be a better way of
picking context.  For example, instead of putting the onus on the user
to pick out the contexts, it would probably be more natural simply to
extend the existing contexts.  Perhaps something like
"<context>:<pattern>" or "<context>:<wordnum>:<pattern>" where context
is just an alphanumeric string would carry more information.  In other
words, word-context would go and the other styles would look like

   zstyle ':zle:transpose-words:between:<->:*' word-style shell
   zstyle ':zle:transpose-words:word:<->:*/*' word-style normal
   zstyle ':zle:transpose-words:word:<->:*/*' word-chars ''

where that third word would be a set like
  empty		an empty line
  before	the unusual case of whitespace before any text
  word		a shell word, matched by the last element of the style
  between	whitespace between words (next arg is number of word before)
  end		after all words

and the fourth word could be e.g. 1 or <2-> to pick the command word or
not the command word.

Half an input is better than no bread.

Index: Functions/Zle/delete-whole-word-match
RCS file: /cvsroot/zsh/zsh/Functions/Zle/delete-whole-word-match,v
retrieving revision 1.1
diff -u -r1.1 delete-whole-word-match
--- Functions/Zle/delete-whole-word-match	13 Oct 2003 16:50:19 -0000	1.1
+++ Functions/Zle/delete-whole-word-match	13 Oct 2003 17:05:19 -0000
@@ -11,7 +11,7 @@
 emulate -L zsh
 setopt extendedglob
-local curcontext=:zle:delete-whole-word
+local curcontext=:zle:$WIDGET
 local -a matched_words
 # Start and end of range of characters to remove.
 integer pos1 pos2

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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