Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1056461pxb; Thu, 9 Sep 2021 19:17:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwarwNVYErcN4z5HZJyjB7gxSJHvsyoj2EQiPryGp9nJUYcN27PlzjsU/xHGLkPx2Cw+6OQ X-Received: by 2002:a05:6e02:503:: with SMTP id d3mr4795258ils.107.1631240247110; Thu, 09 Sep 2021 19:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631240247; cv=none; d=google.com; s=arc-20160816; b=ZnHm64OxpudrTTfv9YtC9eNTF3WhgilGHEXmQ+OaUslPVamcSXUq6LERNXcwOm+l+u JEGyPHrCACl8gz6oAhFF4Wkex+iDBZH5tVeXJDl8h/JMMoFF4tbIcc+KIiHRRvmlQREo qO5xWOOvZOiIvYNTmA5DY6N9Ji2ms+ZQKuyknCDM3jm7QK2i6Nj5UL1KrAEtcTQ98zAZ j8eeyrWWHGC+iDVD2Q8mWjYrY+GWWDNXhk8bzftcHrcoJKvN+pn0oVvktVfrm7paBxx8 xKz7gd/mJ6GQvjhG/+aJzl6N5JXZJ83Nnr3Z0JihpEo34eAL7KZzSsNZ5RIO0Ku1Jdut Hn/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=7gootp9O4wXfYwFe7ItspToaq1GC2C7fuCeIs01oPRA=; b=OReQ1MSPLK3wWa+s6+D+OKlq8hAWFWAqnwG8RPV1hG1Vf/a45+mD8qQU5JHC/AEvJ4 w5wVz3kbkygYRLmge+w54yYC2cHdgXz0cw+be++mrnB9RmPVhHUIpSooOwe586CtZH7H BQj2i3pDn+1Tj3BwU30WLjLNWXM+VyB1SN8sxWGaL0/lxUXabbNuZOnxbtesRCur7uBZ Z0wOIlvWlOkLczX2UEc9vAhBndAcaVmvsW90tLtP3EmFbF90fcvipxTfeQdDWfRELDVZ ofwiR3xaKlnuToc0++jNdPuEQm/K91pR/XKv0NUxqkWCk/CrS0H4AZGN1fcQ4+a1NIhC nM7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kf4rXseJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k35si3422976jac.46.2021.09.09.19.17.15; Thu, 09 Sep 2021 19:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kf4rXseJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbhIJCRO (ORCPT + 99 others); Thu, 9 Sep 2021 22:17:14 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:49919 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbhIJCRO (ORCPT ); Thu, 9 Sep 2021 22:17:14 -0400 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (authenticated) by conssluserg-05.nifty.com with ESMTP id 18A2FX2P009316; Fri, 10 Sep 2021 11:15:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 18A2FX2P009316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1631240133; bh=7gootp9O4wXfYwFe7ItspToaq1GC2C7fuCeIs01oPRA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kf4rXseJysJvIb7HHBGdgBJaUVb37r7dBQOumyjzrbPl0AhomEb6aSkWihANy1pk4 CUj+dvcLmwglmP55EIHPfwbT0JCKfWxbQ0NS7mzYuIGvPpl2KSaEhCOlfdQ2ebGxod YXFdOXLsWW+wqjvy6lmpbcFCpCOqqgahSORrS1OENzEPiaTwiGlioHzM3OnXszZqqN PLoY6JHaqDVQX36Bq1CEoc+C2G01rsxR9bQPcMNWiENlYYDWgxCOI0gygqmnoLQgZm BlWcf0MbjmJzv/+UZef+u+8k4NX9R2LVmsfOFTu0kALHvCOWoqI8DuHnLXyUC6C8+i 11TY5L7pWOhEA== X-Nifty-SrcIP: [209.85.214.171] Received: by mail-pl1-f171.google.com with SMTP id n18so183174plp.7; Thu, 09 Sep 2021 19:15:33 -0700 (PDT) X-Gm-Message-State: AOAM53039cS5OEgJAssi1z8Rt0dOOz441HsFshtdiJBiOEyM21Y6YWlw wwMHEJrKJtecMEoXpJTiFSgZ8bt7EmWbJx3AqiI= X-Received: by 2002:a17:90a:d307:: with SMTP id p7mr5918490pju.144.1631240132781; Thu, 09 Sep 2021 19:15:32 -0700 (PDT) MIME-Version: 1.0 References: <20210901175326.568535-1-arielmarcovitch@gmail.com> In-Reply-To: <20210901175326.568535-1-arielmarcovitch@gmail.com> From: Masahiro Yamada Date: Fri, 10 Sep 2021 11:14:56 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kconfig: Create links to main menu items in search To: Ariel Marcovitch Cc: Linux Kernel Mailing List , Linux Kbuild mailing list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 2, 2021 at 2:53 AM Ariel Marcovitch wrote: > > 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. > > In case the item is a direct child of the rootmenu, show it in the > 'Location:' section as 'Main Menu'. > > This makes the 'if (i > 0)' superfluous because each item with prompt > will have at least one menu in its path. > > Signed-off-by: Ariel Marcovitch > --- > scripts/kconfig/menu.c | 40 ++++++++++++++++++++++++++-------------- > 1 file changed, 26 insertions(+), 14 deletions(-) > > diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c > index 606ba8a63c24..8d7e3b07bf93 100644 > --- a/scripts/kconfig/menu.c > +++ b/scripts/kconfig/menu.c > @@ -712,6 +712,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, > int i, j; > struct menu *submenu[8], *menu, *location = NULL; > struct jump_key *jump = NULL; > + const char *prompt = NULL; Can you move this to the for-loop ? The initializer is unneeded. > > str_printf(r, " Prompt: %s\n", prop->text); > > @@ -735,6 +736,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop, > if (location == NULL && accessible) > location = menu; > } > + > + /* If we have only the root menu, show it */ > + if (i == 0) { > + location = &rootmenu; > + submenu[i++] = location; > + } Instead of handling this as a special case, can we include the rootmenu all the time? We can change the for-loop condition to: for (i = 0; menu && i < 8; menu = menu->parent) { > if (head && location) { > jump = xmalloc(sizeof(struct jump_key)); > > @@ -758,21 +766,25 @@ 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 : "", > - 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); > + > + /* The real rootmenu prompt is ugly */ > + if (menu == &rootmenu) > + prompt = "Main Menu"; Can you use "Main menu" for the consistency with scripts/kconfig/parser.y line 501? > + else > + prompt = menu_get_prompt(menu); I think it is better to omit '->' for the rootmenu. if (menu == &rootmenu) { prompt = "Main menu"; marker = ""; } else { prompt = menu_get_prompt(menu); marker = "->"; } str_printf(r, "%*c%s %s", j, ' ', marker, prompt); Maybe, this will make the help look cleaner. > + str_printf(r, "%*c-> %s", j, ' ', prompt); > + if (menu->sym) { > + str_printf(r, " (%s [=%s])", menu->sym->name ? > + menu->sym->name : "", > + sym_get_string_value(menu->sym)); > } > + str_append(r, "\n"); > } > } > > > base-commit: 087e856cfb76e9eef9a3a6e000854794f3c36e24 > -- > 2.25.1 > -- Best Regards Masahiro Yamada