From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 6A722386EC5C for ; Sun, 24 May 2020 12:58:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6A722386EC5C Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-JLWjVxf4NXCJ9_ANJPgaSA-1; Sun, 24 May 2020 08:58:06 -0400 X-MC-Unique: JLWjVxf4NXCJ9_ANJPgaSA-1 Received: by mail-wr1-f72.google.com with SMTP id c14so5733959wrm.15 for ; Sun, 24 May 2020 05:58:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OIJB67abEhyOy6btdc8qjag2MY3iOZIzHFGmQMUJET8=; b=gUndyJtoglwoz4Dgz8Pzp4/ZN9bFZQL15BxGi96HkxEnQeYG3CffDGCtZjVmNU21x4 B9HnGbamdqnFm+5bem4LhO7w9BFyEUNCMd0i+PH2yh+ur3bKynz8gfYYCttLU9xbEIp7 SGwezdRtRqjo4+/6FFsj4x4sv7Zsdh7BQvvQz2K1H19EFPv4huVza7RB3Hn0wptqclS3 d+E4V/tu0ybBCn/0I0PElySuBMJOJKKMqfTVdE9mmLvSFWDvdQz/RkrTfzA+AwmPnPU0 klHPRpMsy5x/PA427ypm5SLwgGjuCZMymdkB5bt231dPs/Ti8zPBH5D5ie2OaKJlqu2T dsTA== X-Gm-Message-State: AOAM5322VH6JFOnLwjGGzLBR16Cv6G8P+veJ0h1yWc15Z4JZp9V/YSlK s+8oB0sUf8GQuBQAzoUqMOPpr2DtnnSDUbbyTRl+uqCoeixV2b3waOVCT4ZKbobUJ/3SnhncBkx RoxAGjXnUqW3roGi7r6aWxg== X-Received: by 2002:a7b:cc88:: with SMTP id p8mr7307134wma.104.1590325084852; Sun, 24 May 2020 05:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8cFfhAi15c9bIQtUAa/J6EO4fwkhZkEqrUy5M3RNh4QqLMXx5hOsU0LdjY6uaP+qMrUkgrA== X-Received: by 2002:a7b:cc88:: with SMTP id p8mr7307122wma.104.1590325084603; Sun, 24 May 2020 05:58:04 -0700 (PDT) Received: from ?IPv6:2001:8a0:f909:7b00:2327:23ca:3e56:ef5f? ([2001:8a0:f909:7b00:2327:23ca:3e56:ef5f]) by smtp.gmail.com with ESMTPSA id s7sm916263wrr.60.2020.05.24.05.58.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 May 2020 05:58:04 -0700 (PDT) Subject: Re: [PATCH] Add completion styling To: Tom Tromey , Eli Zaretskii References: <20200409024112.18065-1-tom@tromey.com> <83369dp3gy.fsf@gnu.org> <87eesc1x2d.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4b370f83-3954-bbc4-50b5-1528e8b4fca5@redhat.com> Date: Sun, 24 May 2020 13:58:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87eesc1x2d.fsf@tromey.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2020 12:58:10 -0000 On 4/24/20 8:51 PM, Tom Tromey wrote: >>>>>> "Eli" == Eli Zaretskii writes: > > Thanks for your comments. > >>> Readline has a styling feature for completion -- if it is enabled, the >>> common prefix of completions will be displayed in a different style. >>> This doesn't work in gdb, because gdb implements its own completer. >>> >>> This patch implements the feature. However, it doesn't directly use >>> the Readline feature, because gdb can do a bit better: it can let the >>> user control the styling using the existing mechanisms. > > Eli> Would it make sense to default to the style determined by the user's > Eli> colored-completion-prefix setting? > > That's a bit of a pain because readline parses LS_COLORS on its own. > This doesn't seem to be documented anywhere. I'm reluctant to try to > use readline's code, because it is using "_" prefixes; in readline these > indicate private items and there's at least one bug report about this in > bugzilla already (some distro made these hidden in the .so and it broke > gdb). > > Eli> Also, do we want the default styling to be no-styling, or do we want > Eli> something else? > > I would prefer to enable it by default. It's easy to disable if one > prefers. > > Eli> Btw, Emacs solves this problem differently: it uses a distinct styling > Eli> for the first character that distinguishes between completion > Eli> candidates. I wonder if that idea is more useful for quickly > Eli> realizing what one needs to type next. Or do we want to follow > Eli> Readline here for consistency reasons? > > I think the Emacs idea is nice. Maybe we want to let the user control > the prefix text, the "difference character", and the final completion > text. I'm coming here late, sorry about that. I have some comments. As you know, I'm very much in favor of color in completion, mostly because of the C++ wildmatching feature. Unfortunately, coloring for that is doesn't work correctly. Try "b main[TAB]" when debugging GDB, and you'll see that GDB highlights the "t" as the first different character here: selftests::string_view::cons_1::main() selftests::string_view::cons_2::main() selftests::string_view::cons_3::main() ^ while it should highlight here: selftests::string_view::cons_1::main() selftests::string_view::cons_2::main() selftests::string_view::cons_3::main() ^ Also, if you enable "set style completion-prefix foreground", then you should see GDB highlight the common prefix here: selftests::string_view::cons_1::main() selftests::string_view::cons_2::main() selftests::string_view::cons_3::main() ^^^^ though it actually incorrectly highlights here: selftests::string_view::cons_1::main() selftests::string_view::cons_2::main() selftests::string_view::cons_3::main() ^^^^ BTW, it seems like the "dim" default style for "completion-prefix foreground" doesn't have any effect on my konsole terminal, and neither on xterm. It does work on a real Linux virtual console. Seems like "dim" isn't universally supported? Maybe we should avoid "dim" in default styles? I'm using "set style completion-prefix foreground red" here, and it looks nice. Also, I noticed that "set style enabled off" does not disable completion styling. That seems wrong to me. Thanks, Pedro Alves