[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

20.6.6 Programmed Completion

Sometimes it is not possible to create an alist or an obarray containing all the intended possible completions. In such a case, you can supply your own function to compute the completion of a given string. This is called programmed completion.

To use this feature, pass a symbol with a function definition as the collection argument to completing-read. The function completing-read arranges to pass your completion function along to try-completion and all-completions, which will then let your function do all the work.

The completion function should accept three arguments:

There are three flag values for three operations:

It would be consistent and clean for completion functions to allow lambda expressions (lists that are functions) as well as function symbols as collection, but this is impossible. Lists as completion tables already have other meanings, and it would be unreliable to treat one differently just because it is also a possible function. So you must arrange for any function you wish to use for completion to be encapsulated in a symbol.

Emacs uses programmed completion when completing file names. Voir la section File Name Completion.

Macro: dynamic-completion-table function

This macro is a convenient way to write a function that can act as programmed completion function. The argument function should be a function that takes one argument, a string, and returns an alist of possible completions of it. You can think of dynamic-completion-table as a transducer between that interface and the interface for programmed completion functions.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.