From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#65137: 29.1; completion-substring-try-completion doesn't return the longest common substring Date: Mon, 07 Aug 2023 19:24:15 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35109"; mail-complaints-to="usenet@ciao.gmane.io" To: 65137@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 08 01:25:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qT9bI-000902-H0 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Aug 2023 01:25:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT9bB-0001G2-8H; Mon, 07 Aug 2023 19:25:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT9ax-0001Cz-TU for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2023 19:25:05 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT9aw-0004vL-Av for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2023 19:25:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qT9av-0005MM-QT for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2023 19:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Aug 2023 23:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65137 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169145067120558 (code B ref -1); Mon, 07 Aug 2023 23:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Aug 2023 23:24:31 +0000 Original-Received: from localhost ([127.0.0.1]:34534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qT9aR-0005LU-FL for submit@debbugs.gnu.org; Mon, 07 Aug 2023 19:24:31 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:54684) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qT9aN-0005LE-DK for submit@debbugs.gnu.org; Mon, 07 Aug 2023 19:24:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT9aG-00017u-6T for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2023 19:24:20 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT9aD-0004p5-8L for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2023 19:24:19 -0400 Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266904 Archived-At: The substring completion style differs from the "basic" style by performing completion at the start of the input string. So for example, both of these are valid completions for "bar": (completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar")) -> ("foobarbaz" "foobar" . 0) However, the substring completion style's try-completion implementation does not reflect this. Since "foobar" is a prefix of all the valid completions, it should be returned by try-completion. But it is not, regardless of the location of point: (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0) -> ("bar" . 3) (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar")) -> ("bar" . 3) This breaks completion when one completion candidate is a prefix of other completion candidates. The recourse is moving point to the start of the input, so that the "basic" completion style takes over, which will correctly insert the common prefix: (completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0) -> ("foobar" . 6) However, even this does not work in the project-file and xref-location completion categories, for which the "basic" style is not included in completion-category-defaults. For such completion categories, there's simply no way to use completion to insert a common prefix. This is bad, because a filename or identifier might easily be a prefix of another filename or identifier. The solution is completion-substring-try-completion to be fixed to insert these common prefixes. I'll try and fix this, although the code is a bit intimidating. In GNU Emacs 29.1 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-07-29 built on Repository revision: cf24c7ac7608f41078fd2761c856892d5853b676 Repository branch: my-emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.8 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --with-gif=ifavailable' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/l Memory information: ((conses 16 1210667 128287) (symbols 48 75558 3) (strings 32 305623 26170) (string-bytes 1 9620792) (vectors 16 125723) (vector-slots 8 2816397 195041) (floats 8 762 279) (intervals 56 32710 336) (buffers 976 120))