]> code.delx.au - gnu-emacs/blob - doc/misc/eudc.texi
lisp/net/{eudc,ldap}: Merge branch streamline-eudc-configuration
[gnu-emacs] / doc / misc / eudc.texi
1 \input texinfo.tex
2 @c %**start of header
3 @setfilename ../../info/eudc.info
4 @settitle Emacs Unified Directory Client (EUDC) Manual
5 @afourpaper
6 @documentencoding UTF-8
7 @c %**end of header
8
9 @copying
10 This file documents EUDC v1.30b.
11
12 EUDC is the Emacs Unified Directory Client, a common interface to
13 directory servers using various protocols such as LDAP or the CCSO white
14 pages directory system (PH/QI)
15
16 Copyright @copyright{} 1998, 2000--2015 Free Software Foundation, Inc.
17
18 @quotation
19 Permission is granted to copy, distribute and/or modify this document
20 under the terms of the GNU Free Documentation License, Version 1.3 or
21 any later version published by the Free Software Foundation; with no
22 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
23 and with the Back-Cover Texts as in (a) below. A copy of the license
24 is included in the section entitled ``GNU Free Documentation License''.
25
26 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
27 modify this GNU manual.''
28 @end quotation
29 @end copying
30
31 @dircategory Emacs network features
32 @direntry
33 * EUDC: (eudc). Emacs client for directory servers (LDAP, PH).
34 @end direntry
35
36 @footnotestyle end
37
38 @titlepage
39 @title EUDC Manual
40 @subtitle The Emacs Unified Directory Client
41 @author by Oscar Figueiredo
42 @code{1.30b}
43
44 @page
45 @vskip 0pt plus 1fill
46 @insertcopying
47 @end titlepage
48
49 @contents
50
51 @ifnottex
52 @node Top
53 @top Emacs Unified Directory Client
54
55 @insertcopying
56 @end ifnottex
57
58 @menu
59 * Overview:: Summary of EUDC features
60 * Installation:: How to install EUDC
61 * Usage:: The various usage possibilities explained
62 * Credits:: Who's done what
63 * GNU Free Documentation License:: The license for this documentation.
64 * Command and Function Index::
65 * Variables Index::
66 @end menu
67
68
69
70
71
72 @node Overview
73 @chapter Overview
74
75 EUDC, the @dfn{Emacs Unified Directory Client}, provides a common user
76 interface to access directory servers using different directory
77 protocols.
78
79 Currently supported back-ends are:
80
81 @itemize @bullet
82 @item
83 LDAP, Lightweight Directory Access Protocol
84 @item
85 CCSO PH/QI
86 @item
87 BBDB, Big Brother's Insidious Database
88 @end itemize
89
90 The main features of the EUDC interface are:
91
92 @itemize @bullet
93 @item
94 Queries using a customizable form
95 @item
96 Inline query expansion (for instance you can expand a name
97 to an email address in a mail message buffer using a server as an
98 address book)
99 @item
100 Multiple servers can be tried in turn until a match is found for an
101 inline query
102 @item
103 Fast minibuffer queries for email addresses and phone numbers
104 @item
105 Interface to BBDB to let you insert server records into your own BBDB database
106 (@pxref{Top,,BBDB,bbdb,BBDB Manual})
107 @end itemize
108
109 @menu
110 * LDAP:: What is LDAP ?
111 * CCSO PH/QI:: What is CCSO, PH, QI ?
112 * BBDB:: What is BBDB ?
113 @end menu
114
115
116
117 @node LDAP
118 @section LDAP
119
120 LDAP, @dfn{the Lightweight Directory Access Protocol}, is a communication
121 protocol for directory applications defined in RFC 1777.
122
123 Quoted from RFC 1777:
124
125 @quotation
126 [LDAP] is designed to provide access to the X.500 Directory while not
127 incurring the resource requirements of the Directory Access Protocol
128 (DAP). This protocol is specifically targeted at simple management
129 applications and browser applications that provide simple read/write
130 interactive access to the X.500 Directory, and is intended to be a
131 complement to the DAP itself.
132 @end quotation
133
134 LDAP servers usually store (but are not limited to) information about
135 people such as their name, phone number, email address, office
136 location, etc@enddots{} More information about LDAP can be found at
137 @url{http://www.openldap.org/}.
138
139 EUDC requires external support to access LDAP directory servers
140 (@pxref{LDAP Configuration})
141
142
143 @node CCSO PH/QI
144 @section CCSO PH/QI
145
146 The Central Computing Services Office (CCSO) of the University of
147 Illinois at Urbana Champaign created and freely distributed a
148 directory system that was used by many organizations in the 1990s.
149 The system records information about people such as their address,
150 phone number, email, academic information or any other details it was
151 configured to. Nowadays this system is not widely used.
152
153 The system consists of two parts: a database server traditionally called
154 @samp{qi} and a command-line client called @samp{ph}.
155 @ignore
156 Until 2010, the code could be downloaded from
157 @url{http://www-dev.cites.uiuc.edu/ph/}.
158 @end ignore
159
160 The original command-line @samp{ph} client that came with the
161 @samp{ph/qi} distribution provided additional features that are
162 not implemented in EUDC, like the possibility to communicate with the
163 server in login-mode, which made it possible to change records in the
164 database.
165
166
167 @node BBDB
168 @section BBDB
169
170 BBDB is the @dfn{Big Brother's Insidious Database}, a package for Emacs
171 originally written by Jamie Zawinski which provides rolodex-like
172 database functionality featuring tight integration with the Emacs mail
173 and news readers.
174
175 It is often used as an enhanced email address book.
176
177 EUDC considers BBDB as a directory server back end just like LDAP or
178 PH/QI servers, though BBDB has no client/server protocol and thus always
179 resides locally on your machine. The point in this is not to offer an
180 alternate way to query your BBDB database (BBDB itself provides much
181 more flexible ways to do that), but rather to offer an interface to your
182 local directory that is consistent with the interface to external
183 directories (LDAP, PH/QI). This is particularly interesting when
184 performing queries on multiple servers.
185
186 EUDC also offers a means to insert results from directory queries into
187 your own local BBDB (@pxref{Creating BBDB Records})
188
189 @node Installation
190 @chapter Installation
191
192 Add the following to your @file{.emacs} init file:
193 @lisp
194 (require 'eudc)
195 @end lisp
196 This will install EUDC at startup.
197
198 After installing EUDC you will find (the next time you launch Emacs) a
199 new @code{Directory Search} submenu in the @samp{Tools} menu that will
200 give you access to EUDC.
201
202 You may also find it useful to add the following to your @file{.emacs}
203 initialization file to add a shortcut for email address expansion in
204 email composition buffers (@pxref{Inline Query Expansion})
205
206 @lisp
207 (eval-after-load
208 "message"
209 '(define-key message-mode-map [(control ?c) (tab)] 'eudc-expand-inline))
210 (eval-after-load
211 "sendmail"
212 '(define-key mail-mode-map [(control ?c) (tab)] 'eudc-expand-inline))
213 @end lisp
214
215 @menu
216 * LDAP Configuration:: EUDC needs external support for LDAP
217 @end menu
218
219 @node LDAP Configuration
220 @section LDAP Configuration
221
222 LDAP support is added by means of @file{ldap.el}, which is part of
223 Emacs. @file{ldap.el} needs an external command line utility named
224 @file{ldapsearch}, available as part of OpenLDAP
225 (@url{http://www.openldap.org/}). The configurations in this section
226 were tested with OpenLDAP 2.4.23.
227
228 The following examples use a base of
229 @code{ou=people,dc=example,dc=com} and the host name
230 @code{directory.example.com}, a server that supports LDAP-over-SSL
231 (the @code{ldaps} protocol, with default port @code{636}) and which
232 requires authentication by the user @code{emacsuser} with password
233 @code{s3cr3t}.
234
235 These configurations are meant to be self-contained; that is, each
236 provides everything required for sensible TAB-completion of email
237 fields. BBDB lookups are attempted first; if a matching BBDB entry is
238 found then EUDC will not attempt any LDAP lookups.
239
240 Wildcard LDAP lookups are supported using the @code{*} character. For
241 example, attempting to TAB-complete the following:
242
243 @example
244 To: * Smith
245 @end example
246
247 will return all LDAP entries with surnames that begin with
248 @code{Smith}. In every LDAP query it makes, EUDC implicitly appends
249 the wildcard character to the end of the last word.
250
251 @subsection Emacs-only Configuration
252
253 Emacs can pass most required configuration options via the
254 @file{ldapsearch} command-line. One exception is certificate
255 configuration for LDAP-over-SSL, which must be specified in
256 @file{/etc/openldap/ldap.conf}. On systems that provide such
257 certificates as part of the @code{OpenLDAP} installation, this can be
258 as simple as one line:
259
260 @example
261 TLS_CACERTDIR /etc/openldap/certs
262 @end example
263
264 In @file{.emacs}, these expressions suffice to configure EUDC for
265 LDAP:
266
267 @lisp
268 (eval-after-load "message"
269 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
270 (customize-set-variable 'eudc-server-hotlist
271 '(("" . bbdb)
272 ("ldaps://directory.example.com" . ldap)))
273 (customize-set-variable 'ldap-host-parameters-alist
274 '(("ldaps://directory.example.com"
275 base "ou=people,dc=example,dc=com"
276 binddn "example\\emacsuser"
277 passwd ldap-password-read)))
278 @end lisp
279
280 Specifying the function @code{ldap-password-read} for @code{passwd}
281 will cause Emacs to prompt interactively for the password. The
282 password will then be validated and cached, unless
283 @code{password-cache} is nil. You can customize
284 @code{password-cache-expiry} to control the duration for which the
285 password is cached. If you want to clear the cache, call
286 @code{password-reset}.
287
288 @subsection External Configuration
289
290 Your system may already be configured for a default LDAP server. For
291 example, @file{/etc/openldap/ldap.conf} might contain:
292
293 @example
294 BASE ou=people,dc=example,dc=com
295 URI ldaps://directory.example.com
296 TLS_CACERTDIR /etc/openldap/certs
297 @end example
298
299 To authenticate, the @dfn{bind distinguished name (binddn)} is
300 required, in this case, @code{example\emacsuser}, along with the
301 password. These can be specified in @file{~/.authinfo.gpg} with the
302 following line:
303
304 @example
305 machine ldaps://directory.example.com binddn example\emacsuser password s3cr3t
306 @end example
307
308 Then in the @file{.emacs} init file, these expressions suffice to
309 configure EUDC for LDAP:
310
311 @lisp
312 (eval-after-load "message"
313 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
314 (customize-set-variable 'eudc-server-hotlist
315 '(("" . bbdb)
316 ("ldaps://directory.example.com" . ldap)))
317 (customize-set-variable 'ldap-host-parameters-alist
318 '(("ldaps://directory.example.com"
319 auth-source t)))
320 @end lisp
321
322 For this example where we only care about one server, the server name
323 can be omitted in @file{~/.authinfo.gpg} and @file{.emacs}, in which
324 case @file{ldapsearch} defaults to the host name in
325 @file{/etc/openldap/ldap.conf}.
326
327 The @file{~/.authinfo.gpg} line becomes:
328
329 @example
330 binddn example\emacsuser password s3cr3t
331 @end example
332
333 and the @file{.emacs} expressions become:
334
335 @lisp
336 (eval-after-load "message"
337 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
338 (customize-set-variable 'eudc-server-hotlist '(("" . bbdb) ("" . ldap)))
339 (customize-set-variable 'ldap-host-parameters-alist '(("" auth-source t)))
340 @end lisp
341
342 @node Usage
343 @chapter Usage
344
345 This chapter describes the usage of EUDC@. Most functions and
346 customization options are available through the @samp{Directory Search}
347 submenu of the @samp{Tools} submenu.
348
349 @menu
350 * Querying Servers:: How queries are performed and handled
351 * Query Form:: How to use and customize the query form
352 * Display of Query Results:: Controlling how query results are presented
353 * Inline Query Expansion:: How to use and customize inline queries
354 * The Server Hotlist:: How to use and manage the server hotlist
355 * Multi-server Queries:: How to query multiple servers successively
356 * Creating BBDB Records:: How to insert query results into your BBDB
357 * Server/Protocol Locals:: Customizing on a per server/protocol basis
358 @end menu
359
360
361 @node Querying Servers
362 @section Querying Servers
363
364 EUDC's basic functionality is to let you query a directory server and
365 return the results back to you. There are several things you may want
366 to customize in this process.
367
368
369 @menu
370 * Selecting a Server:: The first thing to do
371 * Return Attributes:: Configuring what the server should return
372 * Duplicate Attributes:: What to do when records have duplicate attributes
373 @end menu
374
375 @node Selecting a Server
376 @subsection Selecting a Server
377
378 Before doing any query you will need to set the directory server. You
379 need to specify the name of the host machine running the server software
380 and the protocol to use. If you do not set the server in any fashion,
381 EUDC will ask you for one when you make your first query.
382
383 You can set the server by selecting one from your hotlist of servers
384 (@pxref{The Server Hotlist}) available in the @samp{Server} submenu or
385 by selecting @samp{New Server} in that same menu.
386
387 LDAP servers generally require some configuration before you can perform
388 queries on them. In particular, the @dfn{search base} must be
389 configured. If the server you select has no configured search base then
390 EUDC will propose you to configure it at this point. A customization
391 buffer will be displayed where you can edit the search base and other
392 parameters for the server.
393
394 @defvar eudc-server
395 The name or IP address of the remote directory server. A TCP port number
396 may be specified by appending a colon and a number to the name of the
397 server. You will not need this unless your server runs on a port other
398 than the default (which depends on the protocol).
399 If the directory server resides on your own computer (which is the case
400 if you use the BBDB back end) then `localhost' is a reasonable value but
401 it will be ignored anyway.
402 @end defvar
403
404 @defvar eudc-protocol
405 The directory protocol to use to query the server. Currently supported
406 protocols in this version of EUDC are @code{ph}, @code{ldap} and @code{bbdb}.
407 @end defvar
408
409 @deffn Command eudc-set-server
410 This command accessible from @samp{New Server} submenu lets you specify a
411 new directory server and protocol.
412 @end deffn
413
414 @node Return Attributes
415 @subsection Return Attributes
416
417 Directory servers may be configured to return a default set of
418 attributes for each record matching a query if the query specifies none.
419 The variable @code{eudc-default-return-attributes} controls the return
420 attributes you want to see, if different from the server defaults.
421
422 @defvar eudc-default-return-attributes
423 A list of the default attributes to extract from directory entries. If
424 set to the symbol @code{all} then all available attributes are
425 returned. A value of @code{nil}, the default, means to return the
426 default attributes as configured in the server.
427 @end defvar
428
429 The server may return several matching records to a query. Some of the
430 records may however not contain all the attributes you requested. You can
431 discard those records.
432
433 @defopt eudc-strict-return-matches
434 If non-@code{nil}, entries that do not contain all the requested return
435 attributes are ignored. Default is @code{t}.
436 @end defopt
437
438 @node Duplicate Attributes
439 @subsection Duplicate Attributes
440
441 Directory standards may authorize different instances of the same
442 attribute in a record. For instance the record of a person may contain
443 several email fields containing different email addresses. When using
444 a QI directory server this is difficult to distinguish from attributes
445 having multi-line values such as the postal address that may contain a
446 line for the street and another one for the zip code and city name. In
447 both cases, EUDC will consider the attribute duplicated.
448
449 EUDC has several methods to deal with duplicated attributes. The
450 available methods are:
451
452 @table @code
453 @item list
454 Makes a list with the different values of the duplicate attribute. The
455 record is returned with only one instance of the attribute with a list
456 of all the different values as a value. This is the default method that
457 is used to handle duplicate fields for which no other method has been
458 specified.
459 @item first
460 Discards all the duplicate values of the field keeping only the first
461 one.
462 @item concat
463 Concatenates the different values using a newline as a separator. The
464 record keeps only one instance of the field the value of which is a
465 single multi-line string.
466 @item duplicate
467 Duplicates the whole record into as many instances as there are different
468 values for the field. This is the default for the email field. Thus a
469 record containing 3 different email addresses is duplicated into three
470 different records each having a single email address. This is
471 particularly useful in combination with @code{select} as the method to
472 handle multiple matches in inline expansion queries (@pxref{Inline Query
473 Expansion}) because you are presented with the 3 addresses in a
474 selection buffer
475 @end table
476
477 Because a method may not be applicable to all fields, the variable
478 @code{eudc-duplicate-attribute-handling-method} lets you specify either a
479 default method for all fields or a method for each individual field.
480
481 @defvar eudc-duplicate-attribute-handling-method
482 A method to handle entries containing duplicate attributes. This is
483 either an alist of elements @code{(@var{attr} . @var{method})}, or a symbol
484 @var{method}. The alist form of the variable associates a method to an
485 individual attribute name; the second form specifies a method applicable
486 to all attribute names. Available methods are: @code{list},
487 @code{first}, @code{concat}, and @code{duplicate} (see above). The default is
488 @code{list}.
489 @end defvar
490
491
492
493 @node Query Form
494 @section Query Form
495
496 The simplest way to query your directory server is to use the query
497 form. You display the query form with the @samp{Query with Form} menu
498 item or by invoking the command @kbd{M-x eudc-query-form}. The attribute
499 names presented in this form are defined by the
500 @code{eudc-query-form-attributes} variable (unless a non-@code{nil}
501 argument is supplied to @code{eudc-query-form}).
502
503 Since the different directory protocols to which EUDC interfaces may
504 use different names for equivalent attributes, EUDC defines its own set
505 of attribute names and a mapping between these names and their
506 protocol-specific equivalent through the variable
507 @code{eudc-protocol-attributes-translation-alist}. Names currently
508 defined by EUDC are @code{name}, @code{firstname}, @code{email} and
509 @code{phone}.
510
511 @defvar eudc-query-form-attributes
512 @findex eudc-get-attribute-list
513 A list of attributes presented in the query form. Attribute names in
514 this list should be either EUDC attribute names or valid attribute
515 names. You can get a list of valid attribute names for the current
516 protocol with the @samp{List Valid Attribute Names} menu item or the
517 @kbd{M-x eudc-get-attribute-list} command. Defaults to @code{name},
518 @code{email} and @code{phone}.
519 @end defvar
520
521 @deffn Command eudc-query-form get-fields-from-server
522 Display a form to query the directory server. If given a non-@code{nil}
523 argument the function first queries the server for the existing fields
524 and displays a corresponding form. Not all protocols may support a
525 non-@code{nil} argument here.
526 @end deffn
527
528 Since the names of the fields may not be explicit enough or adapted to
529 be directly displayed as prompt strings in the form, the variable
530 @code{eudc-user-attribute-names-alist} lets you define more explicit
531 names for directory attribute names. This variable is ignored if
532 @code{eudc-use-raw-directory-names} is non-@code{nil}.
533
534 @defvar eudc-user-attribute-names-alist
535 This is an alist of user-defined names for the directory attributes used in
536 query/response forms. Prompt strings for attributes that are not in this
537 alist are derived by splitting the attribute name at underscores and
538 capitalizing the individual words.
539 @end defvar
540
541 @defvar eudc-use-raw-directory-names
542 If non-@code{nil}, use attributes names as defined in the directory.
543 Otherwise, directory query/response forms display the user attribute
544 names defined in @code{eudc-user-attribute-names-alist}.
545 @end defvar
546
547 @node Display of Query Results
548 @section Display of Query Results
549
550 Upon successful completion of a form query, EUDC will display a buffer
551 containing the results of the query.
552
553 The fields that are returned for each record
554 are controlled by @code{eudc-default-return-attributes} (@pxref{Return
555 Attributes}).
556
557 The display of each individual field can be performed by an arbitrary
558 function which allows specific processing for binary values, such as
559 images or audio samples, as well as values with semantics, such as
560 URLs.
561
562 @defvar eudc-attribute-display-method-alist
563 An alist specifying methods to display attribute values. Each member of
564 the list is of the form @code{(@var{name} . @var{func})} where
565 @var{name} is a lowercased string naming a directory attribute
566 (translated according to @code{eudc-user-attribute-names-alist} if
567 @code{eudc-use-raw-directory-names} is non-@code{nil}) and @var{func} a
568 function that will be passed the corresponding attribute values for
569 display.
570 @end defvar
571
572 This variable has protocol-local definitions (see @pxref{Server/Protocol
573 Locals}). For instance, it is defined as follows for LDAP:
574
575 @lisp
576 (eudc-protocol-set 'eudc-attribute-display-method-alist
577 '(("jpegphoto" . eudc-display-jpeg-inline)
578 ("labeledurl" . eudc-display-url)
579 ("audio" . eudc-display-sound)
580 ("labeledurl" . eudc-display-url)
581 ("url" . eudc-display-url))
582 'ldap)
583 @end lisp
584
585 EUDC provides a set of built-in functions to display binary value types:
586
587 @defun eudc-display-generic-binary data
588 Display a button for unidentified binary @var{data}.
589 @end defun
590
591 @defun eudc-display-url url
592 Display URL and make it clickable.
593 @end defun
594
595 @defun eudc-display-sound data
596 Display a button to play the sound @var{data}.
597 @end defun
598
599 @defun eudc-display-jpeg-inline data
600 Display the JPEG @var{data} inline at point if possible.
601 @end defun
602
603 @defun eudc-display-jpeg-as-button data
604 Display a button for the JPEG @var{data}.
605 @end defun
606
607 Right-clicking on a binary value button pops up a contextual menu with
608 options to process the value. Among these are saving the attribute
609 value to a file or sending it to an external viewer command. External
610 viewers should expect the value on their standard input and should
611 display it or perform arbitrary processing on it. Messages sent to
612 standard output are discarded. External viewers are listed in the
613 variable @code{eudc-external-viewers} which you can customize.
614
615 @defvar eudc-external-viewers
616 This is a list of viewer program specifications. Each specification is
617 a list whose first element is a string naming the viewer for unique
618 identification, the second element is the executable program which
619 should be invoked and the following elements are arguments that should
620 be passed to the program.
621 @end defvar
622
623
624 @node Inline Query Expansion
625 @section Inline Query Expansion
626
627 Inline query expansion is a powerful method to get completion from your
628 directory server. The most common usage is for expanding names to email
629 addresses in mail message buffers. The expansion is performed by the
630 command @kbd{M-x eudc-expand-inline} which is available from the
631 @samp{Expand Inline Query} menu item but can also be conveniently
632 bound to a key shortcut (@pxref{Installation}). The operation is
633 controlled by the variables @code{eudc-inline-expansion-format},
634 @code{eudc-inline-query-format},
635 @code{eudc-expanding-overwrites-query} and
636 @code{eudc-multiple-match-handling-method}.
637
638 If the query fails for a server, other servers may be tried successively
639 until one of them finds a match (@pxref{Multi-server Queries}).
640
641 @deffn Command eudc-expand-inline replace-p
642 Query the server and expand the query string before point. The query
643 string consists of the buffer substring from the point back to the
644 preceding comma, colon or beginning of
645 line. @code{eudc-inline-query-format} controls how individual words
646 are mapped onto directory attribute names. After querying the server
647 for the given string, the expansion specified by
648 @code{eudc-inline-expansion-format} is inserted in the buffer at
649 point. If @var{replace-p} is @code{t} then this expansion replaces the
650 query string in the buffer. If @code{eudc-expanding-overwrites-query}
651 is non-@code{nil} then the meaning of @var{replace-p} is negated.
652 @end deffn
653
654 @defvar eudc-inline-query-format
655 Format of an inline expansion query.
656 This is actually a list of @var{format}s. A @var{format} is a list of
657 one or more EUDC attribute names. A @var{format} applies if it contains
658 as many attributes as individual words in the inline query string. If
659 several @var{format}s apply then they are tried in order until a match
660 is found. If @code{nil} all the words will be mapped onto the default
661 server/protocol attribute name (generally @code{name}).
662
663 For instance, use the following
664 @lisp
665 (setq eudc-inline-query-format '((name)
666 (firstname)
667 (firstname name)))
668 @end lisp
669 @noindent
670 to indicate that single word expansion queries are to be considered as
671 surnames and if no match is found then they should be tried as first
672 names. Inline queries consisting of two words are considered as
673 consisting of a first name followed by a surname. If the query consists
674 of more than two words, then the first one is considered as the first
675 name and the remaining words are all considered as surname constituents.
676
677 @var{format}s are in fact not limited to EUDC attribute names, you can
678 use server or protocol specific names in them. It may be safer if you
679 do so, to set the variable @code{eudc-inline-query-format} in a protocol
680 or server local fashion (see @pxref{Server/Protocol Locals}).
681
682 For instance you could use the following to match up to three words
683 against the @code{cn} attribute of LDAP servers:
684 @lisp
685 (eudc-protocol-set 'eudc-inline-query-format
686 '((cn)
687 (cn cn)
688 (cn cn cn))
689 'ldap)
690 @end lisp
691 @end defvar
692
693 @defvar eudc-inline-expansion-format
694 This variable lets you control exactly what is inserted into the buffer
695 upon an inline expansion request. It is a list whose first element is a
696 string passed to @code{format}. Remaining elements are symbols
697 corresponding to directory attribute names. The corresponding attribute
698 values are passed as additional arguments to @code{format}. Default is
699 @code{("%s" email)} but you may want to consider a value like @code{("%s
700 <%s>" name email)}
701 @end defvar
702
703 @defvar eudc-multiple-match-handling-method
704 This variable controls what to do when multiple entries match a query
705 for an inline expansion. Possible values are:
706 @table @code
707 @item first
708 The first match is considered as being the only one, the others are
709 discarded.
710 @item select
711 A selection buffer pops up where you can choose a particular match. This
712 is the default value of the variable.
713 @item all
714 The expansion uses all records successively
715 @item abort
716 An error is signaled. The expansion aborts.
717 @end table
718
719 Default is @code{select}
720 @end defvar
721
722
723
724 @node The Server Hotlist
725 @section The Server Hotlist
726
727 EUDC lets you maintain a list of frequently used servers so that you
728 can easily switch from one to another. This hotlist appears in the
729 @samp{Server} submenu. You select a server in this list by clicking on
730 its name. You can add the current server to the list with the command
731 @kbd{M-x eudc-bookmark-current-server}. The list is contained in the variable
732 @code{eudc-server-hotlist} which is stored in and retrieved from the file
733 designated by @code{eudc-options-file}. EUDC also provides a facility to
734 edit the hotlist interactively (@pxref{The Hotlist Edit Buffer}).
735
736 The hotlist is also used to make queries on multiple servers
737 successively (@pxref{Multi-server Queries}). The order in which the
738 servers are tried is the order they appear in the hotlist, therefore it
739 is important to sort the hotlist appropriately.
740
741 @deffn Command eudc-bookmark-server server
742 Add @var{server} to the hotlist of servers
743 @end deffn
744
745 @deffn Command eudc-bookmark-current-server
746 Add the current server to the hotlist of servers
747 @end deffn
748
749 @defvar eudc-options-file
750 The name of a file where EUDC stores its internal variables
751 (the hotlist and the current server). EUDC will try to load
752 that file upon initialization so, if you choose a file name
753 different from the defaults @file{~/.eudc-options}, be sure to set this
754 variable to the appropriate value @emph{before} EUDC is itself
755 loaded.
756 @end defvar
757
758 @menu
759 * The Hotlist Edit Buffer:: An interactive hotlist editing facility
760 @end menu
761
762 @node The Hotlist Edit Buffer
763 @subsection The Hotlist Edit Buffer
764
765 The hotlist edit buffer offers a means to manage a list of frequently
766 used servers. Commands are available in the context pop-up menu
767 generally bound to the right mouse button. Those commands also have
768 equivalent key bindings.
769
770 @deffn Command eudc-hotlist-add-server
771 Bound to @kbd{a}.
772 Add a new server to the hotlist on the line after point
773 @end deffn
774
775 @deffn Command eudc-hotlist-delete-server
776 Bound to @kbd{d}.
777 Delete the server on the line point is on
778 @end deffn
779
780 @deffn Command eudc-hotlist-select-server
781 Bound to @kbd{s}.
782 Select the server the point is on as the current directory server for
783 the next queries
784 @end deffn
785
786 @deffn Command eudc-hotlist-transpose-servers
787 Bound to @kbd{t}.
788 Bubble up the server the point is on to the top of the list
789 @end deffn
790
791 @deffn Command eudc-hotlist-quit-edit
792 Bound to @kbd{q}.
793 Save the changes and quit the hotlist edit buffer. Use @kbd{x} or
794 @kbd{M-x kill-buffer} to exit without saving.
795 @end deffn
796
797
798 @node Multi-server Queries
799 @section Multi-server Queries
800
801 When using inline query expansion (@pxref{Inline Query Expansion}), EUDC
802 can try to query successively a sequence of directory servers until one
803 of them successfully finds a match for the query.
804
805 @defvar eudc-inline-expansion-servers
806 This variable controls which servers are tried and in which order when
807 trying to perform an inline query. Possible values are:
808 @table @code
809 @item current-server
810 Only the current directory server is tried
811 @item hotlist
812 The servers in the hotlist are tried in order until one finds a match
813 for the query or `eudc-max-servers-to-query' is reached
814 @item server-then-hotlist
815 The current server then the servers in the hotlist are tried in the
816 order they appear in the hotlist until one of them finds a match or
817 `eudc-max-servers-to-query' is reached. This is the default.
818 @end table
819 @end defvar
820
821 @defvar eudc-max-servers-to-query
822 This variable indicates the maximum number of servers to query when
823 performing a multi-server query. The default, @code{nil}, indicates
824 that all available servers should be tried.
825 @end defvar
826
827
828
829 @node Creating BBDB Records
830 @section Creating BBDB Records
831
832 @findex eudc-insert-record-at-point-into-bbdb
833 @findex eudc-try-bbdb-insert
834 With EUDC, you can automatically create BBDB records
835 (@pxref{Top,,BBDB,bbdb,BBDB Manual}) from records you get from a
836 directory server. You do this by moving point to the appropriate
837 record in a query result display buffer and invoking the command
838 @kbd{M-x eudc-insert-record-at-point-into-bbdb} with the
839 keyboard binding @kbd{b}@footnote{This key binding does not actually
840 call @code{eudc-insert-record-at-point-into-bbdb} but uses
841 @code{eudc-try-bbdb-insert} instead.}, or with the menu. EUDC
842 cannot update an existing BBDB record and will signal an error if you
843 try to insert a record matching an existing one.
844
845 @findex eudc-batch-export-records-to-bbdb
846 It is also possible to export to BBDB the whole batch of records
847 contained in the directory query result with the command
848 @kbd{M-x eudc-batch-export-records-to-bbdb}.
849
850 Because directory systems may not enforce a strict record format, local
851 server installations may use different attribute names and have
852 different ways to organize the information. Furthermore BBDB has its own
853 record structure. For these reasons converting a record from its
854 external directory format to the BBDB format is a highly customizable
855 process.
856
857 @defvar eudc-bbdb-conversion-alist
858 The value of this variable should be a symbol naming an alist defining a
859 mapping between BBDB field names onto directory attribute names records.
860 This is a protocol-local variable and is initialized upon protocol
861 switch (@pxref{Server/Protocol Locals}). The alist is made of cells of the
862 form @code{(@var{bbdb-field} . @var{spec-or-list})}.
863 @var{bbdb-field} is the name of a field
864 that must be defined in your BBDB environment (standard field names are
865 @code{name}, @code{company}, @code{net}, @code{phone}, @code{address}
866 and @code{notes}).
867 @var{spec-or-list} is either a single mapping specification or a list of
868 mapping specifications. Lists of mapping specifications are valid for
869 the @code{phone} and @code{address} BBDB fields only. @var{spec}s are
870 actually s-expressions which are evaluated as follows:
871
872 @table @asis
873 @item a string
874 evaluates to itself
875 @item a symbol
876 evaluates to the symbol value. Symbols corresponding to directory
877 attribute names present in the record evaluate to the value of the field
878 in the record
879 @item a form
880 is evaluated as a function. The argument list may contain attribute
881 names which evaluate to the corresponding values in the record. The form
882 evaluation should return something appropriate for the particular
883 @var{bbdb-field} (see @code{bbdb-create-internal}).
884 @code{eudc-bbdbify-phone} and @code{eudc-bbdbify-address} are provided as
885 convenience functions to parse phones and addresses.
886 @end table
887 @end defvar
888
889 The default value of the PH-specific value of that variable is
890 @code{eudc-ph-bbdb-conversion-alist}:
891
892 @lisp
893 ((name . name)
894 (net . email)
895 (address . (eudc-bbdbify-address address "Address"))
896 (phone . ((eudc-bbdbify-phone phone "Phone")
897 (eudc-bbdbify-phone office_phone "Office Phone"))))
898 @end lisp
899
900 This means that:
901
902 @itemize @bullet
903 @item
904 the @code{name} field of the BBDB record gets its value
905 from the @code{name} attribute of the directory record
906 @item
907 the @code{net} field of the BBDB record gets its value
908 from the @code{email} attribute of the directory record
909 @item
910 the @code{address} field of the BBDB record is obtained by parsing the
911 @code{address} attribute of the directory record with the function
912 @code{eudc-bbdbify-address}
913 @item
914 two @code{phone} fields are created (when possible) in the BBDB record.
915 The first one has @cite{Phone} for location and its value is obtained by
916 parsing the @code{phone} attribute of the PH/QI record with the function
917 @code{eudc-bbdbify-phone}. The second one has @cite{Office Phone} for location
918 its value is obtained by parsing the @code{office_phone} attribute of the
919 PH/QI record with the function @code{eudc-bbdbify-phone}.
920 @end itemize
921
922 @defun eudc-bbdbify-phone phone location
923 This is a convenience function provided for use in
924 @code{eudc-bbdb-conversion-alist}. It parses @var{phone} into a vector
925 compatible with @code{bbdb-create-internal}. @var{phone} is either a string
926 supposedly containing a phone number or a list of such strings which are
927 concatenated. @var{location} is used as the phone location for BBDB.
928 @end defun
929
930 @defun eudc-bbdbify-address addr location
931 This is a convenience function provided for use in
932 @code{eudc-bbdb-conversion-alist}. It parses @var{addr} into a vector
933 compatible with @code{bbdb-create-internal}. @var{addr} should be an
934 address string of no more than four lines or a list of lines. The last
935 line is searched for the zip code, city and state name. @var{location}
936 is used as the phone location for BBDB.
937 @end defun
938
939 Note that only a subset of the attributes you selected with
940 @code{eudc-default-return-attributes} and that are actually displayed may
941 actually be inserted as part of the newly created BBDB record.
942
943
944 @node Server/Protocol Locals
945 @section Server/Protocol Locals
946
947 EUDC can be customized independently for each server or directory
948 protocol. All variables can be given local bindings that are activated
949 when a particular server and/or protocol becomes active. This is much
950 like buffer-local bindings but on a per server or per protocol basis.
951
952 @menu
953 * Manipulating local bindings:: Functions to set and query local bindings
954 @end menu
955
956 @node Manipulating local bindings
957 @subsection Manipulating local bindings
958
959 EUDC offers functions that let you set and query variables on a per
960 server or per protocol basis.
961
962 The following predicates allow you to test the existence of
963 server/protocol local bindings for a particular variable.
964
965 @defun eudc-server-local-variable-p var
966 Return non-@code{nil} if @var{var} has server-local bindings
967 @end defun
968
969 @defun eudc-protocol-local-variable-p var
970 Return non-@code{nil} if @var{var} has protocol-local bindings
971 @end defun
972
973 The following functions allow you to set the value of a variable with
974 various degrees of locality.
975
976 @defun eudc-default-set var val
977 Set the EUDC default value of @var{var} to @var{val}.
978 The current binding of @var{var} (if local to the current server or
979 protocol) is not changed.
980 @end defun
981
982 @defun eudc-protocol-set var val &optional protocol
983 Set the binding of @var{var} local to @var{protocol} to @var{val}. If
984 omitted, @var{protocol} defaults to the current value of
985 @code{eudc-protocol}. The current binding of @var{var} is changed only
986 if @var{protocol} is omitted.
987 @end defun
988
989 @defun eudc-server-set var val &optional server
990 Set the binding of @var{var} local to @var{server} to @var{val}. If
991 omitted, @var{server} defaults to the current value of
992 @code{eudc-server}. The current binding of @var{var} is changed only if
993 @var{server} is omitted.
994 @end defun
995
996 @defun eudc-set var val
997 Set the most local (server, protocol or default) binding of @var{var} to
998 @var{val}. The current binding of @var{var} is also set to @var{val}.
999 @end defun
1000
1001 The following variables allow you to query the various bindings of a
1002 variable (local or non-local).
1003
1004 @defun eudc-variable-default-value var
1005 Return the default binding of @var{var} (outside of a particular server
1006 or protocol local binding).
1007 Return @code{unbound} if @var{var} has no EUDC default value.
1008 @end defun
1009
1010 @defun eudc-variable-protocol-value var &optional protocol
1011 Return the value of @var{var} local to @var{protocol}. Return
1012 @code{unbound} if @var{var} has no value local to @var{protocol}.
1013 @var{protocol} defaults to @code{eudc-protocol}.
1014 @end defun
1015
1016 @defun eudc-variable-server-value var [server]
1017 Return the value of @var{var} local to @var{server}.
1018 Return @code{unbound} if @var{var} has no value local to @var{server}.
1019 @var{server} defaults to @code{eudc-server}.
1020 @end defun
1021
1022 Changing a protocol-local or server-local value of a variable has no
1023 effect on its current value. The following command is used to
1024 synchronize the current values of variables with their local values
1025 given the current @code{eudc-server} and @code{eudc-protocol}:
1026
1027 @defun eudc-update-local-variables
1028 Update all EUDC variables according to their local settings.
1029 @end defun
1030
1031
1032
1033 @node Credits
1034 @chapter Credits
1035
1036 EUDC was written by Oscar Figueiredo based on @file{ph.el} by the
1037 same author.
1038
1039 Thanks to Soren Dayton for his suggestions, his enthusiasm and his help
1040 in testing and proofreading the code and docs of @file{ph.el}.
1041
1042 @node GNU Free Documentation License
1043 @appendix GNU Free Documentation License
1044 @include doclicense.texi
1045
1046 @node Command and Function Index
1047 @unnumbered Command and Function Index
1048
1049 @printindex fn
1050
1051 @node Variables Index
1052 @unnumbered Variables Index
1053
1054 @printindex vr
1055
1056 @bye