aboutsummaryrefslogtreecommitdiffhomepage
path: root/make_completions.py
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-04-22 20:14:14 +1000
committerGravatar axel <axel@liljencrantz.se>2007-04-22 20:14:14 +1000
commit176c1a487b89d4450be47f921034571233ab1740 (patch)
tree1d6d62c46e70578ac31f7a2bf1d148e43e9babaa /make_completions.py
parent2872df66d70556b9f655c4a33ee3538674f554df (diff)
Minor improvements to the completion generator and gcc completions
darcs-hash:20070422101414-ac50b-07612cd287d524a361e358369732c26fc9ff3b67.gz
Diffstat (limited to 'make_completions.py')
-rwxr-xr-xmake_completions.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/make_completions.py b/make_completions.py
index ec20470f..cee4698a 100755
--- a/make_completions.py
+++ b/make_completions.py
@@ -10,7 +10,7 @@ def escape_quotes(s):
def escape(s):
return re.sub('([\'"#%*?])', r"\\\1", s)
-def print_completion( cmd, switch_name, desc ):
+def print_completion( cmd, switch_name, arg, desc ):
offset=1
switch_type = "o"
@@ -22,7 +22,15 @@ def print_completion( cmd, switch_name, desc ):
switch_type = "l"
offset=2
- print "complete -c %s -%s %s --description '%s'" % (cmd, switch_type, escape( switch_name[offset:] ), escape_quotes(desc))
+ arg_str = ""
+ if arg == None:
+ pass
+ elif arg == "standard":
+ arg_str = "-a 'c89 c99 gnu89 gnu99 c++98 gnu++98'"
+ else:
+ pass
+
+ print "complete -c %s -%s %s %s --description '%s'" % (cmd, switch_type, escape( switch_name[offset:] ), arg_str, escape_quotes(desc))
def clean_whitespace( str ):
clean_whitespace_prog0 = re.compile( r"-[ \t]*\n[ \t\r]+" )
@@ -45,6 +53,9 @@ prog1 = re.compile(re1, re.MULTILINE)
re2 = r"^(|=[^ ]*)( |\n)*(?P<switch>-[^ =./\n]+)( *[^-\n ]*\n|)"
prog2 = re.compile(re2, re.MULTILINE)
+re3 = r"^=(?P<arg>[^ ]*)"
+prog3 = re.compile(re2, 0)
+
while True:
match = prog1.search( remainder )
@@ -74,14 +85,21 @@ while True:
rem2 = rem2[match2.end():]
+ match_arg = prog3.search( rem2 )
+ arg = None
+
+ if match_arg != None:
+ arg = match_arg.expand( r"\g<arg>" )
+ rem2 = rem2[match_arg.end():]
+
desc = clean_whitespace(rem2)
- if len( desc) > 8:
+ if len( desc) > 8 and arg != None:
# print "Yay desc '%s'!!\n" % desc
for i in switch:
- print_completion( cmd, i, desc )
+ print_completion( cmd, i, arg, desc )
remainder = remainder[match.end():]