@@ -190,7 +190,16 @@ static void aupat_show(AutoPat *ap, event_T event, int previous_group)
190190if (got_int ) {
191191return ;
192192 }
193- msg_outtrans ((char_u * )aucmd_exec_to_string (ac ,ac -> exec ));
193+
194+ char * exec_to_string = aucmd_exec_to_string (ac ,ac -> exec );
195+ if (ac -> desc != NULL ) {
196+ size_t msglen = 100 ;
197+ char * msg = (char * )xmallocz (msglen );
198+ snprintf (msg ,msglen ,"%s [%s]" ,exec_to_string ,ac -> desc );
199+ msg_outtrans ((char_u * )msg );
200+ }else {
201+ msg_outtrans ((char_u * )exec_to_string );
202+ }
194203if (p_verbose > 0 ) {
195204last_set_msg (ac -> script_ctx );
196205 }
@@ -1137,8 +1146,6 @@ int autocmd_register(int64_t id, event_T event, char *pat, int patlen, int group
11371146// perhaps: <lua>DESCRIPTION or similar
11381147if (desc != NULL ) {
11391148ac -> desc = xstrdup (desc );
1140- }else {
1141- ac -> desc = aucmd_exec_default_desc (aucmd );
11421149 }
11431150
11441151return OK ;
@@ -2465,45 +2472,44 @@ bool autocmd_delete_id(int64_t id)
24652472// ===========================================================================
24662473// AucmdExecutable Functions
24672474// ===========================================================================
2468- char * aucmd_exec_default_desc (AucmdExecutable acc )
2475+
2476+ /// Generate a string description of a callback
2477+ static char * aucmd_callback_to_string (Callback cb )
24692478{
2479+ // NOTE: this function probably belongs in a helper
24702480size_t msglen = 100 ;
2481+ char * msg = (char * )xmallocz (msglen );
24712482
2472- switch (acc .type ) {
2473- case CALLABLE_CB :
2474- switch (acc .callable .cb .type ) {
2475- case kCallbackLua : {
2476- char * msg = (char * )xmallocz (msglen );
2477- snprintf (msg ,msglen ,"<Lua function %d>" ,acc .callable .cb .data .luaref );
2478- return msg ;
2479- }
2480- case kCallbackFuncref : {
2481- // TODO(tjdevries): Is this enough space for this?
2482- char * msg = (char * )xmallocz (msglen );
2483- snprintf (msg ,msglen ,"<vim function: %s>" ,acc .callable .cb .data .funcref );
2484- return msg ;
2485- }
2486- case kCallbackPartial : {
2487- char * msg = (char * )xmallocz (msglen );
2488- snprintf (msg ,msglen ,"<vim partial: %s>" ,acc .callable .cb .data .partial -> pt_name );
2489- return msg ;
2490- }
2491- default :
2492- return NULL ;
2493- }
2483+ switch (cb .type ) {
2484+ case kCallbackLua : {
2485+ snprintf (msg ,msglen ,"<Lua function %d>" ,cb .data .luaref );
2486+ break ;
2487+ }
2488+ case kCallbackFuncref : {
2489+ // TODO(tjdevries): Is this enough space for this?
2490+ snprintf (msg ,msglen ,"<vim function: %s>" ,cb .data .funcref );
2491+ break ;
2492+ }
2493+ case kCallbackPartial : {
2494+ snprintf (msg ,msglen ,"<vim partial: %s>" ,cb .data .partial -> pt_name );
2495+ break ;
2496+ }
24942497default :
2495- return NULL ;
2498+ return "" ;
24962499 }
2500+ return msg ;
24972501}
24982502
2503+ /// Generate a string description for the command/callback of an autocmd
24992504char * aucmd_exec_to_string (AutoCmd * ac ,AucmdExecutable acc )
25002505FUNC_ATTR_PURE
25012506{
25022507switch (acc .type ) {
25032508case CALLABLE_EX :
25042509return acc .callable .cmd ;
2505- case CALLABLE_CB :
2506- return ac -> desc ;
2510+ case CALLABLE_CB : {
2511+ return aucmd_callback_to_string (acc .callable .cb );
2512+ }
25072513case CALLABLE_NONE :
25082514return "This is not possible" ;
25092515 }