All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlo Caione <carlo.caione@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH] Autocomplete fix
Date: Thu, 25 Aug 2011 16:40:36 -0700	[thread overview]
Message-ID: <4E56DD74.4070102@gmail.com> (raw)

Autocomplete fixed: now working also to autocomplete file names as first 
argument.

i.e.:

# ./en<TAB> completes to # ./env/

Signed-off-by: Carlo Caione <carlo.caione@gmail.com>
---
  common/complete.c |   13 +++++++++----
  1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/complete.c b/common/complete.c
index 46ba871..543e649 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -71,6 +71,7 @@ static int command_complete(struct string_list *sl, 
char *instr)
  {
  	struct command *cmdtp;
  	char cmd[128];
+	int found = 0;

  	for_each_command(cmdtp) {
  		if (!strncmp(instr, cmdtp->name, strlen(instr))) {
@@ -78,10 +79,11 @@ static int command_complete(struct string_list *sl, 
char *instr)
  			cmd[strlen(cmdtp->name)] = ' ';
  			cmd[strlen(cmdtp->name) + 1] = 0;
  			string_list_add(sl, cmd);
+			found = 1;
  		}
  	}

-	return 0;
+	return(found);
  }

  static int tab_pressed = 0;
@@ -116,13 +118,16 @@ int complete(char *instr, char **outstr)

  	instr = t;

-	/* get the completion possibilities */
  	if ((t = strrchr(t, ' '))) {
  		t++;
  		file_complete(&sl, t);
  		instr = t;
-	} else
-		command_complete(&sl, instr);
+	} else {
+		if(!command_complete(&sl, instr)){	
+			file_complete(&sl, instr);
+		}
+	}
+		

  	pos = strlen(instr);

-- 
1.7.6.1

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2011-08-25 23:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 23:40 Carlo Caione [this message]
2011-08-26  7:47 ` [PATCH] Autocomplete fix Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E56DD74.4070102@gmail.com \
    --to=carlo.caione@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.