From ba177b48d53f7c7e8d5c556415e8864b686724f2 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 24 Jan 2006 09:32:13 +1000 Subject: [PATCH] Do not show function body as description in output of the functions builtin darcs-hash:20060123233213-ac50b-6887d4a2a9536e0697ab5ed0b1277dc645018cb9.gz --- complete.c | 13 ++++++++++++- function.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/complete.c b/complete.c index f546b1332..3e0573eb9 100644 --- a/complete.c +++ b/complete.c @@ -1216,6 +1216,17 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp ) free( apropos_cmd ); } +static const wchar_t *complete_function_desc( const wchar_t *fn ) +{ + const wchar_t *res = function_get_desc( fn ); + + if( !res ) + res = function_get_definition( fn ); + + return res; +} + + /** Complete the specified command name. Search for executables in the path, executables defined using an absolute path, functions, @@ -1295,7 +1306,7 @@ static void complete_cmd( const wchar_t *cmd, al_init( &possible_comp ); function_get_names( &possible_comp, cmd[0] == L'_' ); - copy_strings_with_prefix( comp, cmd, COMPLETE_FUNCTION_DESC, &function_get_desc, &possible_comp ); + copy_strings_with_prefix( comp, cmd, COMPLETE_FUNCTION_DESC, &complete_function_desc, &possible_comp ); al_truncate( &possible_comp, 0 ); builtin_get_names( &possible_comp ); diff --git a/function.c b/function.c index 84d21bc12..c18da3b8c 100644 --- a/function.c +++ b/function.c @@ -136,7 +136,7 @@ const wchar_t *function_get_desc( const wchar_t *argv ) if( data == 0 ) return 0; - return data->desc?data->desc:data->cmd; + return data->desc; } void function_set_desc( const wchar_t *name, const wchar_t *desc )