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#45234: Annotation function vs. Affixation function Date: Tue, 15 Dec 2020 22:19:11 +0200 Organization: LINKOV.NET Message-ID: <87h7om3lls.fsf@mail.linkov.net> References: <87czzc5n7x.fsf@mail.linkov.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="1562"; 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: 45234@debbugs.gnu.org To: Clemens Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 15 21:24:38 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 1kpGs9-0000Jh-Vh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Dec 2020 21:24:37 +0100 Original-Received: from localhost ([::1]:46766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpGs9-00059d-1C for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Dec 2020 15:24:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpGrd-0004Tv-Ou for bug-gnu-emacs@gnu.org; Tue, 15 Dec 2020 15:24:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpGrc-000405-HD for bug-gnu-emacs@gnu.org; Tue, 15 Dec 2020 15:24:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kpGrc-0005Xz-Dw for bug-gnu-emacs@gnu.org; Tue, 15 Dec 2020 15:24:04 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Dec 2020 20:24:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45234 X-GNU-PR-Package: emacs Original-Received: via spool by 45234-submit@debbugs.gnu.org id=B45234.160806383321257 (code B ref 45234); Tue, 15 Dec 2020 20:24:04 +0000 Original-Received: (at 45234) by debbugs.gnu.org; 15 Dec 2020 20:23:53 +0000 Original-Received: from localhost ([127.0.0.1]:59229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kpGrR-0005Wn-Dm for submit@debbugs.gnu.org; Tue, 15 Dec 2020 15:23:53 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:18271) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kpGrN-0005Vt-Hv for 45234@debbugs.gnu.org; Tue, 15 Dec 2020 15:23:50 -0500 X-Originating-IP: 91.129.99.98 Original-Received: from mail.gandi.net (m91-129-99-98.cust.tele2.ee [91.129.99.98]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4992E240003; Tue, 15 Dec 2020 20:23:41 +0000 (UTC) In-Reply-To: (Clemens's message of "Tue, 15 Dec 2020 13:35:23 +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:196188 Archived-At: --=-=-= Content-Type: text/plain > The doc says it receives a list of completions so I think currently you > would have to look at the code to figure that out. Maybe we could avoid > that complication? Currently it seems every affixation would need to check > if it got a list of strings or a list of items as returned by a possibly > defined annotation function. I agree. So this could be changed like this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=affixation-function-over-annotation-function.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 456193d52e..404b1236b1 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -123,7 +123,8 @@ completion-metadata - `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 - and suffix. + and suffix. This function takes precedence over `annotation-function' + when both are provided, so only this function is used. - `display-sort-function': function to sort entries in *Completions*. Takes one argument (COMPLETIONS) and should return a new list of completions. Can operate destructively. @@ -1926,6 +1927,8 @@ completion-extra-properties completions. The function must accept one argument, a list of completions, and return a list where each element is a list of three elements: a completion, a prefix and a suffix. + This function takes precedence over `:annotation-function' + when both are provided, so only this function is used. `:exit-function': Function to run after completion is performed. @@ -2056,15 +2059,16 @@ minibuffer-completion-help (if sort-fun (funcall sort-fun completions) (sort completions 'string-lessp)))) - (when ann-fun + (cond + (aff-fun + (setq completions + (funcall aff-fun completions))) + (ann-fun (setq completions (mapcar (lambda (s) (let ((ann (funcall ann-fun s))) (if ann (list s ann) s))) - completions))) - (when aff-fun - (setq completions - (funcall aff-fun completions))) + completions)))) (with-current-buffer standard-output (setq-local completion-base-position --=-=-=--