From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#48356: 28.0.50; choose-completion discards the suffix after the completion boundary Date: Wed, 10 Apr 2024 04:33:44 +0300 Message-ID: <82196eff-85e6-44da-89e4-4ead4d72e657@gutov.dev> References: <18593691-8b7a-facf-68e1-e9d0c106897b@daniel-mendler.de> <868rtcjqk4.fsf@mail.linkov.net> <949a6c3a-9a59-89dd-bdee-c0ec6ee0baa7@daniel-mendler.de> <86r173odnm.fsf@mail.linkov.net> <868rt42wiz.fsf@mail.linkov.net> <39326c56-094c-4074-95d7-8f92f7f927a5@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------rRBx3yTGZuw0SsBqV5VUfMxZ" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28099"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 48356@debbugs.gnu.org, Daniel Mendler , JD Smith , Juri Linkov To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 10 03:35:12 2024 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 1ruMrm-00070B-JP for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Apr 2024 03:35:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruMrX-00038r-TO; Tue, 09 Apr 2024 21:34:56 -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 1ruMrW-00038g-F6 for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 21:34:54 -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 1ruMrW-0003fA-69 for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 21:34:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ruMre-0004lr-88 for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 21:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Apr 2024 01:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48356 X-GNU-PR-Package: emacs Original-Received: via spool by 48356-submit@debbugs.gnu.org id=B48356.171271284618144 (code B ref 48356); Wed, 10 Apr 2024 01:35:02 +0000 Original-Received: (at 48356) by debbugs.gnu.org; 10 Apr 2024 01:34:06 +0000 Original-Received: from localhost ([127.0.0.1]:51824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruMqj-0004ia-Gz for submit@debbugs.gnu.org; Tue, 09 Apr 2024 21:34:05 -0400 Original-Received: from fhigh5-smtp.messagingengine.com ([103.168.172.156]:44781) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruMqg-0004hu-Ef for 48356@debbugs.gnu.org; Tue, 09 Apr 2024 21:34:03 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 6D4F111401D5; Tue, 9 Apr 2024 21:33:48 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 09 Apr 2024 21:33:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1712712828; x=1712799228; bh=P3HshxZquV oHqL/bcRI81VpBP9sp7axSP+4G30b1hQ8=; b=nWVBOm1dpuCZKg026jXHBedZHv n+WGYndDHTRRG5n17wUK4vIf12B8lieIuRAVuYaIbOrv/K7OvMX6BeYyKdl0Dbzr QSiIUpmCOjFzgsSOQubAdBPVX9mxGgVfnd4ZWJh0zS2RnbttTr9DFLS38Tea60KS wpbgs+56wSXlaTa7dSbhmWpFOPsRyyc2/QUXRRR5slvaErd5lK05tbOF6onLVpPG wOwreo16z1cixX8HL8vYbLtz7joQs/TlU58Lcp0OGMemvf4NrWqNuVreXrCVbooI Qj+i/rFbzl4p91oljpkW3etF2WBgT17iksUavyqxbgW1QHhWfUjpCa76l/lg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712712828; x=1712799228; bh=P3HshxZquVoHqL/bcRI81VpBP9sp 7axSP+4G30b1hQ8=; b=xfDw+qhDJZ+7GquLUREAdyYBqzr+qLEdqxVWOWPKkCBQ uQXnnLHfh4ik+qxiG0JtEPpOsLD5agJkXuUIk2M4kgGXyNneT3ZJ/GrioOCRjwy5 XPGCP4RHAO/tzaoMLhIkOsP+uIchFaJ5thRiy3Ul/PbkFQgDkPVFtgfQQK767KRG hCxwd0GW/1xU0Rj0nkzlHmBRHMcegjjhtQYYHPEpaJDfrUTeJwn7uVbIzg+Mu45Q OzJxJF1TVKf+D6aV2TtrqCtzHbostOEWrmUv7/PZSbKfC4dLnTVHrov5YnSHW1M0 TTZeGo8RYlrq7vVbjSg3UtEPHXT6rwA502I7YWfaww== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehhedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptgfkffggfgfuvfevfhfhjgesmhdtreertddvjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeehleefudekudduveekieelgfeiffdvkefhkeeljeeujeegueekveffkeejjeev heenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Apr 2024 21:33:46 -0400 (EDT) Content-Language: en-US In-Reply-To: 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:283020 Archived-At: This is a multi-part message in MIME format. --------------rRBx3yTGZuw0SsBqV5VUfMxZ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Stefan, On 09/04/2024 02:50, Stefan Monnier wrote: >> ...which translates to "/" because of the double slash -- the filesystem >> root directory (*). But that's the same data which would be used by any >> other proposed solution, too. > > More or less, tho the "ideal" solution is to do that in the > completion-style code, which has a bit more knowledge about it. Doing it in completion-style, though, would either require a relatively awkward change in most/all styles (e.g. the "new dynamic variable" route), or a more straightforward change in styles together with an incompatible change in completion-all-completions. So on balance, would you say it's a good idea to a) use this approach in minibuffer-completion-help, b) create a named function for it, for other callers to take advantage of it as well? IIUC Vertico (and other minibuffer completion UIs) might be interested. >> So maybe it should be either be fixed in the >> completion table (avoid adding trailing slash when the last boundary is >> already followed by slash?), or the insertion code should do some >> additional post-processing of the completion string. > > I think you can fix it in the same ad-hoc way we use elsewhere: compare > the first char after the boundary with the last char of the completion > and drop one of the two if they're the same. Looks like completion--merge-suffix is the helper to use. >> + (base-suffix (let ((suffix (buffer-substring (point) end))) >> + (substring >> + suffix >> + (cdr (completion-boundaries string >> + minibuffer-completion-table >> + minibuffer-completion-predicate >> + suffix))))) > > I think you want to be careful to pass (buffer-substring start (point)) > rather than `string` to `completion-boundaries`. Thanks, see the update attached. > In theory this approach can "do the wrong thing" with some completion > styles, but AFAIK they haven't been written yet. 🙂 So you figure that such theoretical style would return adjusted base-suffix in -all-completions method, not just in -try-completion? --------------rRBx3yTGZuw0SsBqV5VUfMxZ Content-Type: text/x-patch; charset=UTF-8; name="base-suffix-v2.diff" Content-Disposition: attachment; filename="base-suffix-v2.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvbWluaWJ1ZmZlci5lbCBiL2xpc3AvbWluaWJ1ZmZlci5lbApp bmRleCA0MWIyMDE3NGJlMS4uMGNjY2M0NjQ0OGIgMTAwNjQ0Ci0tLSBhL2xpc3AvbWluaWJ1 ZmZlci5lbAorKysgYi9saXNwL21pbmlidWZmZXIuZWwKQEAgLTI1ODYsMTYgKzI1ODYsMTMg QEAgbWluaWJ1ZmZlci1jb21wbGV0aW9uLWhlbHAKICAgICAgICAgICAgICAobWluaWJ1ZmZl ci1jb21wbGV0aW9uLWJhc2UgKHN1YnN0cmluZyBzdHJpbmcgMCBiYXNlLXNpemUpKQogICAg ICAgICAgICAgIChiYXNlLXByZWZpeCAoYnVmZmVyLXN1YnN0cmluZyAobWluaWJ1ZmZlci0t Y29tcGxldGlvbi1wcm9tcHQtZW5kKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAoKyBzdGFydCBiYXNlLXNpemUpKSkKLSAgICAgICAgICAgICAoYmFz ZS1zdWZmaXgKLSAgICAgICAgICAgICAgKGlmIChvciAoZXEgKGFsaXN0LWdldCAnY2F0ZWdv cnkgKGNkciBtZCkpICdmaWxlKQotICAgICAgICAgICAgICAgICAgICAgIGNvbXBsZXRpb24t aW4tcmVnaW9uLW1vZGUtcHJlZGljYXRlKQotICAgICAgICAgICAgICAgICAgKGJ1ZmZlci1z dWJzdHJpbmcKLSAgICAgICAgICAgICAgICAgICAoc2F2ZS1leGN1cnNpb24KLSAgICAgICAg ICAgICAgICAgICAgIChpZiBjb21wbGV0aW9uLWluLXJlZ2lvbi1tb2RlLXByZWRpY2F0ZQot ICAgICAgICAgICAgICAgICAgICAgICAgIChwb2ludCkKLSAgICAgICAgICAgICAgICAgICAg ICAgKG9yIChzZWFyY2gtZm9yd2FyZCAiLyIgbmlsIHQpIChwb2ludC1tYXgpKSkpCi0gICAg ICAgICAgICAgICAgICAgKHBvaW50LW1heCkpCi0gICAgICAgICAgICAgICAgIiIpKQorICAg ICAgICAgICAgIChiYXNlLXN1ZmZpeCAobGV0ICgoc3VmZml4IChidWZmZXItc3Vic3RyaW5n IChwb2ludCkgZW5kKSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN1YnN0cmlu ZworICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWZmaXgKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgKGNkciAoY29tcGxldGlvbi1ib3VuZGFyaWVzIChidWZmZXItc3Vi c3RyaW5nIHN0YXJ0IChwb2ludCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5pYnVmZmVyLWNvbXBsZXRpb24tdGFibGUK KyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIG1pbmlidWZmZXItY29tcGxldGlvbi1wcmVkaWNhdGUKKyAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1ZmZpeCkpKSkpCiAg ICAgICAgICAgICAgKGFsbC1tZCAoY29tcGxldGlvbi0tbWV0YWRhdGEgKGJ1ZmZlci1zdWJz dHJpbmctbm8tcHJvcGVydGllcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBzdGFydCAocG9pbnQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIGJhc2Utc2l6ZSBtZApAQCAtMjY5Nyw3ICsyNjk0LDExIEBAIG1p bmlidWZmZXItY29tcGxldGlvbi1oZWxwCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAoZGVsZXRlLW1pbmlidWZmZXItY29udGVudHMpCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAoaW5zZXJ0IHN0YXJ0IGNob2ljZSkKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDs7IEtlZXAgcG9pbnQgYWZ0ZXIg Y29tcGxldGlvbiBiZWZvcmUgc3VmZml4Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAoc2F2ZS1leGN1cnNpb24gKGluc2VydCBlbmQpKSkKKyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzYXZlLWV4Y3Vyc2lvbiAoaW5zZXJ0Cisg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IChjb21wbGV0aW9uLS1tZXJnZS1zdWZmaXgKKyAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNob2ljZQorICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDEtIChsZW5ndGgg Y2hvaWNlKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGVuZCkpKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgKHVubGVzcyAob3IgKHplcm9wIChsZW5ndGggcHJlZml4KSkKICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGVxdWFsIHByZWZpeAogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGJ1ZmZl ci1zdWJzdHJpbmctbm8tcHJvcGVydGllcwo= --------------rRBx3yTGZuw0SsBqV5VUfMxZ--