unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler <mail@daniel-mendler.de>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Cc: joaotavora@gmail.com
Subject: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations
Date: Sat, 22 May 2021 23:00:07 +0200	[thread overview]
Message-ID: <b19c3b3b-ed3a-8944-357f-416f2731ad9f@daniel-mendler.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

I attached a patch which adds support for the affixation and annotation
function to the recently added icomplete-vertical-mode (Fix bug#48013).

Daniel

[-- Attachment #2: 0001-icomplete-vertical-mode-Add-support-for-affixations-.patch --]
[-- Type: text/x-diff, Size: 3427 bytes --]

From 04e7c6da34df6b60e253a35b9baa3eba4062617f Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
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


             reply	other threads:[~2021-05-22 21:00 UTC|newest]

Thread overview: 177+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-22 21:00 Daniel Mendler [this message]
2021-05-23  9:37 ` [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations João Távora
     [not found]   ` <adbebf98-eb86-9b8b-f191-e2e9f00cf80b@daniel-mendler.de>
2021-05-23 19:55     ` João Távora
2021-05-23 20:14       ` Daniel Mendler
2021-05-23 21:04         ` João Távora
2021-05-23 21:31           ` Daniel Mendler
2021-05-23 21:54             ` João Távora
2021-05-23 22:38               ` Daniel Mendler
2021-05-24 22:46                 ` João Távora
2021-05-25  3:06                   ` Daniel Mendler
2021-05-25  9:21                     ` João Távora
2021-05-26 18:12                   ` João Távora
2021-05-26 19:32                     ` Daniel Semyonov via Emacs development discussions.
2021-05-23 23:04               ` Daniel Mendler
2021-05-23 23:39                 ` Stefan Monnier
2021-05-24 22:54                   ` João Távora
2021-05-25  1:38                     ` Stefan Monnier
2021-05-25  8:39                       ` João Távora
2021-05-25 11:00                         ` Gregory Heytings
2021-05-26  0:03                           ` João Távora
2021-05-25  3:12                     ` Daniel Mendler
2021-05-25  9:25                       ` João Távora
2021-05-24 19:05                 ` João Távora
2021-05-24 19:13                   ` João Távora
2021-05-24 19:53                     ` Daniel Mendler
2021-05-24 23:04                       ` João Távora
2021-05-25  3:14                         ` Daniel Mendler
2021-05-25  9:31                           ` João Távora
2021-05-25  9:40                             ` Daniel Mendler
2021-05-24 22:05                   ` Dmitry Gutov
2021-05-23 23:37             ` Juri Linkov
2021-05-23 23:39             ` Juri Linkov
2021-05-24 10:26               ` Daniel Mendler
2021-05-24 22:07                 ` Juri Linkov
2021-05-25  2:53                   ` Daniel Mendler
2021-05-25  8:30                     ` João Távora
2021-05-25 16:59                       ` Juri Linkov
2021-05-25 17:46                         ` João Távora
2021-05-25 20:37                           ` Juri Linkov
2021-05-26 21:45                             ` Juri Linkov
2021-05-26 22:20                               ` Dmitry Gutov
2021-05-26 23:17                                 ` João Távora
2021-05-27  1:06                                   ` Dmitry Gutov
2021-05-27  7:29                                     ` João Távora
2021-05-27 13:15                                       ` Dmitry Gutov
2021-05-27 14:19                                         ` João Távora
2021-05-27 18:52                                           ` Dmitry Gutov
2021-05-27 20:58                                             ` João Távora
2021-05-28  8:08                               ` Daniel Mendler
2021-05-28  8:34                                 ` João Távora
2021-05-28  9:06                                   ` Daniel Mendler
2021-05-28 10:09                                     ` João Távora
2021-05-28 11:16                                       ` Daniel Mendler
2021-05-28 11:41                                         ` João Távora
2021-05-28 11:55                                           ` Daniel Mendler
2021-05-28 12:15                                             ` João Távora
2021-05-28 12:32                                               ` Daniel Mendler
2021-05-28 13:17                                                 ` João Távora
2021-05-28 13:55                                                   ` Daniel Mendler
2021-05-28 18:46                                                 ` Juri Linkov
2021-05-29  8:11                                                   ` Daniel Mendler
2021-05-28 12:44                                             ` Dmitry Gutov
2021-05-28 13:14                                               ` Daniel Mendler
2021-05-28 13:57                                                 ` Dmitry Gutov
2021-05-28 14:10                                                   ` Daniel Mendler
2021-05-28 14:57                                                     ` Dmitry Gutov
2021-05-28 16:01                                                       ` Daniel Mendler
2021-06-01  9:56                                         ` João Távora
2021-06-01 11:27                                           ` Daniel Mendler
2021-06-01 12:00                                             ` João Távora
2021-06-01 12:37                                               ` Daniel Mendler
2021-06-01 14:30                                                 ` João Távora
2021-06-01 14:40                                                   ` Daniel Mendler
2021-06-01 15:49                                                     ` João Távora
2021-06-01 16:00                                                       ` Daniel Mendler
2021-06-01 18:47                                                         ` João Távora
2021-06-01 19:03                                                           ` Daniel Mendler
2021-06-01 22:32                                                             ` João Távora
2021-06-01 20:22                                                           ` Stefan Monnier
2021-06-01 22:39                                                             ` João Távora
2021-06-02  2:40                                                               ` Stefan Monnier
2021-06-02  7:53                                                                 ` João Távora
2021-06-02 13:48                                                                   ` Stefan Monnier
2021-06-01 23:04                                                           ` Dmitry Gutov
2021-06-01 23:22                                                             ` João Távora
2021-06-01 23:29                                                               ` João Távora
2021-06-01 23:46                                                               ` Dmitry Gutov
2021-06-02  0:02                                                                 ` João Távora
2021-06-02 11:48                                                                   ` Dmitry Gutov
2021-06-02 12:59                                                                     ` João Távora
2021-06-02 18:29                                                                       ` Dmitry Gutov
2021-06-02 18:52                                                                         ` João Távora
2021-06-02 14:19                                                                   ` complexity in minibuffer (was: (icomplete-vertical-mode): Add support for affixations and, annotations) Stefan Monnier
2021-06-02 14:33                                                                     ` João Távora
2021-06-02 15:06                                                                       ` complexity in minibuffer Stefan Monnier
2021-06-02 15:20                                                                         ` João Távora
2021-06-02 15:29                                                                           ` Dmitry Gutov
2021-06-02 15:37                                                                             ` João Távora
2021-06-02 18:11                                                                               ` Dmitry Gutov
2021-06-02 18:30                                                                                 ` João Távora
2021-06-02 15:38                                                                           ` Stefan Monnier
2021-06-02 15:45                                                                             ` João Távora
2021-06-02 15:59                                                                               ` Daniel Mendler
2021-06-02 16:29                                                                                 ` João Távora
2021-06-02 15:53                                                                             ` Daniel Mendler
2021-06-02 18:31                                                                         ` Dmitry Gutov
2021-06-02 19:03                                                                           ` João Távora
2021-06-02 20:15                                                                             ` Dmitry Gutov
2021-06-02 22:11                                                                       ` Juri Linkov
2021-06-03  9:04                                                                         ` João Távora
2021-06-03 20:28                                                                           ` Juri Linkov
2021-06-01 15:58                                                     ` [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations Stefan Monnier
2021-06-01 16:04                                                       ` Daniel Mendler
2021-06-02  5:17                                               ` tumashu
2021-06-02  7:48                                                 ` João Távora
2021-06-02 10:40                                                   ` Dmitry Gutov
2021-06-02 11:04                                                     ` João Távora
2021-06-02 11:28                                                       ` Dmitry Gutov
2021-06-02 11:33                                                         ` João Távora
2021-06-02 12:31                                                           ` Dmitry Gutov
2021-06-02 13:16                                                             ` João Távora
2021-06-05  1:48                                                               ` Dmitry Gutov
2021-06-05  9:21                                                                 ` João Távora
2021-06-05 23:06                                                                   ` Dmitry Gutov
2021-06-05 23:25                                                                     ` João Távora
2021-06-05  4:23                                                               ` Stefan Monnier
2021-06-05  9:26                                                                 ` João Távora
2021-06-05 13:02                                                                 ` Ergus
2021-06-05 23:47                                                                 ` Dmitry Gutov
2021-06-06  2:30                                                                   ` Stefan Monnier
2021-06-02 13:38                                                           ` Stefan Monnier
2021-06-02 14:11                                                             ` Dmitry Gutov
2021-06-02 14:54                                                               ` Stefan Monnier
2021-06-02 15:07                                                                 ` João Távora
2021-06-05  1:08                                                                   ` Dmitry Gutov
2021-06-05  9:16                                                                     ` João Távora
2021-06-01 14:47                                           ` Gregory Heytings
2021-06-01 14:53                                             ` Daniel Mendler
2021-06-01 14:58                                               ` Gregory Heytings
2021-06-01 15:06                                                 ` Daniel Mendler
2021-06-01 15:33                                                   ` Gregory Heytings
2021-06-01 15:41                                                     ` Daniel Mendler
2021-06-01 15:09                                                 ` João Távora
2021-06-01 15:12                                                   ` Daniel Mendler
2021-06-01 15:06                                             ` João Távora
     [not found]                                           ` <b49749e34d620592d83a@heytings.org>
     [not found]                                             ` <CALDnm53Wdnp0yAu6uQd8A=6-uLArCBEdj4F+aVzUdFOT00XMWw@mail.gmail.com>
     [not found]                                               ` <b49749e34dc4e4287593@heytings.org>
     [not found]                                                 ` <87lf7t8wfz.fsf@gmail.com>
2021-06-01 15:24                                                   ` Gregory Heytings
2021-06-01 23:05                                                     ` João Távora
2021-05-24 23:02                 ` Dmitry Gutov
2021-05-24 23:04                 ` Dmitry Gutov
2021-05-23 21:35           ` Daniel Mendler
2021-05-23 22:42           ` Dmitry Gutov
2021-05-23 23:33             ` Stefan Monnier
2021-05-23 23:42             ` Juri Linkov
2021-05-24 23:24               ` Dmitry Gutov
2021-05-23 23:35       ` Juri Linkov
2021-05-24  3:23         ` Stefan Monnier
2021-05-24 10:34           ` Daniel Mendler
2021-05-24 16:22             ` Caching where-is-internal (was: (icomplete-vertical-mode): Add support for affixations and, annotations) Stefan Monnier
2021-05-24 16:31               ` Daniel Mendler
2021-05-24 19:53                 ` Caching where-is-internal Stefan Monnier
2021-05-24 20:07                   ` Daniel Mendler
2021-05-24 20:33                     ` Stefan Monnier
2021-05-24 20:45                       ` Daniel Mendler
2021-05-24 21:44                         ` Stefan Monnier
2021-05-24 21:52           ` [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations Juri Linkov
2021-05-24 22:41             ` João Távora
2021-05-25  1:27             ` Stefan Monnier
2021-05-24 22:37         ` João Távora
2021-05-25 16:53           ` Juri Linkov
2021-05-25 17:24             ` Stefan Monnier
2021-05-25 17:40               ` João Távora
2021-05-25 20:01                 ` Stefan Monnier
2021-05-25 20:27                   ` Dmitry Gutov
2021-05-25 20:46                   ` João Távora
  -- strict thread matches above, loose matches on Subject: below --
2021-06-02  8:25 Manuel Uberti
2021-06-02 11:07 ` João Távora
2021-06-02 11:29   ` Manuel Uberti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b19c3b3b-ed3a-8944-357f-416f2731ad9f@daniel-mendler.de \
    --to=mail@daniel-mendler.de \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).