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: Daniel Mendler
Subject: Re: [PATCH] `completing-read`: Add `group-function` support to completion metadata (REVISED PATCH VERSION 4)
Date: Sat, 8 May 2021 11:10:59 +0200

On 5/8/21 10:45 AM, Daniel Mendler wrote:
> On 5/8/21 8:24 AM, Daniel Mendler wrote:
>> On 5/7/21 7:55 PM, Daniel Mendler wrote:
>>> On 5/7/21 7:03 PM, Juri Linkov wrote:
>>>> I tried to remove `read-char-by-name-group`, but it has a feature
>>>> currently not supported by `group-function`:
>>>>
>>>>   (defcustom read-char-by-name-group nil
>>>>     "How to group characters for `read-char-by-name' completion.
>>>>   When t, split characters to sections of Unicode blocks
>>>>   sorted alphabetically."
>>>>   =====================
>>>>
>>>> It seems a new function is needed to sort groups, e.g. 
>>>> `group-sort-function`.
>>
>> 3. Use a single function with an action argument
>>    3.1 group-function : (action=title) -> string -> string
>>    3.2 group-function : (action=transform) -> string -> string
>>    3.3 group-function : (action=sort) -> list string -> list string
> 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.

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?
    (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)))

Daniel



reply via email to

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