unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Daniel Mendler <mail@daniel-mendler.de>
Subject: Re: [elpa] externals/vertico a962a8b 2/3: Implement deferred highlighting for all completion styles
Date: Sun, 11 Apr 2021 12:37:34 -0400	[thread overview]
Message-ID: <jwvy2dog4om.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20210411131739.DAF2320AE6@vcs0.savannah.gnu.org> (Protesilaos Stavrou's message of "Sun, 11 Apr 2021 09:17:39 -0400 (EDT)")

> +(declare-function orderless-highlight-matches "ext:orderless")
> +(defun vertico--all-completions (&rest args)
> +  "Compute all completions for ARGS with deferred highlighting."
> +  (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality))
> +             (orig-flex (symbol-function #'completion-flex-all-completions))
> +             ((symbol-function #'completion-flex-all-completions)
> +              (lambda (&rest args)
> +                ;; Unfortunately for flex we have to undo the deferred highlighting, since flex uses
> +                ;; the completion-score for sorting, which is applied during highlighting.
> +                (cl-letf (((symbol-function #'completion-pcm--hilit-commonality) orig-pcm))
> +                  (apply orig-flex args))))
> +             ;; Defer the following highlighting functions
> +             (hl #'identity)
> +             ((symbol-function #'completion-hilit-commonality)
> +              (lambda (cands prefix &optional base)
> +                (setq hl (lambda (x) (nconc (completion-hilit-commonality x prefix base) nil)))
> +                (and cands (nconc cands base))))
> +             ((symbol-function #'completion-pcm--hilit-commonality)
> +              (lambda (pattern cands)
> +                (setq hl (lambda (x) (completion-pcm--hilit-commonality pattern x)))
> +                cands))
> +             ((symbol-function #'orderless-highlight-matches)
> +              (lambda (pattern cands)
> +                (setq hl (lambda (x) (orderless-highlight-matches pattern x)))
> +                cands)))
> +    (cons (apply #'completion-all-completions args) hl)))

Yuck!
I think this should have a bug#NNN attached to make sure it's only used
on a temporary basis (i.e. until Emacs's minibuffer.el provides the
corresponding functionality).


        Stefan




       reply	other threads:[~2021-04-11 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210411131733.8572.37775@vcs0.savannah.gnu.org>
     [not found] ` <20210411131739.DAF2320AE6@vcs0.savannah.gnu.org>
2021-04-11 16:37   ` Stefan Monnier [this message]
2021-04-11 17:34     ` [elpa] externals/vertico a962a8b 2/3: Implement deferred highlighting for all completion styles Daniel Mendler

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=jwvy2dog4om.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=mail@daniel-mendler.de \
    /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).