Hello,
When you want to change CDROM, and you have 2 files in the directory called
mandriva-linux-2008.0-free-rc2-CD1.i586.iso and
mandriva-linux-2008.0-free-rc2-CD2.i586.iso, you have to enter
mandriva-linux-2008.0-free-rc2-CD2 by hand and only get completion on
.i586.iso which is not really helpful.

The attached patch gets the common prefix so that you can do man<TAB>2<TAB>
Index: readline.c
===================================================================
RCS file: /sources/qemu/qemu/readline.c,v
retrieving revision 1.5
diff -u -r1.5 readline.c
--- readline.c	17 Sep 2007 08:09:45 -0000	1.5
+++ readline.c	22 Sep 2007 13:35:18 -0000
@@ -300,7 +300,7 @@
 
 static void term_completion(void)
 {
-    int len, i, j, max_width, nb_cols;
+    int len, i, j, max_width, nb_cols, max_prefix;
     char *cmdline;
 
     nb_completions = 0;
@@ -327,11 +327,26 @@
     } else {
         term_printf("\n");
         max_width = 0;
+        max_prefix = 0;	
         for(i = 0; i < nb_completions; i++) {
             len = strlen(completions[i]);
+            if (i==0) {
+                max_prefix = len;
+            } else {
+                if (len < max_prefix)
+                    max_prefix = len;
+                for(j=0; j<max_prefix; j++) {
+                    if (completions[i][j] != completions[0][j])
+                        max_prefix = j;
+                }
+            }
             if (len > max_width)
                 max_width = len;
         }
+        if (max_prefix > 0) 
+            for(i = completion_index; i < max_prefix; i++) {
+                term_insert_char(completions[0][i]);
+            }
         max_width += 2;
         if (max_width < 10)
             max_width = 10;

Reply via email to