From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#48545: 28.0.50; `icomplete-vertical-mode` does not support the `group-function` Date: Thu, 19 Aug 2021 12:18:55 +0100 Message-ID: <871r6pr8bk.fsf@gmail.com> References: <10d162d5-2cd6-dd87-3289-a0187dfbf51f@daniel-mendler.de> <871r6sw9iz.fsf@gmail.com> <87a6lfnld0.fsf@gmail.com> <87eearulft.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="1171"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Daniel Mendler , Gregory Heytings , 48545-done@debbugs.gnu.org, dgutov@yandex.ru To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 19 13:20:13 2021 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 1mGg5k-00009y-KT for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Aug 2021 13:20:12 +0200 Original-Received: from localhost ([::1]:54322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGg5j-0007oF-I2 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Aug 2021 07:20:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGg5a-0007lF-HO for bug-gnu-emacs@gnu.org; Thu, 19 Aug 2021 07:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGg5a-0005CE-8i for bug-gnu-emacs@gnu.org; Thu, 19 Aug 2021 07:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mGg5a-0007Qo-4W for bug-gnu-emacs@gnu.org; Thu, 19 Aug 2021 07:20:02 -0400 Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Aug 2021 11:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 48545 X-GNU-PR-Package: emacs Mail-Followup-To: 48545@debbugs.gnu.org, joaotavora@gmail.com, mail@daniel-mendler.de Original-Received: via spool by 48545-done@debbugs.gnu.org id=D48545.162937194728490 (code D ref 48545); Thu, 19 Aug 2021 11:20:01 +0000 Original-Received: (at 48545-done) by debbugs.gnu.org; 19 Aug 2021 11:19:07 +0000 Original-Received: from localhost ([127.0.0.1]:58652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGg4g-0007PS-S9 for submit@debbugs.gnu.org; Thu, 19 Aug 2021 07:19:07 -0400 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:53078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGg4f-0007Oy-I0 for 48545-done@debbugs.gnu.org; Thu, 19 Aug 2021 07:19:06 -0400 Original-Received: by mail-wm1-f45.google.com with SMTP id f10so3625513wml.2 for <48545-done@debbugs.gnu.org>; Thu, 19 Aug 2021 04:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=i4DvC/ck90L/Sp/P5rMpnFOYI6QWg+tDLB1+xdcStGA=; b=DSIUezm4YjeHINT6DCfAK5PxQnORWM9xITtDlRi4zm2GUyCfLJVWmVgwvsIYxaeeFj cCMUG9KdU0nUEgj6E2Fi7mnvBB8ZkCm+Hv6RCFKCjHzZOCqnwkxLyvQ7qamXG2VTXiDm m7UU0jggTp3x/1OnYxUEjngLDV5ESsR2SwU07MuE8Bg0V5pdKHljOVHw+5FS6V4FNcI+ PPRC/7mtYIsz8XTcMcsKM0s/OKK5DEvNx91qfnMyoPpvagEm6oFjsai4ZlG8CKTj0Aap ZvdvB8/KxE8eZNcnki+0vd/6lBtzTf/HvsDrI3KQzfBdg1SFYNKiJjBrbvDW63jdiM6V I4Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=i4DvC/ck90L/Sp/P5rMpnFOYI6QWg+tDLB1+xdcStGA=; b=Uh8wzQs9UzBRL4IHE8aUJVeesL6oQpZCK2fXgTnylY0nXHQL0oW7FWzO9kP5cvgK/v Q9lvk0rO3RR8E46HpLBzHfA1/R3UruKPTLUQhn1wrKqCeCoO6GrBElwoaU5yB5b0t3A9 HiOKk/d4LALssgrwcNtKWY8Xx0NYSDVTq8VHLu5518kupzNOxfSqaCQpIcovbf7dEpaZ rzHlsanNVjmTzgG8xGIesiGnXpExAbyAJHVJwB2cy8O1PvF+oyjJytUAYAMixE0UAs+y WBDEVzQtqDN6OvVkU5gb2SkcBbDjkiTNKOYzV8qf35kyGI8Rs01ULcnbi30jV1IR52k6 qitg== X-Gm-Message-State: AOAM532R3420rMRFpyD5+pAvOi9ua/zFVa5tvUp5qZ76tmKfnworxYA2 3uOqrFA7uopIXqi6IBBgHPw= X-Google-Smtp-Source: ABdhPJz5cW2xQGY+7oPdjfscgQrA7ethOXi5WNAjabpTAUU/k7PGxFENRe0n/4U/p3yTx8cAm9xfnQ== X-Received: by 2002:a05:600c:358c:: with SMTP id p12mr4006390wmq.173.1629371939640; Thu, 19 Aug 2021 04:18:59 -0700 (PDT) Original-Received: from krug (a94-133-27-132.cpe.netcabo.pt. [94.133.27.132]) by smtp.gmail.com with ESMTPSA id c8sm2579631wrx.53.2021.08.19.04.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 04:18:58 -0700 (PDT) In-Reply-To: <87eearulft.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Wed, 18 Aug 2021 10:55:02 +0100") 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:212200 Archived-At: [Dmitry, I've tagged you since you're generally interested in this stuff.] Jo=C3=A3o T=C3=A1vora writes: > K=C3=A9vin Le Gouguec writes: >> I think Daniel is referring to what happens if you set completions-group >> to t and type e.g. C-x 8 RET ROMAN TAB TAB (without icomplete): you will >> see two "sections" titled 'symbol' and 'ancient-symbol'. > Thanks you, easy to reproduce and see clearly what you mean now=20 I've pushed this feature. This is how I tested: src/emacs -Q --eval '(setq completions-group t)' \ --eval '(setq xref-show-definitions-function (quote xref-sho= w-definitions-completing-read))' -f fido-vertical-mode C-U M-. xref-location-marker RET This should produce 5 locations. It shows, with section headers, how 4 of these belong to xref.el and 1 belongs to elisp-mode.el. When typing a pattern which leads to filtering (e.g. with flex) sections are preserved. Sane scrolling should also be maintained, though this was complicated to get right and may still have some bugs (I haven't noticed any yet.) I noticed a quirk, though. If I add '-l etags' to the 'emacs -Q' line, one gets 6 matches instead of 5 (due to etags having another xref-location-marker). That's fine, but due to the default alphanumeric/length sorting, it gets shoved into the group of xref.el matches and thus we get two xref.el groups. I.e. it looks like xref.el (cl-defgeneric xref-location-marker)=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 (cl-defmethod xref-location-marker ((l xref-file-location)))=20=20 (cl-defmethod xref-location-marker ((l xref-bogus-location)))=20 etags.el (cl-defmethod xref-location-marker ((l xref-etags-location)))=20 xref.el (cl-defmethod xref-location-marker ((l xref-buffer-location))) elisp-mode.el (cl-defmethod xref-location-marker ((l xref-elisp-location))) I don't use completions-group so I don't care strongly for this, but I believe that this is generally undesired, for non-filtering scenarios. All the entries from the xref.el group should probably be clumped together. If a user were flex-matching and thus expecting certain sort score-based order, it _would_ make sense to me, but here no flexy things were happening at all. To fix this, perhaps the default sorting methods should be turned off in completion-all-sorted-completions in minibuffer.el if a table supplies `group-function`. A patch for this is after my sig. Alternatively, tables that do support `group-function` could also start specifying: (display-sort-function . identity) I've tested both alternatives and they seem to do the right thing. But this may be the subject for some other bug, if someone cares. Anyway, I'm marking this closed this bug since its main work is done. Feedback welcome, of course. Jo=C3=A3o diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ffcd5d88ab..20fbc326a2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1506,17 +1506,18 @@ completion-all-sorted-completions (setq all (delete-dups all)) (setq last (last all)) =20 - (if sort-fun - (setq all (funcall sort-fun all)) - ;; Sort first by length and alphabetically. - (setq all (minibuffer--sort-by-length-alpha all)) - ;; Sort by history position, put the default, if it - ;; exists, on top. - (when (minibufferp) - (setq all (minibuffer--sort-by-position - (minibuffer--sort-preprocess-history - (substring string 0 base-size)) - all)))) + (cond (sort-fun + (setq all (funcall sort-fun all))) + ((not (completion-metadata-get all-md 'group-function)) + ;; Sort first by length and alphabetically. + (setq all (minibuffer--sort-by-length-alpha all)) + ;; Sort by history position, put the default, if it + ;; exists, on top. + (when (minibufferp) + (setq all (minibuffer--sort-by-position + (minibuffer--sort-preprocess-history + (substring string 0 base-size)) + all)))))