Next: , Previous: , Up: Usage   [Contents][Index]

3.4 Inline Query Expansion

Inline query expansion is a powerful method to get completion from your directory server. The most common usage is for expanding names to email addresses in mail message buffers. The expansion is performed by the command M-x eudc-expand-inline which is available from the ‘Expand Inline Query’ menu item but can also be conveniently bound to a key shortcut (see Installation). The operation is controlled by the variables eudc-inline-expansion-format, eudc-inline-query-format, eudc-expanding-overwrites-query and eudc-multiple-match-handling-method.

If the query fails for a server, other servers may be tried successively until one of them finds a match (see Multi-server Queries).

Command: eudc-expand-inline replace-p

Query the server and expand the query string before point. The query string consists of the buffer substring from the point back to the preceding comma, colon or beginning of line. eudc-inline-query-format controls how individual words are mapped onto directory attribute names. After querying the server for the given string, the expansion specified by eudc-inline-expansion-format is inserted in the buffer at point. If replace-p is t then this expansion replaces the query string in the buffer. If eudc-expanding-overwrites-query is non-nil then the meaning of replace-p is negated.

Variable: eudc-inline-query-format

Format of an inline expansion query. This is actually a list of formats. A format is a list of one or more EUDC attribute names. A format applies if it contains as many attributes as individual words in the inline query string. If several formats apply then they are tried in order until a match is found. If nil all the words will be mapped onto the default server/protocol attribute name (generally name).

For instance, use the following

(setq eudc-inline-query-format '((name)
                                 (firstname)
                                 (firstname name)))

to indicate that single word expansion queries are to be considered as surnames and if no match is found then they should be tried as first names. Inline queries consisting of two words are considered as consisting of a first name followed by a surname. If the query consists of more than two words, then the first one is considered as the first name and the remaining words are all considered as surname constituents.

formats are in fact not limited to EUDC attribute names, you can use server or protocol specific names in them. It may be safer if you do so, to set the variable eudc-inline-query-format in a protocol or server local fashion (see see Server/Protocol Locals).

For instance you could use the following to match up to three words against the cn attribute of LDAP servers:

(eudc-protocol-set 'eudc-inline-query-format
                   '((cn)
                     (cn cn)
                     (cn cn cn))
                   'ldap)
Variable: eudc-inline-expansion-format

This variable lets you control exactly what is inserted into the buffer upon an inline expansion request. It is a list whose first element is a string passed to format. Remaining elements are symbols corresponding to directory attribute names. The corresponding attribute values are passed as additional arguments to format. Default is ("%s" email) but you may want to consider a value like ("%s <%s>" name email)

Variable: eudc-multiple-match-handling-method

This variable controls what to do when multiple entries match a query for an inline expansion. Possible values are:

first

The first match is considered as being the only one, the others are discarded.

select

A selection buffer pops up where you can choose a particular match. This is the default value of the variable.

all

The expansion uses all records successively

abort

An error is signaled. The expansion aborts.

Default is select

Next: , Previous: , Up: Usage   [Contents][Index]