From: PatR Date: Sat, 16 Apr 2022 21:28:27 +0000 (-0700) Subject: & (whatdoes) enhancement? X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4acb9385e88fecb06efffa57285d48c36915483;p=nethack & (whatdoes) enhancement? Using '&#' or '?f#' showed "# perform an extended command (##)". The "(##)" part looks rather silly and is not helpful. Expand the text a little and omit command name for that particular command: "# enter and perform an extended command". --- diff --git a/src/cmd.c b/src/cmd.c index 4503336f3..d5723435c 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -2265,7 +2265,7 @@ do_repeat(void) or control keystroke generally should not be; there are a few exceptions such as ^O/#overview and C/N/#name */ struct ext_func_tab extcmdlist[] = { - { '#', "#", "perform an extended command", + { '#', "#", "enter and perform an extended command", doextcmd, IFBURIED | GENERALCMD | CMD_M_PREFIX, NULL }, { M('?'), "?", "list all extended commands", doextlist, IFBURIED | AUTOCOMPLETE | GENERALCMD | CMD_M_PREFIX, @@ -2624,7 +2624,7 @@ static int (*move_funcs[N_DIRS_Z][N_MOVEMODES])(void) = { { doup, doup, doup }, }; -/* used by dokeylist() and by key2extcmdesc() for dowhatdoes() */ +/* used by dokeylist() and by key2extcmddesc() for dowhatdoes() */ static const struct { int nhkf; const char *desc; @@ -2694,6 +2694,7 @@ const char * key2extcmddesc(uchar key) { static char key2cmdbuf[QBUFSZ]; + const char *txt; int k, i, j; uchar M_5 = (uchar) M('5'), M_0 = (uchar) M('0'); @@ -2728,13 +2729,11 @@ key2extcmddesc(uchar key) return misc_keys[i].desc; } /* finally, check whether 'key' is a command */ - if (g.Cmd.commands[key]) { - if (g.Cmd.commands[key]->ef_txt) { - Sprintf(key2cmdbuf, "%s (#%s)", - g.Cmd.commands[key]->ef_desc, - g.Cmd.commands[key]->ef_txt); - return key2cmdbuf; - } + if (g.Cmd.commands[key] && (txt = g.Cmd.commands[key]->ef_txt) != 0) { + Sprintf(key2cmdbuf, "%s (#%s)", g.Cmd.commands[key]->ef_desc, txt); + /* special case: 'txt' for '#' is "#" and showing that as + "perform an extended command (##)" looks silly; strip "(##)" off */ + return strsubst(key2cmdbuf, " (##)", ""); } return (char *) 0; }