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

PATCH: bash-transpose-words



This one I definitely plan to use, I've been frustrated by the other one
too often.

Now what I'd really like is for the cursor to stay at the point between the
words it's transposing instead of hopping around after it, but that
requires either doing the whole thing in a shell function, or some trickery
with marks --- which I still don't trust if text has been moving around,
but I haven't analysed what I don't trust well enough to suggest what needs
fixing.

Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.11
diff -u -r1.11 contrib.yo
--- Doc/Zsh/contrib.yo	2001/07/06 17:25:54	1.11
+++ Doc/Zsh/contrib.yo	2001/07/20 10:45:27
@@ -366,15 +366,17 @@
 tindex(bash-backward-word)
 tindex(bash-kill-word)
 tindex(bash-backward-kill-word)
+tindex(bash-transpowse-words)
 xitem(tt(bash-forward-word), tt(bash-backward-word))
-item(tt(bash-kill-word), tt(bash-backward-kill-word))(
+xitem(tt(bash-kill-word), tt(bash-backward-kill-word))
+item(tt(bash-transpose-words))(
 These work similarly to the corresponding builtin zle functions without the
 `tt(bash-)' prefix, but a word is considered to consist of alphanumeric
 characters only.  If you wish to replace your existing bindings with these
 four widgets, the following is sufficient:
 
 example(for widget in kill-word backward-kill-word \ 
-forward-word backward-word; do 
+forward-word backward-word transpose-words; do 
   autoload bash-$widget 
   zle -N $widget bash-$widget
 done)
Index: Functions/Zle/bash-transpose-words
===================================================================
RCS file: bash-transpose-words
diff -N bash-transpose-words
--- /dev/null	Thu May 24 22:33:05 2001
+++ bash-transpose-words	Fri Jul 20 03:45:27 2001
@@ -0,0 +1,9 @@
+# This implements a bash-style transpose-words.
+# To use,
+#   zle -N bash-transpose-words
+#   bindkey '...' bash-transpose-words
+# or if you wish to replace existing transpose-words bindings,
+#   zle -N transpose-words bash-transpose-words
+
+local WORDCHARS=''
+zle .transpose-words

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


**********************************************************************
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 
prohibited.  
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