emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] `completing-read`: Add `group-function` support to completio


From: Juri Linkov
Subject: Re: [PATCH] `completing-read`: Add `group-function` support to completion metadata (REVISED PATCH)
Date: Sun, 25 Apr 2021 23:45:48 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> You can try the patch with the following settings and execute
> `xref-find-references` for example (M-?).

I tried and it looks really nice.  One question about performance:
there are 3 calls of the same function on every completion candidate:
twice it's called with the nil arg, and one call with the 'transform' arg:

> +(defun minibuffer--group-by (fun elems)
> +      (let* ((key (funcall fun cand nil))

> @@ -1780,6 +1829,12 @@ completion--insert-strings
> +          (let ((title (funcall group-fun (if (consp str) (car str) str) 
> nil)))

> @@ -1825,8 +1880,15 @@ completion--insert-strings
> +                        (funcall group-fun str 'transform)

> @@ -2098,15 +2171,22 @@ minibuffer-completion-help
> +                              (minibuffer--group-by group-fun completions)))

My concern is how fast it will work on a large list of candidate strings?

Would it be possible to optimize it to call the group function only once
on every candidate?  This might require changing the data structure,
for example, to an alist like is returned by `seq-group-by`.

Another variant is to put additional text properties on candidate strings,
e.g. a text property on redundant prefix with the group title that
completion--insert-strings then could fetch from the input string.



reply via email to

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