Fix #213. You can now remove autoloaded functions.

Oddly enough, the code is here, but is internal function.
This commit is contained in:
Konrad Borowski 2013-10-12 21:55:11 +02:00
parent 97e731e05c
commit 1349d129c5
3 changed files with 5 additions and 5 deletions

View file

@ -1339,7 +1339,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
{ {
int i; int i;
for (i=woptind; i<argc; i++) for (i=woptind; i<argc; i++)
function_remove(argv[i]); function_remove_ignore_autoload(argv[i]);
return STATUS_BUILTIN_OK; return STATUS_BUILTIN_OK;
} }
else if (desc) else if (desc)

View file

@ -61,9 +61,6 @@ function_autoload_t::function_autoload_t() : autoload_t(L"fish_function_path", N
{ {
} }
/** Removes a function from our internal table, returning true if it was found and false if not */
static bool function_remove_ignore_autoload(const wcstring &name);
/** Callback when an autoloaded function is removed */ /** Callback when an autoloaded function is removed */
void function_autoload_t::command_removed(const wcstring &cmd) void function_autoload_t::command_removed(const wcstring &cmd)
{ {
@ -220,7 +217,7 @@ int function_exists_no_autoload(const wcstring &cmd, const env_vars_snapshot_t &
return loaded_functions.find(cmd) != loaded_functions.end() || function_autoloader.can_load(cmd, vars); return loaded_functions.find(cmd) != loaded_functions.end() || function_autoloader.can_load(cmd, vars);
} }
static bool function_remove_ignore_autoload(const wcstring &name) bool function_remove_ignore_autoload(const wcstring &name)
{ {
scoped_lock lock(functions_lock); scoped_lock lock(functions_lock);
bool erased = (loaded_functions.erase(name) > 0); bool erased = (loaded_functions.erase(name) > 0);

View file

@ -95,6 +95,9 @@ void function_init();
/** Add a function. */ /** Add a function. */
void function_add(const function_data_t &data, const parser_t &parser); void function_add(const function_data_t &data, const parser_t &parser);
/** Removes a function from our internal table, returning true if it was found and false if not */
bool function_remove_ignore_autoload(const wcstring &name);
/** /**
Remove the function with the specified name. Remove the function with the specified name.
*/ */