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