From 2147e161bf7936f5c812266f9922e7d6721e9c71 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 6 Aug 2018 21:29:01 +0200 Subject: [PATCH] rcfile: when a vital function is not mapped, mention in which menu Add the reverse of the name-to-menu function to accomplish this. This fixes https://savannah.gnu.org/bugs/?54449. --- src/global.c | 12 ++++++++++++ src/proto.h | 1 + src/rcfile.c | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/global.c b/src/global.c index 25b5b4da..136058e0 100644 --- a/src/global.c +++ b/src/global.c @@ -1710,6 +1710,18 @@ int strtomenu(const char *input) return -1; } + +/* Return the name that corresponds to the given menu symbol. */ +char *menu_to_name(int menu) +{ + int index = -1; + + while (++index < NUMBER_OF_MENUS) + if (menusymbols[index] == menu) + return menunames[index]; + + return "boooo"; +} #endif /* ENABLE_NANORC */ diff --git a/src/proto.h b/src/proto.h index 46794fff..725543ab 100644 --- a/src/proto.h +++ b/src/proto.h @@ -330,6 +330,7 @@ const subnfunc *sctofunc(const sc *s); const char *flagtostr(int flag); sc *strtosc(const char *input); int strtomenu(const char *input); +char *menu_to_name(int menu); #ifdef DEBUG void thanks_for_all_the_fish(void); #endif diff --git a/src/rcfile.c b/src/rcfile.c index b63a2c45..d9b78a48 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -882,7 +882,8 @@ static void check_vitals_mapped(void) const sc *s = first_sc_for(inmenus[v], f->func); if (!s) { fprintf(stderr, _("No key is bound to function '%s' in " - "some menu. Exiting.\n"), f->desc); + "menu '%s'. Exiting.\n"), f->desc, + menu_to_name(inmenus[v])); fprintf(stderr, _("If needed, use nano with the -I option " "to adjust your nanorc settings.\n")); exit(1);