|
From: | Juri Linkov |
Subject: | Re: [PATCH] `completing-read`: Add `group-function` support to completion metadata (REVISED PATCH VERSION 4) |
Date: | Sun, 09 May 2021 20:59:45 +0300 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> I attached the current set of patches. The last patch >> "0005-group-function-Implement-generalized-action-argument.patch" >> implements the generalized action argument. The other patches (1-4) do >> not differ from the previously sent patches. I send them for completeness. Thanks, I tested it with mule--ucs-names-group, and everything works well. > Correction to the lastest patch. The `minibuffer--group-by` function > should actually be written as follows: > > (defun minibuffer--group-by (group-fun elems) > "Group ELEMS by GROUP-FUN." > (let ((groups)) > (dolist (cand elems) > (let* ((key (funcall group-fun 'title cand)) > (group (assoc key groups))) > (if group > (setcdr group (cons cand (cdr group))) > (push (list key cand) groups)))) > ;; FIXME: Is thread-last allowed in minibuffer.el? subr-x is not preloaded, but since thread-last is a macro maybe it's possible to expand it during compilation: (eval-when-compile (require 'subr-x)) > (setq groups (nreverse groups) > groups (mapc (lambda (x) > (setcdr x (nreverse (cdr x)))) > groups) > groups (funcall group-fun 'sort groups) > groups (mapcar #'cdr groups)) > (apply #'nconc groups))) Or maybe simply `mapcan`.
[Prev in Thread] | Current Thread | [Next in Thread] |