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

[PATCH] bash-style completion



Hi,

I installed zsh 3.0.5 today and immediately liked it a lot better than
bash2, which I'd previously been using. The only zsh feature I dislike
is the csh-style completion (TAB to complete the unambiguous prefix,
^D to list possible completions), so I hacked zsh to provide
bash-style completion (TAB completes the unambiguous prefix, TAB again
lists possible completions). Patches against 3.0.5 are attached. Hope
they can be of use.

The patches also fix a minor bug (lastambig was not being reset when
the completion list is invalidated).

To use bash-style completion, just bind your favorite key to
'complete-or-list'. I use 'bindkey \\t complete-or-list'.

OBTW, I put completeorlist() at the end of zle_tricky.c because it
uses lastambig. There's probably a cleaner way, e.g. defining
COMP_COMPLETE_OR_LIST and doing the dirty work (all four lines of it)
within do_complete().

Oh, and I'm not on the list, so please Cc: me any questions or
comments.

DES
-- 
Dag-Erling Smørgrav - des@xxxxxxxxxxxxxxxxx

--- zle.h.orig	Tue Jun  3 07:11:24 1997
+++ zle.h	Wed Feb  3 18:48:03 1999
@@ -291,6 +291,7 @@
     z_beginningoflinehist,
     z_capitalizeword,
     z_clearscreen,
+    z_completeorlist,
     z_completeword,
     z_copyprevword,
     z_copyregionaskill,
--- zle_bindings.c.orig	Fri Jun 28 15:43:51 1996
+++ zle_bindings.c	Wed Feb  3 18:46:08 1999
@@ -51,6 +51,7 @@
     {"beginning-of-line-hist", beginningoflinehist, ZLE_MOVEMENT},
     {"capitalize-word", capitalizeword, 0},
     {"clear-screen", clearscreen, ZLE_MENUCMP},
+    {"complete-or-list", completeorlist, ZLE_MENUCMP},
     {"complete-word", completeword, ZLE_MENUCMP},
     {"copy-prev-word", copyprevword, 0},
     {"copy-region-as-kill", copyregionaskill, ZLE_KILL},
--- zle_tricky.c.orig	Wed Feb  3 18:49:08 1999
+++ zle_tricky.c	Wed Feb  3 22:09:29 1999
@@ -2998,7 +2998,7 @@
 	if (ccmain != &cc_dummy)
 	    freecompctl(ccmain);
     }
-    menucmp = showinglist = validlist = 0;
+    menucmp = showinglist = validlist = lastambig = 0;
     menucur = NULL;
 }
 
@@ -3968,4 +3968,20 @@
 	deletechar();		/* delete the added space. */
     }
     remove_at = -1;
+}
+
+/**/
+void
+completeorlist(void)
+{
+    usemenu = isset(MENUCOMPLETE);
+    useglob = isset(GLOBCOMPLETE);
+    if (c == '\t' && usetab())
+	selfinsert();
+    else {
+	if (lastambig)
+	    docomplete(COMP_LIST_COMPLETE);
+	else
+	    docomplete(COMP_COMPLETE);
+    }
 }



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