1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-02 21:52:04 -08:00
emacs/doc/lispref
Daniel Mendler 443d9efc95 (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.
2021-05-20 20:50:23 +03:00
..
abbrevs.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
anti.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
back.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
backups.texi Extend meaning of UNIQUIFY `auto-save-file-name-transforms'. (Bug#47493) 2021-05-10 13:42:48 +02:00
book-spine.texi
buffers.texi Remove several references to Emacs 22 and earlier 2021-03-10 05:45:47 +01:00
ChangeLog.1 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
commands.texi Add a new command for mode-specific commands 2021-02-20 15:12:45 +01:00
compile.texi Tiny fixes to recent native compilation docs 2021-05-08 17:53:41 +01:00
control.texi Add condition-case success handler (bug#47677) 2021-04-15 15:41:13 +02:00
customize.texi Decouple require-theme from load-theme 2021-03-04 15:40:35 +00:00
debugging.texi * lisp/emacs-lisp/benchmark.el (benchmark-call): New function 2021-03-17 19:04:28 -04:00
display.texi ; Grammar fixes 2021-04-16 09:56:41 +02:00
doclicense.texi
edebug.texi Edebug: Disable backtracking when hitting a &define keyword. 2021-04-10 18:19:49 +02:00
elisp.texi Document native-compilation 2021-05-08 16:26:41 +03:00
errors.texi Add a new variable `inhibit-interaction' 2021-01-12 15:12:38 +01:00
eval.texi Remove several references to Emacs 22 and earlier 2021-03-10 05:45:47 +01:00
files.texi Merge from origin/emacs-27 2021-04-25 09:16:09 -07:00
frames.texi * lisp/frame.el (delete-other-frames): Add universal prefix iconify arg 2021-04-12 12:32:58 -04:00
functions.texi Improve the documentation of :extra in cl-defmethod 2021-03-05 14:27:08 +01:00
gpl.texi
hash.texi Clarify that #s(hash-table ...) doesn't always create a new hash table 2021-02-07 14:47:09 +01:00
help.texi Pretty-print keys without <> around modifiers (bug#45536) 2021-01-05 11:28:58 +01:00
hooks.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
index.texi
internals.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
intro.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
keymaps.texi Merge from origin/emacs-27 2021-04-25 09:16:09 -07:00
lay-flat.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
lists.texi Clarify that #s(hash-table ...) doesn't always create a new hash table 2021-02-07 14:47:09 +01:00
loading.texi Document native-compilation 2021-05-08 16:26:41 +03:00
macros.texi * doc/lispref/macros.texi (Eval During Expansion): Copy edit. 2021-04-25 09:30:16 +02:00
Makefile.in Make tags tables from Texinfo sources 2021-03-11 16:42:57 +02:00
maps.texi Remove the 'M-o' ('facemap-keymap') binding experimentally 2021-02-10 19:38:18 +01:00
markers.texi Merge from origin/emacs-27 2021-02-19 08:36:55 -08:00
minibuf.texi (completing-read): Add group-function to the completion metadata 2021-05-20 20:50:23 +03:00
modes.texi (define-minor-mode): Warn about use of pre-Emacs-21 style args 2021-04-12 11:08:19 -04:00
nonascii.texi ; Fix some typos in doc strings and manuals 2021-04-24 18:26:07 +02:00
numbers.texi * src/fns.c (Frandom): Handle bignum limits 2021-03-05 12:09:50 -05:00
objects.texi Merge from origin/emacs-27 2021-04-16 07:50:20 -07:00
os.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
package.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
positions.texi Remove several references to Emacs 22 and earlier 2021-03-10 05:45:47 +01:00
processes.texi * lisp/emacs-lisp/bindat.el: Allow non-fixed size of strz 2021-04-15 11:28:06 -04:00
README Update copyright year to 2021 2021-01-01 01:13:56 -08:00
records.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
searching.texi ; Fix recent re-builder doc changes. 2021-05-08 15:07:38 +01:00
sequences.texi Merge from origin/emacs-27 2021-02-19 08:36:55 -08:00
spellfile Update lispref spellfile 2019-06-04 08:34:16 -07:00
streams.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
strings.texi Move string-trim functions to subr.el 2021-03-24 09:22:44 +01:00
symbols.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
syntax.texi Merge from origin/emacs-27 2021-02-06 08:10:38 -08:00
text.texi Improve documentation of new behavior of 'M-y' 2021-05-17 15:17:57 +03:00
threads.texi Update copyright year to 2021 2021-01-01 01:13:56 -08:00
tips.texi Remove mention of using defun- and defvar- as prefixes 2021-03-06 13:27:34 +01:00
two-volume-cross-refs.txt Update copyright year to 2021 2021-01-01 01:13:56 -08:00
two-volume.make Update copyright year to 2021 2021-01-01 01:13:56 -08:00
variables.texi Always heed the `lexical-binding' local variable 2021-05-10 12:40:11 +02:00
windows.texi Fix unclean "can't happen" error handling in read_minibuf_unwind 2021-04-22 12:07:21 +00:00

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Copyright (C) 2001-2021 Free Software Foundation, Inc.  -*- outline -*-
See the end of the file for license conditions.


README for the Emacs Lisp Reference Manual.

* This directory contains the texinfo source files for the Emacs Lisp
Reference Manual.

* Report bugs in the Lisp Manual (or in Emacs) using M-x report-emacs-bug.
To ask questions, use the help-gnu-emacs mailing list.

* The Emacs Lisp Reference Manual is quite large.  It totals around
1100 pages in smallbook format; the info files total around 3.0 megabytes.

* You can format this manual for Info, for printing hardcopy using TeX,
or for HTML.

* You can buy nicely printed copies from the Free Software Foundation.
Buying a manual from the Free Software Foundation helps support our GNU
development work.  See <https://shop.fsf.org/>.
(At time of writing, this manual is out of print.)

* The master file for formatting this manual for Tex is called 'elisp.texi'.
It contains @include commands to include all the chapters that make up
the manual.

* This distribution contains a Makefile that you can use with GNU Make.

** To make an Info file, you need to install Texinfo, then run 'make info'.

** Use 'make elisp.pdf' or 'make elisp.html' to create PDF or HTML versions.


This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.