From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults Date: Fri, 08 Nov 2019 12:14:31 -0500 Message-ID: References: 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="25968"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 38101@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 08 18:15:26 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iT7r0-0006ZU-8Y for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Nov 2019 18:15:22 +0100 Original-Received: from localhost ([::1]:58004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT7qy-0006S5-Ki for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Nov 2019 12:15:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40461) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT7qh-0006Pv-Jf for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2019 12:15:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iT7qg-0005Ox-DZ for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2019 12:15:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38706) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iT7qg-0005Or-7w for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2019 12:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iT7qf-0003Hg-V2 for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2019 12:15: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: Fri, 08 Nov 2019 17:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38101 X-GNU-PR-Package: emacs Original-Received: via spool by 38101-submit@debbugs.gnu.org id=B38101.157323328212581 (code B ref 38101); Fri, 08 Nov 2019 17:15:01 +0000 Original-Received: (at 38101) by debbugs.gnu.org; 8 Nov 2019 17:14:42 +0000 Original-Received: from localhost ([127.0.0.1]:47527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iT7qM-0003Gq-6B for submit@debbugs.gnu.org; Fri, 08 Nov 2019 12:14:42 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iT7qK-0003Gd-7Z for 38101@debbugs.gnu.org; Fri, 08 Nov 2019 12:14:40 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B3E65449A00; Fri, 8 Nov 2019 12:14:34 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 59A984499DB; Fri, 8 Nov 2019 12:14:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1573233273; bh=4BIaxnfjlV2bifYIjW/lnJDsibe3fNVrwHvbe3G172E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=nqxdgJX+hzmA5ZlQPj/Xpz27vNaWIrInm2YksH6DEhYeq8VESR1Pwmwap3SBYyaHt CuUfC3vs8dtoWuftJi81QLntA43I6sMdW0pAxZQwqmRAv0NlTzpyuxmEI7yx6xNR8p dgSkL7e7POasQoE4Uaj4mMu/Fx7ld07TQxG5mtNXkUpUstKAl4mn2bdp5Zqmj3+xCu gN+shdJhaMZ4Dw74vpdJFGchICY4h51nvhNbHT8aUa3RT5/XoliRzp7Hcwsv5rneO1 LwFGWZnx6HtscGQJ8i2djRVhtQWOPocjJa+Fa1m9Ns+8tlz7jc4Dc7g8EIvrv+Tkro +UKlNR0MZEUbA== Original-Received: from pastel (unknown [216.154.47.134]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 252E6120397; Fri, 8 Nov 2019 12:14:33 -0500 (EST) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Thu, 7 Nov 2019 14:22:29 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171234 Archived-At: >> > (setq completion-styles '(flex)) >> > (setq completion-category-defaults nil) Right: `completion-category-defaults` lets us specify different default completion styles for particular cases, but it doesn't clearly says "how different" and instead just overrides the global setting. In practice it's been used so far to override the default (mostly) prefix completion with substring completion, IOW the override is performed in order to use a "more lax" completion (where "lax" here can be understood as the size of the set of matching candidates for a given pattern: `substring` matches more candidates than `basic` so it is "more lax"). But if the user sets the default completion style to a "very lax" style such as `flex` then the override doesn't work as intended any more. It won't completely prevent the use of `flex` luckily: (defun completion--styles (metadata) (let* ((cat (completion-metadata-get metadata 'category)) (over (completion--category-override cat 'styles))) (if over (delete-dups (append (cdr over) (copy-sequence completion-styles))) completion-styles))) So, if the default `completion-styles` is `(flex)` and the `completion-category-defaults` specifies, say, `(basic substring)`, then the result is to use `(basic substring flex)` which still includes `flex` (hence the problem is not too crippling) but `flex` will only be used when both `basic` and `substring` fail to find any matching candidates, which is not what was desired. In this specific case is `basic` or `substring` find matching candidates those would also have been returned by `flex` and (presumably) with the best scores, so the end result (compared to only using `flex`) is mostly that *Completions* gets truncated. Stefan