From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#42149: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Date: Sun, 27 Dec 2020 16:45:07 -0500 Message-ID: References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 42149@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Dario Gjorgjevski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 27 22:46:17 2020 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 1ktdrl-000A2o-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 22:46:17 +0100 Original-Received: from localhost ([::1]:56664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktdri-0007d7-6H for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 16:46:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktdrW-0007ap-NH for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 16:46:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktdrW-0003Ra-EN for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 16:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktdrW-0006xs-CX for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 16:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Dec 2020 21:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42149-submit@debbugs.gnu.org id=B42149.160910552526723 (code B ref 42149); Sun, 27 Dec 2020 21:46:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 21:45:25 +0000 Original-Received: from localhost ([127.0.0.1]:33697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdqu-0006wx-Vp for submit@debbugs.gnu.org; Sun, 27 Dec 2020 16:45:25 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdqt-0006wi-9L for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 16:45:23 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9CD5D440915; Sun, 27 Dec 2020 16:45:17 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C84C14407DF; Sun, 27 Dec 2020 16:45:08 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609105508; bh=7wMMMhKYzzB9RaLh8wyPdFBRh5vUZpds/D4nh83jJ6c=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=e5HL5KW3prRnJjyFAr5WD/zL5/GC3W5nIBJ0d3ec9D1GDEVO3rvoy2Bdxj2tXJ68a iCwPG5XzAmkQCQTbGEggDIvrJv8hg3h5rmWqdsfLqPhgKR4ubQKXrfAyMiyd1V2buB /FYzoPnOaT7WpLkMigm6P8Am/PVCxvL0+t7Z9Yuw+BmdVbAFTJnAJepK7tednZUPdP vn9SoWC7cPGwtxnHRLWNNBJGDsuXCocIXeb+JuenViZ98iTf9qtiUuvYjw2XH1hWRU AFozH2Hf75XGDyX/Bw9v+qiwqU+CI8VUkdOWsJJkj1qbg9lEL2TkLMucuIAWzGKNBQ /P34TT0PgCsnQ== Original-Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 67E5E120433; Sun, 27 Dec 2020 16:45:08 -0500 (EST) In-Reply-To: (Dario Gjorgjevski's message of "Thu, 15 Oct 2020 16:25:08 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:196831 Archived-At: > Please find attached a patch with an edited commit message. It should > be better. [ Boy, we are really unacceptably slow at reviewing this. ] Thanks very much for your patch. It looks good to me, but I think it's important we find a fix with which Jo=C3=A3o agrees. > Furthermore, =E2=80=98completions-first-difference=E2=80=99 and > =E2=80=98completions-common-part=E2=80=99 would sometimes overlap dependi= ng on the > position of point within the query string. Could you point us at the corresponding test? [ And thanks so much for the tests, this is great! ] > The former is fixed by correcting the part of > =E2=80=98completion-pcm--hilit-commonality=E2=80=99 responsible for loopi= ng over the > holes in the query string. Is that done by treating the "leftover" from the string as if there was an additional match? That would correspond to the "implicit any" that terminates every pattern. > The latter is fixed by explicitly moving > the position of =E2=80=98completions-first-difference=E2=80=99 in case an= overlap with > =E2=80=98completions-common-part=E2=80=99 is detected. Did you (by any chance) figure out how/why the two end up overlapping? The fix you're using looks pretty "hackish" and introduces a non-trivial data flow for `pos`. Before using such an ad-hoc solution it'd be best to understand where the problem comes from (it might still be the better answer in the end, but it's hard to judge). > (completion-pcm--optimize-pattern): Turn multiple consecutive > occurrences of =E2=80=98any=E2=80=99 into just a single one. This is good (consecutive `any` can introduce serious performance bugs because of our backtracing regexp matcher). Other than improving performance, have you found other effects? > +(defun completion-pcm--count-leading-holes (pattern) > + "Count the number of leading holes in PATTERN." > + (length (seq-take-while #'symbolp pattern))) `seq-take-while` is not defined at this stage. Either: - (require 'seq), but that means `seq` will have to be preloaded, which will require negotiating with Eli. - Mark `seq-take-while` with a `;;;###autoload` cookie so it'll be loaded on demand. - Avoid using `seq-take-while` here. I vote for the the 2nd option. I think Jo=C3=A3o knows the scoring algorithm much more than I do, so I'll let him judge if the change is sound. Stefan