]> code.delx.au - gnu-emacs/blob - doc/misc/eudc.texi
Merge branch 'map'
[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 @include docstyle.texi
6 @afourpaper
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=gnu,dc=org} 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 * Troubleshooting:: Debug @command{ldapsearch} failures
278 @end menu
279
280 @node Emacs-only Configuration
281 @subsection Emacs-only Configuration
282
283 Emacs can pass most required configuration options via the
284 @command{ldapsearch} command-line. One exception is certificate
285 configuration for LDAP-over-SSL, which must be specified in
286 @file{/etc/openldap/ldap.conf}. On systems that provide such
287 certificates as part of the @code{OpenLDAP} installation, this can be
288 as simple as one line:
289
290 @example
291 TLS_CACERTDIR /etc/openldap/certs
292 @end example
293
294 In @file{.emacs}, these expressions suffice to configure EUDC for
295 LDAP:
296
297 @vindex message-mode-map
298 @findex eudc-expand-inline
299 @vindex eudc-server-hotlist
300 @vindex ldap-host-parameters-alist
301 @lisp
302 (eval-after-load "message"
303 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
304 (customize-set-variable 'eudc-server-hotlist
305 '(("" . bbdb)
306 ("ldaps://ldap.gnu.org" . ldap)))
307 (customize-set-variable 'ldap-host-parameters-alist
308 '(("ldaps://ldap.gnu.org"
309 base "ou=people,dc=gnu,dc=org"
310 binddn "gnu\\emacsuser"
311 passwd ldap-password-read)))
312 @end lisp
313
314 @findex ldap-password-read
315 @vindex passwd
316 @vindex password-cache
317 @vindex password-cache-expiry
318 @findex password-reset
319 Specifying the function @code{ldap-password-read} for @code{passwd}
320 will cause Emacs to prompt interactively for the password. The
321 password will then be validated and cached, unless
322 @code{password-cache} is nil. You can customize
323 @code{password-cache-expiry} to control the duration for which the
324 password is cached. If you want to clear the cache, call
325 @code{password-reset}.
326
327 @node External Configuration
328 @subsection External Configuration
329
330 Your system may already be configured for a default LDAP server. For
331 example, @file{/etc/openldap/ldap.conf} might contain:
332
333 @example
334 BASE ou=people,dc=gnu,dc=org
335 URI ldaps://ldap.gnu.org
336 TLS_CACERTDIR /etc/openldap/certs
337 @end example
338
339 @cindex bind distinguished name
340 @cindex binddn
341 Authentication requires a password, and a @dfn{bind distinguished name
342 (binddn)} representing the user, in this case,
343 @code{gnu\emacsuser}. These can be specified in
344 @file{~/.authinfo.gpg} with the following line:
345
346 @example
347 machine ldaps://ldap.gnu.org binddn gnu\emacsuser password s3cr3t
348 @end example
349
350 Then in the @file{.emacs} init file, these expressions suffice to
351 configure EUDC for LDAP:
352
353 @vindex message-mode-map
354 @findex eudc-expand-inline
355 @vindex eudc-server-hotlist
356 @vindex ldap-host-parameters-alist
357 @lisp
358 (eval-after-load "message"
359 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
360 (customize-set-variable 'eudc-server-hotlist
361 '(("" . bbdb)
362 ("ldaps://ldap.gnu.org" . ldap)))
363 (customize-set-variable 'ldap-host-parameters-alist
364 '(("ldaps://ldap.gnu.org"
365 auth-source t)))
366 @end lisp
367
368 For this example where we only care about one server, the server name
369 can be omitted in @file{~/.authinfo.gpg} and @file{.emacs}, in which
370 case @command{ldapsearch} defaults to the host name in
371 @file{/etc/openldap/ldap.conf}.
372
373 The @file{~/.authinfo.gpg} line becomes:
374
375 @example
376 binddn gnu\emacsuser password s3cr3t
377 @end example
378
379 @noindent
380 and the @file{.emacs} expressions become:
381
382 @vindex message-mode-map
383 @findex eudc-expand-inline
384 @vindex eudc-server-hotlist
385 @vindex ldap-host-parameters-alist
386 @lisp
387 (eval-after-load "message"
388 '(define-key message-mode-map (kbd "TAB") 'eudc-expand-inline))
389 (customize-set-variable 'eudc-server-hotlist
390 '(("" . bbdb) ("" . ldap)))
391 (customize-set-variable 'ldap-host-parameters-alist
392 '(("" auth-source t)))
393 @end lisp
394
395 @node Troubleshooting
396 @subsection Troubleshooting
397
398 If @command{ldapsearch} exits with an error, you'll see a message like
399 this in the @code{*Messages*} buffer (all on one line):
400
401 @example
402 ldap-search-internal: Failed ldapsearch invocation:
403 ldapsearch "-Hldaps://ldap.gnu.org" "-bou=people,dc=gnu,dc=org"
404 "-Dgnu\emacsuser" "-W" "-LL" "-tt" "(&(mail=name*))"
405 "givenname" "sn" "mail"
406 @end example
407
408 The @command{ldapsearch} command is formatted such that it can be
409 copied and pasted into a terminal. Set the @command{ldapsearch} debug
410 level to 5 by appending @code{-d 5} to the command line.
411
412 @node Usage
413 @chapter Usage
414
415 This chapter describes the usage of EUDC@. Most functions and
416 customization options are available through the @samp{Directory Search}
417 submenu of the @samp{Tools} submenu.
418
419 @menu
420 * Querying Servers:: How queries are performed and handled
421 * Query Form:: How to use and customize the query form
422 * Display of Query Results:: Controlling how query results are presented
423 * Inline Query Expansion:: How to use and customize inline queries
424 * The Server Hotlist:: How to use and manage the server hotlist
425 * Multi-server Queries:: How to query multiple servers successively
426 * Creating BBDB Records:: How to insert query results into your BBDB
427 * Server/Protocol Locals:: Customizing on a per server/protocol basis
428 @end menu
429
430
431 @node Querying Servers
432 @section Querying Servers
433
434 EUDC's basic functionality is to let you query a directory server and
435 return the results back to you. There are several things you may want
436 to customize in this process.
437
438
439 @menu
440 * Selecting a Server:: The first thing to do
441 * Return Attributes:: Configuring what the server should return
442 * Duplicate Attributes:: What to do when records have duplicate attributes
443 @end menu
444
445 @node Selecting a Server
446 @subsection Selecting a Server
447
448 Before doing any query you will need to set the directory server. You
449 need to specify the name of the host machine running the server software
450 and the protocol to use. If you do not set the server in any fashion,
451 EUDC will ask you for one when you make your first query.
452
453 You can set the server by selecting one from your hotlist of servers
454 (@pxref{The Server Hotlist}) available in the @samp{Server} submenu or
455 by selecting @samp{New Server} in that same menu.
456
457 LDAP servers generally require some configuration before you can perform
458 queries on them. In particular, the @dfn{search base} must be
459 configured. If the server you select has no configured search base then
460 EUDC will propose you to configure it at this point. A customization
461 buffer will be displayed where you can edit the search base and other
462 parameters for the server.
463
464 @defvar eudc-server
465 The name or IP address of the remote directory server. A TCP port number
466 may be specified by appending a colon and a number to the name of the
467 server. You will not need this unless your server runs on a port other
468 than the default (which depends on the protocol).
469 If the directory server resides on your own computer (which is the case
470 if you use the BBDB back end) then @samp{localhost} is a reasonable value but
471 it will be ignored anyway.
472 @end defvar
473
474 @defvar eudc-protocol
475 The directory protocol to use to query the server. Currently supported
476 protocols in this version of EUDC are @code{ph}, @code{ldap} and @code{bbdb}.
477 @end defvar
478
479 @deffn Command eudc-set-server
480 This command accessible from @samp{New Server} submenu lets you specify a
481 new directory server and protocol.
482 @end deffn
483
484 @node Return Attributes
485 @subsection Return Attributes
486
487 Directory servers may be configured to return a default set of
488 attributes for each record matching a query if the query specifies none.
489 The variable @code{eudc-default-return-attributes} controls the return
490 attributes you want to see, if different from the server defaults.
491
492 @defvar eudc-default-return-attributes
493 A list of the default attributes to extract from directory entries. If
494 set to the symbol @code{all} then all available attributes are
495 returned. A value of @code{nil}, the default, means to return the
496 default attributes as configured in the server.
497 @end defvar
498
499 The server may return several matching records to a query. Some of the
500 records may however not contain all the attributes you requested. You can
501 discard those records.
502
503 @defopt eudc-strict-return-matches
504 If non-@code{nil}, entries that do not contain all the requested return
505 attributes are ignored. Default is @code{t}.
506 @end defopt
507
508 @node Duplicate Attributes
509 @subsection Duplicate Attributes
510
511 Directory standards may authorize different instances of the same
512 attribute in a record. For instance the record of a person may contain
513 several email fields containing different email addresses. When using
514 a QI directory server this is difficult to distinguish from attributes
515 having multi-line values such as the postal address that may contain a
516 line for the street and another one for the zip code and city name. In
517 both cases, EUDC will consider the attribute duplicated.
518
519 EUDC has several methods to deal with duplicated attributes. The
520 available methods are:
521
522 @table @code
523 @item list
524 Makes a list with the different values of the duplicate attribute. The
525 record is returned with only one instance of the attribute with a list
526 of all the different values as a value. This is the default method that
527 is used to handle duplicate fields for which no other method has been
528 specified.
529 @item first
530 Discards all the duplicate values of the field keeping only the first
531 one.
532 @item concat
533 Concatenates the different values using a newline as a separator. The
534 record keeps only one instance of the field the value of which is a
535 single multi-line string.
536 @item duplicate
537 Duplicates the whole record into as many instances as there are different
538 values for the field. This is the default for the email field. Thus a
539 record containing 3 different email addresses is duplicated into three
540 different records each having a single email address. This is
541 particularly useful in combination with @code{select} as the method to
542 handle multiple matches in inline expansion queries (@pxref{Inline Query
543 Expansion}) because you are presented with the 3 addresses in a
544 selection buffer
545 @end table
546
547 Because a method may not be applicable to all fields, the variable
548 @code{eudc-duplicate-attribute-handling-method} lets you specify either a
549 default method for all fields or a method for each individual field.
550
551 @defvar eudc-duplicate-attribute-handling-method
552 A method to handle entries containing duplicate attributes. This is
553 either an alist of elements @code{(@var{attr} . @var{method})}, or a symbol
554 @var{method}. The alist form of the variable associates a method to an
555 individual attribute name; the second form specifies a method applicable
556 to all attribute names. Available methods are: @code{list},
557 @code{first}, @code{concat}, and @code{duplicate} (see above). The default is
558 @code{list}.
559 @end defvar
560
561
562
563 @node Query Form
564 @section Query Form
565
566 The simplest way to query your directory server is to use the query
567 form. You display the query form with the @samp{Query with Form} menu
568 item or by invoking the command @kbd{M-x eudc-query-form}. The attribute
569 names presented in this form are defined by the
570 @code{eudc-query-form-attributes} variable (unless a non-@code{nil}
571 argument is supplied to @code{eudc-query-form}).
572
573 Since the different directory protocols to which EUDC interfaces may
574 use different names for equivalent attributes, EUDC defines its own set
575 of attribute names and a mapping between these names and their
576 protocol-specific equivalent through the variable
577 @code{eudc-protocol-attributes-translation-alist}. Names currently
578 defined by EUDC are @code{name}, @code{firstname}, @code{email} and
579 @code{phone}.
580
581 @defvar eudc-query-form-attributes
582 @findex eudc-get-attribute-list
583 A list of attributes presented in the query form. Attribute names in
584 this list should be either EUDC attribute names or valid attribute
585 names. You can get a list of valid attribute names for the current
586 protocol with the @samp{List Valid Attribute Names} menu item or the
587 @kbd{M-x eudc-get-attribute-list} command. Defaults to @code{name},
588 @code{email} and @code{phone}.
589 @end defvar
590
591 @deffn Command eudc-query-form get-fields-from-server
592 Display a form to query the directory server. If given a non-@code{nil}
593 argument the function first queries the server for the existing fields
594 and displays a corresponding form. Not all protocols may support a
595 non-@code{nil} argument here.
596 @end deffn
597
598 Since the names of the fields may not be explicit enough or adapted to
599 be directly displayed as prompt strings in the form, the variable
600 @code{eudc-user-attribute-names-alist} lets you define more explicit
601 names for directory attribute names. This variable is ignored if
602 @code{eudc-use-raw-directory-names} is non-@code{nil}.
603
604 @defvar eudc-user-attribute-names-alist
605 This is an alist of user-defined names for the directory attributes used in
606 query/response forms. Prompt strings for attributes that are not in this
607 alist are derived by splitting the attribute name at underscores and
608 capitalizing the individual words.
609 @end defvar
610
611 @defvar eudc-use-raw-directory-names
612 If non-@code{nil}, use attributes names as defined in the directory.
613 Otherwise, directory query/response forms display the user attribute
614 names defined in @code{eudc-user-attribute-names-alist}.
615 @end defvar
616
617 @node Display of Query Results
618 @section Display of Query Results
619
620 Upon successful completion of a form query, EUDC will display a buffer
621 containing the results of the query.
622
623 The fields that are returned for each record
624 are controlled by @code{eudc-default-return-attributes} (@pxref{Return
625 Attributes}).
626
627 The display of each individual field can be performed by an arbitrary
628 function which allows specific processing for binary values, such as
629 images or audio samples, as well as values with semantics, such as
630 URLs.
631
632 @defvar eudc-attribute-display-method-alist
633 An alist specifying methods to display attribute values. Each member of
634 the list is of the form @code{(@var{name} . @var{func})} where
635 @var{name} is a lowercased string naming a directory attribute
636 (translated according to @code{eudc-user-attribute-names-alist} if
637 @code{eudc-use-raw-directory-names} is non-@code{nil}) and @var{func} a
638 function that will be passed the corresponding attribute values for
639 display.
640 @end defvar
641
642 This variable has protocol-local definitions (see @pxref{Server/Protocol
643 Locals}). For instance, it is defined as follows for LDAP:
644
645 @lisp
646 (eudc-protocol-set 'eudc-attribute-display-method-alist
647 '(("jpegphoto" . eudc-display-jpeg-inline)
648 ("labeledurl" . eudc-display-url)
649 ("audio" . eudc-display-sound)
650 ("labeledurl" . eudc-display-url)
651 ("url" . eudc-display-url))
652 'ldap)
653 @end lisp
654
655 EUDC provides a set of built-in functions to display binary value types:
656
657 @defun eudc-display-generic-binary data
658 Display a button for unidentified binary @var{data}.
659 @end defun
660
661 @defun eudc-display-url url
662 Display URL and make it clickable.
663 @end defun
664
665 @defun eudc-display-sound data
666 Display a button to play the sound @var{data}.
667 @end defun
668
669 @defun eudc-display-jpeg-inline data
670 Display the JPEG @var{data} inline at point if possible.
671 @end defun
672
673 @defun eudc-display-jpeg-as-button data
674 Display a button for the JPEG @var{data}.
675 @end defun
676
677 Right-clicking on a binary value button pops up a contextual menu with
678 options to process the value. Among these are saving the attribute
679 value to a file or sending it to an external viewer command. External
680 viewers should expect the value on their standard input and should
681 display it or perform arbitrary processing on it. Messages sent to
682 standard output are discarded. External viewers are listed in the
683 variable @code{eudc-external-viewers} which you can customize.
684
685 @defvar eudc-external-viewers
686 This is a list of viewer program specifications. Each specification is
687 a list whose first element is a string naming the viewer for unique
688 identification, the second element is the executable program which
689 should be invoked and the following elements are arguments that should
690 be passed to the program.
691 @end defvar
692
693
694 @node Inline Query Expansion
695 @section Inline Query Expansion
696
697 Inline query expansion is a powerful method to get completion from your
698 directory server. The most common usage is for expanding names to email
699 addresses in mail message buffers. The expansion is performed by the
700 command @kbd{M-x eudc-expand-inline} which is available from the
701 @samp{Expand Inline Query} menu item but can also be conveniently
702 bound to a key shortcut (@pxref{Installation}). The operation is
703 controlled by the variables @code{eudc-inline-expansion-format},
704 @code{eudc-inline-query-format},
705 @code{eudc-expanding-overwrites-query} and
706 @code{eudc-multiple-match-handling-method}.
707
708 If the query fails for a server, other servers may be tried successively
709 until one of them finds a match (@pxref{Multi-server Queries}).
710
711 @deffn Command eudc-expand-inline replace-p
712 Query the server and expand the query string before point. The query
713 string consists of the buffer substring from the point back to the
714 preceding comma, colon or beginning of
715 line. @code{eudc-inline-query-format} controls how individual words
716 are mapped onto directory attribute names. After querying the server
717 for the given string, the expansion specified by
718 @code{eudc-inline-expansion-format} is inserted in the buffer at
719 point. If @var{replace-p} is @code{t} then this expansion replaces the
720 query string in the buffer. If @code{eudc-expanding-overwrites-query}
721 is non-@code{nil} then the meaning of @var{replace-p} is negated.
722 @end deffn
723
724 @defvar eudc-inline-query-format
725 Format of an inline expansion query.
726 This is actually a list of @var{format}s. A @var{format} is a list of
727 one or more EUDC attribute names. A @var{format} applies if it contains
728 as many attributes as individual words in the inline query string. If
729 several @var{format}s apply then they are tried in order until a match
730 is found. If @code{nil} all the words will be mapped onto the default
731 server/protocol attribute name (generally @code{name}).
732
733 For instance, use the following
734 @lisp
735 (setq eudc-inline-query-format '((name)
736 (firstname)
737 (firstname name)))
738 @end lisp
739 @noindent
740 to indicate that single word expansion queries are to be considered as
741 surnames and if no match is found then they should be tried as first
742 names. Inline queries consisting of two words are considered as
743 consisting of a first name followed by a surname. If the query consists
744 of more than two words, then the first one is considered as the first
745 name and the remaining words are all considered as surname constituents.
746
747 @var{format}s are in fact not limited to EUDC attribute names, you can
748 use server or protocol specific names in them. It may be safer if you
749 do so, to set the variable @code{eudc-inline-query-format} in a protocol
750 or server local fashion (see @pxref{Server/Protocol Locals}).
751
752 For instance you could use the following to match up to three words
753 against the @code{cn} attribute of LDAP servers:
754 @lisp
755 (eudc-protocol-set 'eudc-inline-query-format
756 '((cn)
757 (cn cn)
758 (cn cn cn))
759 'ldap)
760 @end lisp
761 @end defvar
762
763 @defvar eudc-inline-expansion-format
764 This variable lets you control exactly what is inserted into the buffer
765 upon an inline expansion request. It is a list whose first element is a
766 string passed to @code{format}. Remaining elements are symbols
767 corresponding to directory attribute names. The corresponding attribute
768 values are passed as additional arguments to @code{format}. Default is
769 @code{("%s" email)} but you may want to consider a value like @code{("%s
770 <%s>" name email)}
771 @end defvar
772
773 @defvar eudc-multiple-match-handling-method
774 This variable controls what to do when multiple entries match a query
775 for an inline expansion. Possible values are:
776 @table @code
777 @item first
778 The first match is considered as being the only one, the others are
779 discarded.
780 @item select
781 A selection buffer pops up where you can choose a particular match. This
782 is the default value of the variable.
783 @item all
784 The expansion uses all records successively
785 @item abort
786 An error is signaled. The expansion aborts.
787 @end table
788
789 Default is @code{select}
790 @end defvar
791
792
793
794 @node The Server Hotlist
795 @section The Server Hotlist
796
797 EUDC lets you maintain a list of frequently used servers so that you
798 can easily switch from one to another. This hotlist appears in the
799 @samp{Server} submenu. You select a server in this list by clicking on
800 its name. You can add the current server to the list with the command
801 @kbd{M-x eudc-bookmark-current-server}. The list is contained in the variable
802 @code{eudc-server-hotlist} which is stored in and retrieved from the file
803 designated by @code{eudc-options-file}. EUDC also provides a facility to
804 edit the hotlist interactively (@pxref{The Hotlist Edit Buffer}).
805
806 The hotlist is also used to make queries on multiple servers
807 successively (@pxref{Multi-server Queries}). The order in which the
808 servers are tried is the order they appear in the hotlist, therefore it
809 is important to sort the hotlist appropriately.
810
811 @deffn Command eudc-bookmark-server server
812 Add @var{server} to the hotlist of servers
813 @end deffn
814
815 @deffn Command eudc-bookmark-current-server
816 Add the current server to the hotlist of servers
817 @end deffn
818
819 @defvar eudc-options-file
820 The name of a file where EUDC stores its internal variables
821 (the hotlist and the current server). EUDC will try to load
822 that file upon initialization so, if you choose a file name
823 different from the defaults @file{~/.eudc-options}, be sure to set this
824 variable to the appropriate value @emph{before} EUDC is itself
825 loaded.
826 @end defvar
827
828 @menu
829 * The Hotlist Edit Buffer:: An interactive hotlist editing facility
830 @end menu
831
832 @node The Hotlist Edit Buffer
833 @subsection The Hotlist Edit Buffer
834
835 The hotlist edit buffer offers a means to manage a list of frequently
836 used servers. Commands are available in the context pop-up menu
837 generally bound to the right mouse button. Those commands also have
838 equivalent key bindings.
839
840 @deffn Command eudc-hotlist-add-server
841 Bound to @kbd{a}.
842 Add a new server to the hotlist on the line after point
843 @end deffn
844
845 @deffn Command eudc-hotlist-delete-server
846 Bound to @kbd{d}.
847 Delete the server on the line point is on
848 @end deffn
849
850 @deffn Command eudc-hotlist-select-server
851 Bound to @kbd{s}.
852 Select the server the point is on as the current directory server for
853 the next queries
854 @end deffn
855
856 @deffn Command eudc-hotlist-transpose-servers
857 Bound to @kbd{t}.
858 Bubble up the server the point is on to the top of the list
859 @end deffn
860
861 @deffn Command eudc-hotlist-quit-edit
862 Bound to @kbd{q}.
863 Save the changes and quit the hotlist edit buffer. Use @kbd{x} or
864 @kbd{M-x kill-buffer} to exit without saving.
865 @end deffn
866
867
868 @node Multi-server Queries
869 @section Multi-server Queries
870
871 When using inline query expansion (@pxref{Inline Query Expansion}), EUDC
872 can try to query successively a sequence of directory servers until one
873 of them successfully finds a match for the query.
874
875 @defvar eudc-inline-expansion-servers
876 This variable controls which servers are tried and in which order when
877 trying to perform an inline query. Possible values are:
878 @table @code
879 @item current-server
880 Only the current directory server is tried
881 @item hotlist
882 The servers in the hotlist are tried in order until one finds a match
883 for the query or @code{eudc-max-servers-to-query} is reached
884 @item server-then-hotlist
885 The current server then the servers in the hotlist are tried in the
886 order they appear in the hotlist until one of them finds a match or
887 @code{eudc-max-servers-to-query} is reached. This is the default.
888 @end table
889 @end defvar
890
891 @defvar eudc-max-servers-to-query
892 This variable indicates the maximum number of servers to query when
893 performing a multi-server query. The default, @code{nil}, indicates
894 that all available servers should be tried.
895 @end defvar
896
897
898
899 @node Creating BBDB Records
900 @section Creating BBDB Records
901
902 @findex eudc-insert-record-at-point-into-bbdb
903 @findex eudc-try-bbdb-insert
904 With EUDC, you can automatically create BBDB records
905 (@pxref{Top,,BBDB,bbdb,BBDB Manual}) from records you get from a
906 directory server. You do this by moving point to the appropriate
907 record in a query result display buffer and invoking the command
908 @kbd{M-x eudc-insert-record-at-point-into-bbdb} with the
909 keyboard binding @kbd{b}@footnote{This key binding does not actually
910 call @code{eudc-insert-record-at-point-into-bbdb} but uses
911 @code{eudc-try-bbdb-insert} instead.}, or with the menu. EUDC
912 cannot update an existing BBDB record and will signal an error if you
913 try to insert a record matching an existing one.
914
915 @findex eudc-batch-export-records-to-bbdb
916 It is also possible to export to BBDB the whole batch of records
917 contained in the directory query result with the command
918 @kbd{M-x eudc-batch-export-records-to-bbdb}.
919
920 Because directory systems may not enforce a strict record format, local
921 server installations may use different attribute names and have
922 different ways to organize the information. Furthermore BBDB has its own
923 record structure. For these reasons converting a record from its
924 external directory format to the BBDB format is a highly customizable
925 process.
926
927 @defvar eudc-bbdb-conversion-alist
928 The value of this variable should be a symbol naming an alist defining a
929 mapping between BBDB field names onto directory attribute names records.
930 This is a protocol-local variable and is initialized upon protocol
931 switch (@pxref{Server/Protocol Locals}). The alist is made of cells of the
932 form @code{(@var{bbdb-field} . @var{spec-or-list})}.
933 @var{bbdb-field} is the name of a field
934 that must be defined in your BBDB environment (standard field names are
935 @code{name}, @code{company}, @code{net}, @code{phone}, @code{address}
936 and @code{notes}).
937 @var{spec-or-list} is either a single mapping specification or a list of
938 mapping specifications. Lists of mapping specifications are valid for
939 the @code{phone} and @code{address} BBDB fields only. @var{spec}s are
940 actually s-expressions which are evaluated as follows:
941
942 @table @asis
943 @item a string
944 evaluates to itself
945 @item a symbol
946 evaluates to the symbol value. Symbols corresponding to directory
947 attribute names present in the record evaluate to the value of the field
948 in the record
949 @item a form
950 is evaluated as a function. The argument list may contain attribute
951 names which evaluate to the corresponding values in the record. The form
952 evaluation should return something appropriate for the particular
953 @var{bbdb-field} (see @code{bbdb-create-internal}).
954 @code{eudc-bbdbify-phone} and @code{eudc-bbdbify-address} are provided as
955 convenience functions to parse phones and addresses.
956 @end table
957 @end defvar
958
959 The default value of the PH-specific value of that variable is
960 @code{eudc-ph-bbdb-conversion-alist}:
961
962 @lisp
963 ((name . name)
964 (net . email)
965 (address . (eudc-bbdbify-address address "Address"))
966 (phone . ((eudc-bbdbify-phone phone "Phone")
967 (eudc-bbdbify-phone office_phone "Office Phone"))))
968 @end lisp
969
970 This means that:
971
972 @itemize @bullet
973 @item
974 the @code{name} field of the BBDB record gets its value
975 from the @code{name} attribute of the directory record
976 @item
977 the @code{net} field of the BBDB record gets its value
978 from the @code{email} attribute of the directory record
979 @item
980 the @code{address} field of the BBDB record is obtained by parsing the
981 @code{address} attribute of the directory record with the function
982 @code{eudc-bbdbify-address}
983 @item
984 two @code{phone} fields are created (when possible) in the BBDB record.
985 The first one has @cite{Phone} for location and its value is obtained by
986 parsing the @code{phone} attribute of the PH/QI record with the function
987 @code{eudc-bbdbify-phone}. The second one has @cite{Office Phone} for location
988 its value is obtained by parsing the @code{office_phone} attribute of the
989 PH/QI record with the function @code{eudc-bbdbify-phone}.
990 @end itemize
991
992 @defun eudc-bbdbify-phone phone location
993 This is a convenience function provided for use in
994 @code{eudc-bbdb-conversion-alist}. It parses @var{phone} into a vector
995 compatible with @code{bbdb-create-internal}. @var{phone} is either a string
996 supposedly containing a phone number or a list of such strings which are
997 concatenated. @var{location} is used as the phone location for BBDB.
998 @end defun
999
1000 @defun eudc-bbdbify-address addr location
1001 This is a convenience function provided for use in
1002 @code{eudc-bbdb-conversion-alist}. It parses @var{addr} into a vector
1003 compatible with @code{bbdb-create-internal}. @var{addr} should be an
1004 address string of no more than four lines or a list of lines. The last
1005 line is searched for the zip code, city and state name. @var{location}
1006 is used as the phone location for BBDB.
1007 @end defun
1008
1009 Note that only a subset of the attributes you selected with
1010 @code{eudc-default-return-attributes} and that are actually displayed may
1011 actually be inserted as part of the newly created BBDB record.
1012
1013
1014 @node Server/Protocol Locals
1015 @section Server/Protocol Locals
1016
1017 EUDC can be customized independently for each server or directory
1018 protocol. All variables can be given local bindings that are activated
1019 when a particular server and/or protocol becomes active. This is much
1020 like buffer-local bindings but on a per server or per protocol basis.
1021
1022 @menu
1023 * Manipulating local bindings:: Functions to set and query local bindings
1024 @end menu
1025
1026 @node Manipulating local bindings
1027 @subsection Manipulating local bindings
1028
1029 EUDC offers functions that let you set and query variables on a per
1030 server or per protocol basis.
1031
1032 The following predicates allow you to test the existence of
1033 server/protocol local bindings for a particular variable.
1034
1035 @defun eudc-server-local-variable-p var
1036 Return non-@code{nil} if @var{var} has server-local bindings
1037 @end defun
1038
1039 @defun eudc-protocol-local-variable-p var
1040 Return non-@code{nil} if @var{var} has protocol-local bindings
1041 @end defun
1042
1043 The following functions allow you to set the value of a variable with
1044 various degrees of locality.
1045
1046 @defun eudc-default-set var val
1047 Set the EUDC default value of @var{var} to @var{val}.
1048 The current binding of @var{var} (if local to the current server or
1049 protocol) is not changed.
1050 @end defun
1051
1052 @defun eudc-protocol-set var val &optional protocol
1053 Set the binding of @var{var} local to @var{protocol} to @var{val}. If
1054 omitted, @var{protocol} defaults to the current value of
1055 @code{eudc-protocol}. The current binding of @var{var} is changed only
1056 if @var{protocol} is omitted.
1057 @end defun
1058
1059 @defun eudc-server-set var val &optional server
1060 Set the binding of @var{var} local to @var{server} to @var{val}. If
1061 omitted, @var{server} defaults to the current value of
1062 @code{eudc-server}. The current binding of @var{var} is changed only if
1063 @var{server} is omitted.
1064 @end defun
1065
1066 @defun eudc-set var val
1067 Set the most local (server, protocol or default) binding of @var{var} to
1068 @var{val}. The current binding of @var{var} is also set to @var{val}.
1069 @end defun
1070
1071 The following variables allow you to query the various bindings of a
1072 variable (local or non-local).
1073
1074 @defun eudc-variable-default-value var
1075 Return the default binding of @var{var} (outside of a particular server
1076 or protocol local binding).
1077 Return @code{unbound} if @var{var} has no EUDC default value.
1078 @end defun
1079
1080 @defun eudc-variable-protocol-value var &optional protocol
1081 Return the value of @var{var} local to @var{protocol}. Return
1082 @code{unbound} if @var{var} has no value local to @var{protocol}.
1083 @var{protocol} defaults to @code{eudc-protocol}.
1084 @end defun
1085
1086 @defun eudc-variable-server-value var [server]
1087 Return the value of @var{var} local to @var{server}.
1088 Return @code{unbound} if @var{var} has no value local to @var{server}.
1089 @var{server} defaults to @code{eudc-server}.
1090 @end defun
1091
1092 Changing a protocol-local or server-local value of a variable has no
1093 effect on its current value. The following command is used to
1094 synchronize the current values of variables with their local values
1095 given the current @code{eudc-server} and @code{eudc-protocol}:
1096
1097 @defun eudc-update-local-variables
1098 Update all EUDC variables according to their local settings.
1099 @end defun
1100
1101
1102
1103 @node Credits
1104 @chapter Credits
1105
1106 EUDC was written by Oscar Figueiredo based on @file{ph.el} by the
1107 same author.
1108
1109 Thanks to Soren Dayton for his suggestions, his enthusiasm and his help
1110 in testing and proofreading the code and docs of @file{ph.el}.
1111
1112 @node GNU Free Documentation License
1113 @appendix GNU Free Documentation License
1114 @include doclicense.texi
1115
1116 @node Index
1117 @unnumbered Index
1118
1119 @printindex cp
1120
1121 @bye