Skip to contentSkip to conversation

kconfig: Create links to main menu items in search

PATCH In review Ariel Marcovitch 2 participants 3 messages Sep 13, 2021 – Sep 25, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kconfig: Create links to main menu items in search

When one searches for a main menu item, links aren't created for it like with the rest of the symbols.

This happens because we trace the item until we get to the rootmenu, but we don't include it in the path of the item. The rationale was probably that we don't want to show the main menu in the path of all items, because it is redundant.

However, when an item has only the rootmenu in its path it should be included, because this way the user can jump to its location.

Add a 'Main menu' entry in the 'Location:' section for the kconfig items.

This makes the 'if (i > 0)' superfluous because each item with prompt will have at least one menu in its path.

---
 scripts/kconfig/menu.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
scripts/kconfig/menu.c +18 -15
index 606ba8a63c24..3d6f7cba8846 100644
@@ -728,7 +728,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
 		get_dep_str(r, prop->visible.expr, "  Visible if: ");
 
 	menu = prop->menu->parent;
-	for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
+	for (i = 0; menu && i < 8; menu = menu->parent) {
 		bool accessible = menu_is_visible(menu);
 
 		submenu[i++] = menu;
@@ -758,21 +758,24 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
 		list_add_tail(&jump->entries, head);
 	}
 
