emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and,


From: Juri Linkov
Subject: Re: [PATCH] (icomplete-vertical-mode): Add support for affixations and, annotations
Date: Thu, 27 May 2021 00:45:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> Sure it's not beautiful, but it's an improvement to annotation-function.
>> If affixation-function were a function of a single completion, it would
>> be fine.  For a hint at a good design, look at the language server
>> protocol.  It returns a large list of completions, and then you can
>> "resolve" a completion to get many more of its properties.  So
>> resolution-function is an option.
>
> resolution-function sounds good.  Maybe this is not the most
> suitable comparison but since you mentioned the word "resolve"
> that evoked by association: resolver functions used in GraphQL.

Then instead of such ad-hoc meta functions:

  :annotation-function
  (lambda (str) (if (fboundp (intern-soft str)) " <f>"))
  :company-kind #'elisp--company-kind
  :company-doc-buffer #'elisp--company-doc-buffer
  :company-docsig #'elisp--company-doc-string
  :company-location #'elisp--company-location))

we could have one function

  :resolution-function
  (lambda (str fields)
    (mapcar (lambda (field)
              (pcase field
                ('suffix (if (fboundp (intern-soft str)) " <f>"))
                ('kind (elisp--company-kind str))
                ('doc-buffer (elisp--company-doc-buffer str))
                ('docsig (elisp--company-doc-string str))
                ('location (elisp--company-location str))))
            fields))

called with e.g.

  (funcall (completion-metadata-get md 'resolution-function)
           '(prefix suffix location kind))

When 'prefix' is not implemented by the backend, it just returns 'nil'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]