From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#45780: 28.0.50; [PATCH] Face used for affixation function annotations Date: Mon, 11 Jan 2021 20:38:55 +0200 Organization: LINKOV.NET Message-ID: <87ft378gjk.fsf@mail.linkov.net> References: <9b1409af-58b9-3a62-4162-343fd25293ca@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 45780@debbugs.gnu.org To: Clemens Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 11 20:01:34 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 1kz2Ra-0008jE-B5 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 20:01:34 +0100 Original-Received: from localhost ([::1]:46326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz2RZ-0005e7-BF for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Jan 2021 14:01:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz2R5-0005a3-AG for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 14:01:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kz2R4-0006Kx-JR for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 14:01:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kz2R4-0002Sm-IB for bug-gnu-emacs@gnu.org; Mon, 11 Jan 2021 14:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Jan 2021 19:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45780 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45780-submit@debbugs.gnu.org id=B45780.16103916609435 (code B ref 45780); Mon, 11 Jan 2021 19:01:02 +0000 Original-Received: (at 45780) by debbugs.gnu.org; 11 Jan 2021 19:01:00 +0000 Original-Received: from localhost ([127.0.0.1]:58264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kz2R2-0002S6-23 for submit@debbugs.gnu.org; Mon, 11 Jan 2021 14:01:00 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:56497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kz2Qz-0002Rm-L5 for 45780@debbugs.gnu.org; Mon, 11 Jan 2021 14:00:58 -0500 X-Originating-IP: 91.129.98.64 Original-Received: from mail.gandi.net (m91-129-98-64.cust.tele2.ee [91.129.98.64]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 3BDAAFF80C; Mon, 11 Jan 2021 19:00:49 +0000 (UTC) In-Reply-To: <9b1409af-58b9-3a62-4162-343fd25293ca@posteo.net> (Clemens's message of "Mon, 11 Jan 2021 13:38:13 +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:197737 Archived-At: --=-=-= Content-Type: text/plain Hi Clemens, > As per the comment above the affected code, the client can specify the face > when prefix and suffix are provided. The prefix is already checked earlier > and what remained was checking the suffix not the prefix. Shouldn't then this code with font-lock-prepend-text-property be removed completely? Since both prefix and suffix are non-nil, this makes code no-op. > There is another thing I would like to bring up in this context: When the > annotations returned by annotation/affixation functions already specify > a face I think it would be nicer if the completion-annotations face > wouldn't be applied generally. In Selectrum we use something like: > > (if (text-property-not-all 0 (length str) 'face nil str) > str > (propertize str 'face 'completions-annotations)) So you propose to search for the face text-property in the provided string to decide whether to add the default face in completion--insert-strings? > This gives the client full control over the visual appearance if that is > preferred. Maybe this approach could also make sense to be included in > Emacs? Do you see any possible backward-compatibility issues with changing this in Emacs? For example, when a package like Selectrum puts another face on the completion string, then it will be displayed instead of the default completion-annotations face. > Currently for the annotation function the completions-annotations > face is always applied and for the affixation function it also still gets > applied when the affixation function returns a two candidate list (like > read-extended-command--affixation on current master). The case of also > allowing a two candidate list to be returned by affixation functions is > also currently undocumented. Thanks for noticing the documentation problem. Do you think this fix is sufficient: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=affix-doc.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 3eca9d066f..227966020c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -122,7 +122,8 @@ completion-metadata returns a string to append to STRING. - `affixation-function': function to prepend/append a prefix/suffix to entries. Takes one argument (COMPLETIONS) and should return a list - of completions with a list of three elements: completion, its prefix + of completions with a list of either two elements: completion + and suffix, or three elements: completion, its prefix and suffix. This function takes priority over `annotation-function' when both are provided, so only this function is used. - `display-sort-function': function to sort entries in *Completions*. @@ -1941,6 +1942,7 @@ completion-extra-properties `:affixation-function': Function to prepend/append a prefix/suffix to completions. The function must accept one argument, a list of completions, and return a list where each element is a list of + either two elements: a completion, and a suffix, or three elements: a completion, a prefix and a suffix. This function takes priority over `:annotation-function' when both are provided, so only this function is used. --=-=-=--