From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.devel Subject: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations Date: Sat, 22 May 2021 23:00:07 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F2A2E248F635E74A37ACB13E" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12624"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joaotavora@gmail.com To: "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 22 23:01:45 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lkYkj-00036O-0W for ged-emacs-devel@m.gmane-mx.org; Sat, 22 May 2021 23:01:45 +0200 Original-Received: from localhost ([::1]:50868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lkYki-000498-3I for ged-emacs-devel@m.gmane-mx.org; Sat, 22 May 2021 17:01:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkYjZ-0003Nk-Gs for emacs-devel@gnu.org; Sat, 22 May 2021 17:00:33 -0400 Original-Received: from server.qxqx.de ([2a01:4f8:121:346::180]:49413 helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkYjV-0002m4-Qe for emacs-devel@gnu.org; Sat, 22 May 2021 17:00:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Type:MIME-Version:Date:Message-ID:Cc:To:Subject: From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QdygeLPiqfgFuaCUxSfdrvev9VKoMC/tCg92m9n0vqQ=; b=XC3ViThCs/2imJMKCuCgUsOrbI H/kSELbEf0TfDl51H6gcO7Oo2yQUEEqowoiWuFLDhRcPpnCwzJkawpys75lWWcHbs4uSa0oWCkkhC kGv5gM+me3pVBYZ750OgF2EuCPh1ygwjj+gbXkNEJe3k/r99Vu45ICETcUIvqUUnLnA0=; Content-Language: en-US Received-SPF: pass client-ip=2a01:4f8:121:346::180; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269626 Archived-At: This is a multi-part message in MIME format. --------------F2A2E248F635E74A37ACB13E Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit I attached a patch which adds support for the affixation and annotation function to the recently added icomplete-vertical-mode (Fix bug#48013). Daniel --------------F2A2E248F635E74A37ACB13E Content-Type: text/x-diff; charset=UTF-8; name="0001-icomplete-vertical-mode-Add-support-for-affixations-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-icomplete-vertical-mode-Add-support-for-affixations-.pa"; filename*1="tch" >From 04e7c6da34df6b60e253a35b9baa3eba4062617f Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 22 May 2021 22:41:27 +0200 Subject: [PATCH] (icomplete-vertical-mode): Add support for affixations and annotations Fix bug#48013 * lisp/icomplete.el (icomplete--affixate): Add function, which annotates the currently visible candidates, given the `affixation-function` or `annotation-function` specified by the completion metadata. (icomplete-completions): Use the new function. --- lisp/icomplete.el | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 91bbb60013..83003fd5f3 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -666,6 +666,28 @@ icomplete-exhibit (put-text-property 0 1 'cursor t text) (overlay-put icomplete-overlay 'after-string text)))))))) +(defun icomplete--affixate (md prospects) + "Affixate PROSPECTS with prefixes and suffixes, given completion metadata MD." + (let ((aff-fun (or (completion-metadata-get md 'affixation-function) + (plist-get completion-extra-properties :affixation-function))) + (ann-fun (or (completion-metadata-get md 'annotation-function) + (plist-get completion-extra-properties :annotation-function)))) + (if aff-fun + (funcall aff-fun prospects) + (if ann-fun + (mapcar + (lambda (comp) + (let ((suffix (or (funcall ann-fun comp) ""))) + (list comp "" + ;; The default completion UI adds the + ;; `completions-annotations' face if no + ;; other faces are present. + (if (text-property-not-all 0 (length suffix) 'face nil suffix) + suffix + (propertize suffix 'face 'completions-annotations))))) + prospects) + prospects)))) + ;;;_ > icomplete-completions (name candidates predicate require-match) (defun icomplete-completions (name candidates predicate require-match) "Identify prospective candidates for minibuffer completion. @@ -814,14 +836,18 @@ icomplete-completions ;; is cached. (if last (setcdr last base-size)) (if prospects - (concat determ - (if icomplete-vertical-mode " \n" "{") - (mapconcat 'identity prospects (if icomplete-vertical-mode - "\n" - icomplete-separator)) - (unless icomplete-vertical-mode - (concat (and limit (concat icomplete-separator ellipsis)) - "}"))) + (if icomplete-vertical-mode + (concat determ " \n" + (mapconcat + (lambda (comp) + (if (consp comp) + (concat (cadr comp) (car comp) (caddr comp)) + comp)) + (icomplete--affixate md prospects) + "\n")) + (concat determ "{" + (mapconcat 'identity prospects icomplete-separator) + (and limit (concat icomplete-separator ellipsis) "}"))) (concat determ " [Matched]")))))) ;;; Iswitchb compatibility -- 2.20.1 --------------F2A2E248F635E74A37ACB13E--