From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: new-flex-completion-style Date: Wed, 13 Feb 2019 19:13:30 +0000 Message-ID: References: <20190202232827.27331.87300@vcs0.savannah.gnu.org> <20190202232828.4AE452159A@vcs0.savannah.gnu.org> <87lg2mynrg.fsf@gmail.com> <871s4czm5n.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="173507"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 13 20:14:11 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtzyz-000izn-FG for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2019 20:14:09 +0100 Original-Received: from localhost ([127.0.0.1]:33860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtzyy-0008DQ-BM for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2019 14:14:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtzym-0008B4-Uk for emacs-devel@gnu.org; Wed, 13 Feb 2019 14:13:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtzyl-0000g7-Sc for emacs-devel@gnu.org; Wed, 13 Feb 2019 14:13:56 -0500 Original-Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:46912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtzyk-0008F6-UT for emacs-devel@gnu.org; Wed, 13 Feb 2019 14:13:55 -0500 Original-Received: by mail-qk1-x72d.google.com with SMTP id i5so2044539qkd.13 for ; Wed, 13 Feb 2019 11:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dgVzs771umvEy7twopD2iAUbx4ZY41Hh3EejCsBurEo=; b=TDcXhag7N3iDOFHMBCN9kl2vDx24QaobQs9PDDwuBpz+W8ElSwy454IZAo9tylGUGq UdNMi2KgzmbWXPGNUY2k21PJkFOCs7iZKsivT/vwoehVShhXJ7dfJs5X88OD8gIUNJ+9 VPedUUWLIj4iNhxPrersyoJhCK30v3XwZOfGjmxDsZOmxwJdqQq7Dm+8q8H6OBn/R1FM te7Wcx6HtdcW/SPkpKctJN6W+RD2+anaHfmzm1v91QrLf2n5ikaG/3esC6VnLu1GEAxI FX/vba1XRY19uEkNQnrIEgaz3JYtEqBl37BGMbT+JoBJzsJWkUeqamstvt2KhQvwHW5i 3fIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dgVzs771umvEy7twopD2iAUbx4ZY41Hh3EejCsBurEo=; b=nhK/qozleFOOYTT9mcMB//YPIM2cwIydPj7/NpqG330EUjfcVNR1DRdU6Qdvdqu6Vz 1Nonm8kCp48Xpf2YcaP9ahyYdp2F+msFimBHYSV3aeBnSXMTbELGAF3A6Pp3r6xVzzZY LC1yg87A+CYZ9OFXHEWeEf2OPdnaMV3GBUp055dkkQkHmhzjauKWydwPMGHiJKecmhcH SqOr7UoP+HFSjkt7K+hOMaNQu6tpKFxKJPlYk+99jYKajhY0jQEGvwuXRkWPwqFOS8Qk qkzegkGbk5j7+tZ9qqj/h1Z0Q9IFAqNFZLv2W2G7aUZ2h2zd+WE/LbtQxwQ+CROyQ9cX QXjQ== X-Gm-Message-State: AHQUAuZCgjiVmXmNxeMh+ZdEX/uUXMotJBV9ZAydqkDSu9IRKXODkARO wWTa21XXnxe0bN7xSTF/COz4FF6cJXPcF++/C8w= X-Google-Smtp-Source: AHgI3IaLk8DhZ3uY3ET3+ROQ/UbbvPBwVQ6FPRVqAymHvCa1L+Oy1BxYLfKuqwm05QlMnmXL0Z/Fr7FfD/d+o/V1gxk= X-Received: by 2002:a37:c04a:: with SMTP id o71mr1606142qki.234.1550085221781; Wed, 13 Feb 2019 11:13:41 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::72d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233290 Archived-At: On Wed, Feb 13, 2019 at 6:54 PM Stefan Monnier wrote: > Making sure I understand: > - "counts the +++" will always return the length of the pattern, right? > So this is used just to normalize the result to ]0..1]. > - if the falloff constant is 0, the denominator is the number of places > where a "star" had to be added (plus one). And if the falloff > constant is positive it prefers more insertions of shorter text > chunks over fewer insertions of longer text chunks, and if it's > negative it oddly prefers longer insertions over shorter ones. Yes and Yes. The length of the pattern but probably not as calculated by (length pattern). I don't think it's odd. I call the former "scattered match" and the latter a "tighter match". For the particular way I remember symbol names, files names, etc, it's probably a good idea, since I can almost always remember a full word in the name. But sure enough I've had it configured for "scattered match" all along and I didn't know! > > Anyway, what do you think? Is this acceptable or so you have anything > > better? > > Fine by me (tho maybe I wouldn't count the final "---", to more > closely match [no pun intended] the usual prefix completion). Maybe this should be configurable, but in general I don't think staying close to prefix completion should be a goal, since this is a completely different game. IOW, valuing a string ends/beginning differently makes little sense in flex. > >>> + (put-text-property > >>> + 0 1 'completion-pcm-commonality-score > >>> + (/ score-numerator (* len (1+ score-denominator)) 1.0) str)) > >> > >> This will signal an error when `str` is the empty string :-( > > > > Ooops, but that that happen? Can an empty string be pcm-matched > > by some pattern? There's > > I think it can if the pattern is empty. So maybe all those > put/get-text-property are fine if you make sure this code is never even > called when the pattern is empty. OK, I'll figure something out. > BTW, the patch below seems to improve the behavior (e.g. it lets > `.../emacs/cfi TAB` complete to `.../emacs/config` as it should since > all remaining matches also match "config"). cool!