<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.computercraft.info/wiki/index.php?action=history&amp;feed=atom&amp;title=Shell.setCompletionFunction</id>
		<title>Shell.setCompletionFunction - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.computercraft.info/wiki/index.php?action=history&amp;feed=atom&amp;title=Shell.setCompletionFunction"/>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;action=history"/>
		<updated>2026-07-11T09:34:50Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7085&amp;oldid=prev</id>
		<title>Bomb Bloke at 12:14, 29 June 2015</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7085&amp;oldid=prev"/>
				<updated>2015-06-29T12:14:12Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 12:14, 29 June 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|examples=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|examples=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Example&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Example&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|desc=Registers a function which handles tab completion behaviour for a hypothetical &amp;quot;would&amp;quot; script &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;in a directory titled &amp;quot;folder&amp;quot;&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|desc=Registers a function which handles tab completion behaviour for a hypothetical &amp;quot;would&amp;quot; script.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|code=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|code=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; local parameters = { [&amp;quot;you &amp;quot;] = { [&amp;quot;please &amp;quot;] = { [&amp;quot;listen&amp;quot;] = {}, [&amp;quot;look &amp;quot;] = { [&amp;quot;up&amp;quot;] = {}, [&amp;quot;down&amp;quot;] = {} },&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; local parameters = { [&amp;quot;you &amp;quot;] = { [&amp;quot;please &amp;quot;] = { [&amp;quot;listen&amp;quot;] = {}, [&amp;quot;look &amp;quot;] = { [&amp;quot;up&amp;quot;] = {}, [&amp;quot;down&amp;quot;] = {} },&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; shell.setCompletionFunction(&amp;quot;would&amp;quot;, tabCompletionFunction)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; shell.setCompletionFunction(&amp;quot;would&amp;quot;, tabCompletionFunction)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|output=If the user enters &amp;quot;would&amp;quot; into the CraftOS shell after running this code, assuming that file exists, various silly sentences will be suggested as they type further (use up/down to cycle through the suggestions).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|output=If the user enters &amp;quot;would&amp;quot; into the CraftOS shell after running this code, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''&lt;/ins&gt;assuming that file exists,&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'' &lt;/ins&gt;various silly sentences will be suggested as they type further (use up/down to cycle through the suggestions).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:API_Functions]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:API_Functions]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key ccraft_wiki-mw_:diff:version:1.11a:oldid:7084:newid:7085 --&gt;
&lt;/table&gt;</summary>
		<author><name>Bomb Bloke</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7084&amp;oldid=prev</id>
		<title>Bomb Bloke at 12:12, 29 June 2015</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7084&amp;oldid=prev"/>
				<updated>2015-06-29T12:12:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 12:12, 29 June 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|desc=Added by ComputerCraft 1.74, shell.setCompletionFunction() associates a &amp;quot;completion function&amp;quot; with a given path. When a user enters that path into the [[shell]]'s command line, the assigned function will be used to provide suggestions for tab completion (which can be based on the number of parameters entered so far, and what the previous ones were). For example, if the user enters &amp;quot;pastebin &amp;quot;, a suitable tab completion function might offer &amp;quot;put&amp;quot; as an option for the first parameter, changing to &amp;quot;get&amp;quot; if a &amp;quot;g&amp;quot; is entered.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|desc=Added by ComputerCraft 1.74, shell.setCompletionFunction() associates a &amp;quot;completion function&amp;quot; with a given path. When a user enters that path into the [[shell]]'s command line, the assigned function will be used to provide suggestions for tab completion (which can be based on the number of parameters entered so far, and what the previous ones were). For example, if the user enters &amp;quot;pastebin &amp;quot;, a suitable tab completion function might offer &amp;quot;put&amp;quot; as an option for the first parameter, changing to &amp;quot;get&amp;quot; if a &amp;quot;g&amp;quot; is entered.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &amp;quot;completion function&amp;quot;, when actually utilised (generally via a call to [[shell.complete]]()), is passed four parameters - the shell table it is to be used with, the number of parameters entered (1, while user is typing the first; then 2, while the user is typing the second, and so on), the content of the current parameter being typed, and a numerically indexed table containing all the previous parameters typed (1 being the command name, 2 being the first parameter, and so on).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &amp;quot;completion function&amp;quot;, when actually utilised (generally via a call to [[shell.complete]]()), is passed four parameters - the shell table it is to be used with, the number of parameters entered (1, while user is typing the first; then 2, while the user is typing the second, and so on), the content of the current parameter being typed, and a numerically indexed table containing all the previous parameters typed (1 being the command name, 2 being the first parameter, and so on&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;). For example, if the user enters &amp;quot;pastebin p&amp;quot;, the function would be passed (shell, 1, &amp;quot;p&amp;quot;, {&amp;quot;pastebin&amp;quot;}&lt;/ins&gt;).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In turn, the function is expected to return a numerically indexed table containing all the possible strings that could be used to complete the current parameter (or an empty table, if none are known). For example, if the user enters &amp;quot;pastebin p&amp;quot;, the expected result is {&amp;quot;ut &amp;quot;}.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In turn, the function is expected to return a numerically indexed table containing all the possible strings that could be used to complete the current parameter (or an empty table, if none are known). For example, if the user enters &amp;quot;pastebin p&amp;quot;, the expected result is {&amp;quot;ut &amp;quot;}.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key ccraft_wiki-mw_:diff:version:1.11a:oldid:7082:newid:7084 --&gt;
&lt;/table&gt;</summary>
		<author><name>Bomb Bloke</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7082&amp;oldid=prev</id>
		<title>Bomb Bloke: Created page with &quot;{{lowercase}} {{Function |name=shell.setCompletionFunction |args= {{Type|string}} path, {{Type|function}} completion function |api=shell |addon=ComputerCraft |desc=Added by Co...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Shell.setCompletionFunction&amp;diff=7082&amp;oldid=prev"/>
				<updated>2015-06-29T11:57:15Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{lowercase}} {{Function |name=shell.setCompletionFunction |args= {{Type|string}} path, {{Type|function}} completion function |api=shell |addon=ComputerCraft |desc=Added by Co...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=shell.setCompletionFunction&lt;br /&gt;
|args= {{Type|string}} path, {{Type|function}} completion function&lt;br /&gt;
|api=shell&lt;br /&gt;
|addon=ComputerCraft&lt;br /&gt;
|desc=Added by ComputerCraft 1.74, shell.setCompletionFunction() associates a &amp;quot;completion function&amp;quot; with a given path. When a user enters that path into the [[shell]]'s command line, the assigned function will be used to provide suggestions for tab completion (which can be based on the number of parameters entered so far, and what the previous ones were). For example, if the user enters &amp;quot;pastebin &amp;quot;, a suitable tab completion function might offer &amp;quot;put&amp;quot; as an option for the first parameter, changing to &amp;quot;get&amp;quot; if a &amp;quot;g&amp;quot; is entered.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;completion function&amp;quot;, when actually utilised (generally via a call to [[shell.complete]]()), is passed four parameters - the shell table it is to be used with, the number of parameters entered (1, while user is typing the first; then 2, while the user is typing the second, and so on), the content of the current parameter being typed, and a numerically indexed table containing all the previous parameters typed (1 being the command name, 2 being the first parameter, and so on).&lt;br /&gt;
&lt;br /&gt;
In turn, the function is expected to return a numerically indexed table containing all the possible strings that could be used to complete the current parameter (or an empty table, if none are known). For example, if the user enters &amp;quot;pastebin p&amp;quot;, the expected result is {&amp;quot;ut &amp;quot;}.&lt;br /&gt;
&lt;br /&gt;
A list of registered paths (together with their functions) can be obtained via [[shell.getCompletionInfo]](). Other functions that may be useful in creating a &amp;quot;tab completion&amp;quot; function suitable for shell registration are [[fs.complete]](), [[textutils.complete]](), [[shell.completeProgram]]() and [[help.completeTopic]]().&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Registers a function which handles tab completion behaviour for a hypothetical &amp;quot;would&amp;quot; script in a directory titled &amp;quot;folder&amp;quot;.&lt;br /&gt;
|code=&lt;br /&gt;
 local parameters = { [&amp;quot;you &amp;quot;] = { [&amp;quot;please &amp;quot;] = { [&amp;quot;listen&amp;quot;] = {}, [&amp;quot;look &amp;quot;] = { [&amp;quot;up&amp;quot;] = {}, [&amp;quot;down&amp;quot;] = {} },&lt;br /&gt;
  	[&amp;quot;eat&amp;quot;] = {} }, [&amp;quot;give &amp;quot;] = { [&amp;quot;up&amp;quot;] = {}, [&amp;quot;blood&amp;quot;] = {}, }, [&amp;quot;kindly&amp;quot;] = {} } }&lt;br /&gt;
 &lt;br /&gt;
 local function tabCompletionFunction(shell, parNumber, curText, lastText)&lt;br /&gt;
 	-- Check that the parameters entered so far are valid:&lt;br /&gt;
 	local curParam = parameters&lt;br /&gt;
 	for i = 2, #lastText do&lt;br /&gt;
 		if curParam[lastText[i] .. &amp;quot; &amp;quot;] then&lt;br /&gt;
 			curParam = curParam[lastText[i] .. &amp;quot; &amp;quot;]&lt;br /&gt;
 		else&lt;br /&gt;
 			return {}&lt;br /&gt;
 		end&lt;br /&gt;
 	end&lt;br /&gt;
 &lt;br /&gt;
 	-- Check for suitable words for the current parameter:&lt;br /&gt;
 	local results = {}&lt;br /&gt;
 	for word, _ in pairs(curParam) do&lt;br /&gt;
 		if word:sub(1, #curText) == curText then&lt;br /&gt;
 			results[#results + 1] = word:sub(#curText + 1)&lt;br /&gt;
 		end&lt;br /&gt;
 	end&lt;br /&gt;
 	return results&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 shell.setCompletionFunction(&amp;quot;would&amp;quot;, tabCompletionFunction)&lt;br /&gt;
|output=If the user enters &amp;quot;would&amp;quot; into the CraftOS shell after running this code, assuming that file exists, various silly sentences will be suggested as they type further (use up/down to cycle through the suggestions).&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:API_Functions]]&lt;/div&gt;</summary>
		<author><name>Bomb Bloke</name></author>	</entry>

	</feed>