summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/gv-tests.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2021-04-25 13:07:29 +0200
committerJuri Linkov <juri@linkov.net>2021-05-20 20:50:23 +0300
commit443d9efc9524be6aff5d9703b81a821b3bb12f35 (patch)
treebdfd87a619b27073af3cf342c92e8f2dc1bdfb52 /test/lisp/emacs-lisp/gv-tests.el
parent72ec24d4808c763d8d1fd4ae45b315b9a4b4011b (diff)
downloademacs-443d9efc9524be6aff5d9703b81a821b3bb12f35.tar.gz
emacs-443d9efc9524be6aff5d9703b81a821b3bb12f35.tar.bz2
emacs-443d9efc9524be6aff5d9703b81a821b3bb12f35.zip
(completing-read): Add `group-function` to the completion metadata
A completion table can specify a `group-function` in its metadata. The group function takes two arguments, a completion candidate and a transform argument. The group function is used to group the candidates after sorting and to enhance the completion UI with group titles. If the transform argument is nil, the function must return the title of the group to which the completion candidate belongs. The function may also return nil if the candidate does not belong to a group. If the transform argument is non-nil, the function must return the transformed candidate. For example, the transformation allows to remove a redundant part of the candidate, which is then displayed in the title. The grouping functionality is guarded by the customizable variable `completions-group` and turned off by default for the *Completions* buffer. The specific form of the `group-function` has been chosen in order to allow allocation-free grouping. This is important for completion UIs, which continously update the displayed set of candidates (Icomplete, Vertico, Ivy, etc.). Only when the transform argument is non-nil the candidate transformation is performed, which may involve a string allocation as done in the function `xref--completing-read-group`. The function `xref-show-definitions-completing-read` makes use of the `group-function`, by moving the file name prefix to the title. If grouping is enabled, the *Completions* are displayed as "linenum:summary" instead of "file:linenum:summary". This way the *Completions* buffer resembles the *Occur* buffer. * doc/lispref/minibuf.texi: Add documentation. * lisp/minibuffer.el (completion-metadata): Describe the `group-function` in the docstring. (completions-group): Add guard variable, off by default. (completions-group-format): Add variable defining the format string for the group titles. (completions-group-title): Add face used by `completions-group-format` for the group titles. (completions-group-separator): Add face used by `completions-group-format` for the group separator lines. (minibuffer--group-by): New grouping function. (minibuffer-completion-help): Use it. (display-completion-list): Add optional GROUP-FUN argument. (completion--insert-strings): Add optional GROUP-FUN argument. Insert group titles if `completions-format` is `one-column`. Transform each candidate with the GROUP-FUN. Attach the untransformed candidate to the property `completion--string`. * lisp/simple.el (choose-completion): Retrieve the untransformed completion candidate from the property `completion--string`. * lisp/progmodes/xref.el: (xref--completing-read-group): New grouping function. (xref-show-definitions-completing-read): Use it.
Diffstat (limited to 'test/lisp/emacs-lisp/gv-tests.el')
0 files changed, 0 insertions, 0 deletions