1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-12 06:21:02 -08:00
emacs/lisp/progmodes
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
..
antlr-mode.el Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
asm-mode.el
autoconf.el
bat-mode.el
bug-reference.el Add bug-reference-mode-force-auto-setup 2021-05-16 16:19:57 +02:00
cc-align.el Convert CC Mode to lexical binding in Emacs 2021-04-10 19:20:14 +00:00
cc-awk.el ; Normalize and add missing first and last lines 2021-04-19 12:21:01 +02:00
cc-bytecomp.el Merge remote-tracking branch 'savannah/master' into native-comp 2021-04-19 18:46:50 +02:00
cc-cmds.el CC Mode: Put debug specs inside declare forms. Add missing debug specs. 2021-04-15 10:11:20 +00:00
cc-defs.el Remove unused lexical variables in cc-defs.el 2021-05-04 21:00:05 +01:00
cc-engine.el CC Mode: Put debug specs inside declare forms. Add missing debug specs. 2021-04-15 10:11:20 +00:00
cc-fonts.el CC Mode: Get proper search limits in c-font-lock-cut-off-declarators 2021-04-25 17:40:16 +00:00
cc-guess.el ; Fix typos: emacs lisp -> Emacs Lisp 2021-04-16 14:54:02 +02:00
cc-langs.el Merge remote-tracking branch 'savannah/master' into native-comp 2021-04-19 18:46:50 +02:00
cc-menus.el Convert CC Mode to lexical binding in Emacs 2021-04-10 19:20:14 +00:00
cc-mode.el CC Mode: Put debug specs inside declare forms. Add missing debug specs. 2021-04-15 10:11:20 +00:00
cc-styles.el ; Fix some typos in doc strings and manuals 2021-04-24 18:26:07 +02:00
cc-vars.el Convert CC Mode to lexical binding in Emacs 2021-04-10 19:20:14 +00:00
cfengine.el * lisp/progmodes/cfengine.el: Use lexical-binding 2021-04-01 18:16:52 -04:00
cl-font-lock.el
cmacexp.el * lisp/progmodes/cmacexp.el: Use lexical-binding. 2021-04-09 15:20:56 +02:00
compile.el compilation-goto-locus does not handle right display-buffer 2021-03-28 15:19:47 +02:00
cperl-mode.el cperl-mode: Eliminate bad interpretation of ?foo? 2021-05-06 12:33:40 +02:00
cpp.el
cwarn.el * lisp/progmodes/cwarn.el: Use lexical-binding. 2021-03-31 00:07:03 +02:00
dcl-mode.el * lisp/progmodes/dcl-mode.el: Clarify what is meant by DCL 2021-04-01 17:23:55 -04:00
ebnf-abn.el Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
ebnf-bnf.el * lisp/progmodes/ebnf-*.el: Use lexical-binding 2021-03-23 22:38:41 -04:00
ebnf-dtd.el * lisp/progmodes/ebnf-*.el: Use lexical-binding 2021-03-23 22:38:41 -04:00
ebnf-ebx.el * lisp/progmodes/ebnf-*.el: Use lexical-binding 2021-03-23 22:38:41 -04:00
ebnf-iso.el Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
ebnf-otz.el * lisp/progmodes/ebnf-*.el: Use lexical-binding 2021-03-23 22:38:41 -04:00
ebnf-yac.el Remove redundant #' before lambda in progmodes/*.el 2021-04-01 16:26:44 +02:00
ebnf2ps.el Remove redundant #' before lambda in progmodes/*.el 2021-04-01 16:26:44 +02:00
ebrowse.el Avoid lowering gc-cons-threshold 2021-04-22 04:11:02 +02:00
elisp-mode.el Rename comp-deferred-compilation 2021-05-11 18:31:45 +02:00
etags.el Replace "(default %s)" with 'format-prompt' 2021-03-24 10:31:31 +01:00
executable.el Use lexical-binding in executable.el and add tests 2021-04-01 19:55:32 +02:00
f90.el
flymake-cc.el
flymake-proc.el
flymake.el Fail earlier if stale Flymake report functions called 2021-04-10 11:19:34 +01:00
fortran.el
gdb-mi.el * lisp/progmodes/gud.el (gud-tooltip-tips): Use proper closures 2021-05-18 20:21:51 -04:00
glasses.el ; Remove some useless comments 2021-04-16 14:54:02 +02:00
grep.el Abbreviate rgrep command on MS Windows (bug#48302) 2021-05-12 10:47:07 +02:00
gud.el * lisp/progmodes/gud.el (gud-tooltip-tips): Use proper closures 2021-05-18 20:21:51 -04:00
hideif.el Fix incorrect regular expression for more general text replacements. 2021-03-31 11:42:33 +08:00
hideshow.el
icon.el Use lexical-binding in progmodes/icon.el 2021-02-27 03:24:51 +01:00
idlw-complete-structtag.el * list/progmodes/idl*.el: Use lexical-binding 2021-03-24 17:11:05 -04:00
idlw-help.el * list/progmodes/idl*.el: Use lexical-binding 2021-03-24 17:11:05 -04:00
idlw-shell.el ; Normalize and add missing first and last lines 2021-04-19 12:21:01 +02:00
idlw-toolbar.el * list/progmodes/idl*.el: Use lexical-binding 2021-03-24 17:11:05 -04:00
idlwave.el ; Normalize and add missing first and last lines 2021-04-19 12:21:01 +02:00
inf-lisp.el Remove redundant #' before lambda in progmodes/*.el 2021-04-01 16:26:44 +02:00
js.el * lisp/progmodes/js.el (js--make-framework-matcher): Use a closure 2021-05-18 20:30:08 -04:00
ld-script.el
m4-mode.el
make-mode.el
meta-mode.el ; Remove some useless comments 2021-04-16 14:54:02 +02:00
mixal-mode.el
modula2.el * lisp/progmodes/modula2.el: Use lexical-binding. 2021-03-24 06:25:36 +01:00
octave.el Remove redundant #' before lambda in progmodes/*.el 2021-04-01 16:26:44 +02:00
opascal.el * lisp/font-lock.el: Fix font-lock-comment-end-skip fallback (bug#34088) 2021-05-11 13:19:50 -04:00
pascal.el
perl-mode.el perl-mode: Fix regexps for fontification 2021-03-24 17:06:21 +01:00
prog-mode.el
project.el Shell-quote the directory when finding a project's files 2021-05-06 20:44:50 +03:00
prolog.el Remove redundant requires of easymenu 2021-02-26 15:52:26 +01:00
ps-mode.el * lisp/progmodes/ps-mode.el: Use lexical-binding 2021-04-06 14:05:58 -04:00
python.el ; Remove some useless comments 2021-04-16 14:54:02 +02:00
ruby-mode.el ruby-mode.el: puts and printf do not require args 2021-05-03 09:41:44 +02:00
scheme.el Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
sh-script.el Add :company-kind support to sh-mode completion 2021-05-15 03:44:16 +03:00
simula.el * lisp/progmodes/simula.el: Use lexical-binding 2021-04-02 19:51:41 -04:00
sql.el * lisp/progmodes/sql.el: `sql-postgres-statement-starters' defcustom 2021-05-19 15:07:52 +02:00
subword.el
tcl.el Replace "(default %s)" with 'format-prompt' 2021-03-24 10:31:31 +01:00
vera-mode.el Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
verilog-mode.el * lisp/progmodes/verilog-mode.el (vl-memory): Add missing defvar. 2021-04-12 13:36:05 -04:00
vhdl-mode.el * lisp/progmodes/vhdl-mode.el: Add note about XEmacs compatibility 2021-04-12 10:46:07 -04:00
which-func.el * lisp/progmodes/which-func.el: Doc fixes. 2021-04-22 18:06:36 +02:00
xref.el (completing-read): Add group-function to the completion metadata 2021-05-20 20:50:23 +03:00
xscheme.el