nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH 2/2] rcfile: when a vital function is not mapped, me


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH 2/2] rcfile: when a vital function is not mapped, mention in which menu
Date: Tue, 7 Aug 2018 20:05:21 +0200

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  |  3 +++
 src/rcfile.c |  3 ++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/global.c b/src/global.c
index d0da11e7..9122a767 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1724,6 +1724,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 6734ce04..a4a19306 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -329,8 +329,11 @@ void set_spell_shortcuts(void);
 #endif
 const subnfunc *sctofunc(const sc *s);
 const char *flagtostr(int flag);
+#ifdef ENABLE_NANORC
 sc *strtosc(const char *input);
 int strtomenu(const char *input);
+char *menu_to_name(int menu);
+#endif
 #ifdef DEBUG
 void thanks_for_all_the_fish(void);
 #endif
diff --git a/src/rcfile.c b/src/rcfile.c
index 87832f06..efaa9e5e 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -883,7 +883,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);
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]