-	if (i > 0) {
-		str_printf(r, "  Location:\n");
-		for (j = 4; --i >= 0; j += 2) {
-			menu = submenu[i];
-			if (jump && menu == location)
-				jump->offset = strlen(r->s);
-			str_printf(r, "%*c-> %s", j, ' ',
-				   menu_get_prompt(menu));
-			if (menu->sym) {
-				str_printf(r, " (%s [=%s])", menu->sym->name ?
-					menu->sym->name : "<choice>",
-					sym_get_string_value(menu->sym));
-			}
-			str_append(r, "\n");
+	str_printf(r, "  Location:\n");
+	for (j = 4; --i >= 0; j += 2) {
+		menu = submenu[i];
+		if (jump && menu == location)
+			jump->offset = strlen(r->s);
+
+		if (menu == &rootmenu)
+			/* The real rootmenu prompt is ugly */
+			str_printf(r, "%*cMain menu", j, ' ');
+		else
+			str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
+
+		if (menu->sym) {
+			str_printf(r, " (%s [=%s])", menu->sym->name ?
+				menu->sym->name : "<choice>",
+				sym_get_string_value(menu->sym));
 		}
+		str_append(r, "\n");
 	}
 }
 

base-commit: a9086b878b7fd65894eb8cb1fa395dd469970566

Signature · 1 line
2.25.1
#1 lore raw
Quoted 75 lines · Ariel Marcovitch

When one searches for a main menu item, links aren't created for it like with the rest of the symbols.

This happens because we trace the item until we get to the rootmenu, but we don't include it in the path of the item. The rationale was probably that we don't want to show the main menu in the path of all items, because it is redundant.

However, when an item has only the rootmenu in its path it should be included, because this way the user can jump to its location.

Add a 'Main menu' entry in the 'Location:' section for the kconfig items.

This makes the 'if (i > 0)' superfluous because each item with prompt will have at least one menu in its path.

---
  scripts/kconfig/menu.c | 33 ++++++++++++++++++---------------
  1 file changed, 18 insertions(+), 15 deletions(-)
scripts/kconfig/menu.c +18 -15
index 606ba8a63c24..3d6f7cba8846 100644
@@ -728,7 +728,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
  		get_dep_str(r, prop->visible.expr, "  Visible if: ");
 
  	menu = prop->menu->parent;
-	for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
+	for (i = 0; menu && i < 8; menu = menu->parent) {
  		bool accessible = menu_is_visible(menu);
 
  		submenu[i++] = menu;
@@ -758,21 +758,24 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
  		list_add_tail(&jump->entries, head);
  	}
 
-	if (i > 0) {
-		str_printf(r, "  Location:\n");
-		for (j = 4; --i >= 0; j += 2) {
-			menu = submenu[i];
-			if (jump && menu == location)
-				jump->offset = strlen(r->s);
-			str_printf(r, "%*c-> %s", j, ' ',
-				   menu_get_prompt(menu));
-			if (menu->sym) {
-				str_printf(r, " (%s [=%s])", menu->sym->name ?
-					menu->sym->name : "<choice>",
-					sym_get_string_value(menu->sym));
-			}
-			str_append(r, "\n");
+	str_printf(r, "  Location:\n");
+	for (j = 4; --i >= 0; j += 2) {
+		menu = submenu[i];
+		if (jump && menu == location)
+			jump->offset = strlen(r->s);
+
+		if (menu == &rootmenu)
+			/* The real rootmenu prompt is ugly */
+			str_printf(r, "%*cMain menu", j, ' ');
+		else
+			str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
+
+		if (menu->sym) {
+			str_printf(r, " (%s [=%s])", menu->sym->name ?
+				menu->sym->name : "<choice>",
+				sym_get_string_value(menu->sym));
  		}
+		str_append(r, "\n");
  	}
  }
 
Quoted 1 line

base-commit: a9086b878b7fd65894eb8cb1fa395dd469970566

A friendly ping :)

#2 lore raw
Quoted 77 lines · Ariel Marcovitch
Quoted 75 lines · Ariel Marcovitch

When one searches for a main menu item, links aren't created for it like with the rest of the symbols.

This happens because we trace the item until we get to the rootmenu, but we don't include it in the path of the item. The rationale was probably that we don't want to show the main menu in the path of all items, because it is redundant.

However, when an item has only the rootmenu in its path it should be included, because this way the user can jump to its location.

Add a 'Main menu' entry in the 'Location:' section for the kconfig items.

This makes the 'if (i > 0)' superfluous because each item with prompt will have at least one menu in its path.

---
  scripts/kconfig/menu.c | 33 ++++++++++++++++++---------------
  1 file changed, 18 insertions(+), 15 deletions(-)
scripts/kconfig/menu.c +18 -15
index 606ba8a63c24..3d6f7cba8846 100644
@@ -728,7 +728,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
              get_dep_str(r, prop->visible.expr, "  Visible if: ");
 
      menu = prop->menu->parent;
-     for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
+     for (i = 0; menu && i < 8; menu = menu->parent) {
              bool accessible = menu_is_visible(menu);
 
              submenu[i++] = menu;
@@ -758,21 +758,24 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
              list_add_tail(&jump->entries, head);
      }
 
-     if (i > 0) {
-             str_printf(r, "  Location:\n");
-             for (j = 4; --i >= 0; j += 2) {
-                     menu = submenu[i];
-                     if (jump && menu == location)
-                             jump->offset = strlen(r->s);
-                     str_printf(r, "%*c-> %s", j, ' ',
-                                menu_get_prompt(menu));
-                     if (menu->sym) {
-                             str_printf(r, " (%s [=%s])", menu->sym->name ?
-                                     menu->sym->name : "<choice>",
-                                     sym_get_string_value(menu->sym));
-                     }
-                     str_append(r, "\n");
+     str_printf(r, "  Location:\n");
+     for (j = 4; --i >= 0; j += 2) {
+             menu = submenu[i];
+             if (jump && menu == location)
+                     jump->offset = strlen(r->s);
+
+             if (menu == &rootmenu)
+                     /* The real rootmenu prompt is ugly */
+                     str_printf(r, "%*cMain menu", j, ' ');
+             else
+                     str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
+
+             if (menu->sym) {
+                     str_printf(r, " (%s [=%s])", menu->sym->name ?
+                             menu->sym->name : "<choice>",
+                             sym_get_string_value(menu->sym));
              }
+             str_append(r, "\n");
      }
  }
 
Quoted 2 lines
Quoted 1 line

base-commit: a9086b878b7fd65894eb8cb1fa395dd469970566

A friendly ping :)

Applied to linux-kbuild. Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada