Fix a comment whitespace typo.
[emacs.git] / lisp / net / eudc-vars.el
blob79d6f2ebc6921f8c30227e74a5396f98dc856d1f
1 ;;; eudc-vars.el --- Emacs Unified Directory Client
3 ;; Copyright (C) 1998-2017 Free Software Foundation, Inc.
5 ;; Author: Oscar Figueiredo <oscar@cpe.fr>
6 ;; Pavel Janík <Pavel@Janik.cz>
7 ;; Maintainer: Thomas Fitzsimmons <fitzsim@fitzsim.org>
8 ;; Keywords: comm
9 ;; Package: eudc
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;;; Commentary:
28 ;;; Code:
30 (require 'custom)
32 ;;{{{ EUDC Main Custom Group
34 (defgroup eudc nil
35 "Emacs Unified Directory Client."
36 :version "21.1"
37 :link '(info-link "(eudc)")
38 :group 'mail
39 :group 'comm)
41 (defcustom eudc-server nil
42 "The name or IP address of the directory server.
43 A port number may be specified by appending a colon and a
44 number to the name of the server. Use `localhost' if the directory
45 server resides on your computer (BBDB backend).
47 To specify multiple servers, customize eudc-server-hotlist
48 instead."
49 :type '(choice (string :tag "Server") (const :tag "None" nil)))
51 ;; Known protocols (used in completion)
52 ;; Not to be mistaken with `eudc-supported-protocols'
53 (defvar eudc-known-protocols '(bbdb ldap))
55 (defcustom eudc-server-hotlist nil
56 "Directory servers to query.
57 This is an alist of the form (SERVER . PROTOCOL). SERVER is the
58 host name or URI of the server, PROTOCOL is a symbol representing
59 the EUDC backend with which to access the server.
61 The BBDB backend ignores SERVER; `localhost' can be used as a
62 placeholder string."
63 :tag "Directory Servers to Query"
64 :type `(repeat (cons :tag "Directory Server"
65 (string :tag "Server Host Name or URI")
66 (choice :tag "Protocol"
67 :menu-tag "Protocol"
68 ,@(mapcar (lambda (s)
69 (list 'const
70 ':tag (symbol-name s) s))
71 eudc-known-protocols)
72 (const :tag "None" nil))))
73 :version "25.1")
75 (defvar eudc-supported-protocols nil
76 "Protocols currently supported by EUDC.
77 This variable is updated when protocol-specific libraries
78 are loaded, *do not change manually*.")
80 (defcustom eudc-protocol nil
81 "The directory protocol to use to query the server.
82 Supported protocols are specified by `eudc-supported-protocols'."
83 :type `(choice :menu-tag "Protocol"
84 ,@(mapcar (lambda (s)
85 (list 'const ':tag (symbol-name s) s))
86 eudc-known-protocols)
87 (const :tag "None" nil)))
90 (defcustom eudc-strict-return-matches t
91 "Ignore or allow entries not containing all requested return attributes.
92 If non-nil, such entries are ignored."
93 :type 'boolean)
95 (defcustom eudc-default-return-attributes nil
96 "A list of default attributes to extract from directory entries.
97 If set to the symbol `all', return all attributes.
98 A value of nil means return the default attributes as configured in the
99 server."
100 :type '(choice :menu-tag "Return Attributes"
101 (const :menu-tag "Server defaults (nil)" nil)
102 (const :menu-tag "All" all)
103 (repeat :menu-tag "Attribute list"
104 :tag "Attribute name"
105 :value (nil)
106 (symbol :tag "Attribute name"))))
108 (defcustom eudc-multiple-match-handling-method 'select
109 "What to do when multiple entries match an inline expansion query.
110 Possible values are:
111 `first' (equivalent to nil) which means keep the first match only,
112 `select' pop-up a selection buffer,
113 `all' expand to all matches,
114 `abort' the operation is aborted, an error is signaled."
115 :type '(choice :menu-tag "Method"
116 (const :menu-tag "Use First"
117 :tag "Use First" first)
118 (const :menu-tag "Select Interactively"
119 :tag "Select Interactively" select)
120 (const :menu-tag "Use All"
121 :tag "Use All" all)
122 (const :menu-tag "Abort Operation"
123 :tag "Abort Operation" abort)
124 (const :menu-tag "Default (Use First)"
125 :tag "Default (Use First)" nil)))
127 (defcustom eudc-duplicate-attribute-handling-method '((email . duplicate))
128 "A method to handle entries containing duplicate attributes.
129 This is either an alist (ATTR . METHOD) or a symbol METHOD.
130 The alist form of the variable associates a method to an individual attribute,
131 the second form specifies a method applicable to all attributes.
132 Available methods are:
133 `list' or nil lets the value of the attribute be a list of values,
134 `first' keeps the first value and discards the others,
135 `concat' concatenates the values into a single multiline string,
136 `duplicate' duplicates the entire entry into as many instances as
137 different values."
138 :type '(choice (const :menu-tag "List" list)
139 (const :menu-tag "First" first)
140 (const :menu-tag "Concat" concat)
141 (const :menu-tag "Duplicate" duplicate)
142 (repeat :menu-tag "Per Attribute Specification"
143 :tag "Per Attribute Specification"
144 (cons :tag "Attribute/Method"
145 :value (nil . list)
146 (symbol :tag "Attribute name")
147 (choice :tag "Method"
148 :menu-tag "Method"
149 (const :menu-tag "List" list)
150 (const :menu-tag "First" first)
151 (const :menu-tag "Concat" concat)
152 (const :menu-tag "Duplicate" duplicate))))))
154 (defcustom eudc-inline-query-format '((email)
155 (firstname)
156 (firstname name))
157 "Format of an inline expansion query.
158 This is a list of FORMATs. A FORMAT is itself a list of one or more
159 EUDC attribute names. A FORMAT applies if it contains as many attributes as
160 there are individual words in the inline query string.
161 If several FORMATs apply then they are tried in order until a match
162 is found.
163 If nil, all the words are mapped onto the default server or protocol
164 attribute name.
166 The attribute names in FORMATs are not restricted to EUDC attribute names
167 but can also be protocol/server specific names. In this case, this variable
168 must be set in a protocol/server-local fashion, see `eudc-server-set' and
169 `eudc-protocol-set'."
170 :tag "Format of Inline Expansion Queries"
171 :type '(repeat
172 (repeat
173 :menu-tag "Format"
174 :tag "Format"
175 (choice
176 :tag "Attribute"
177 (const :menu-tag "First Name" :tag "First Name" firstname)
178 (const :menu-tag "Surname" :tag "Surname" name)
179 (const :menu-tag "Email Address" :tag "Email Address" email)
180 (const :menu-tag "Phone" :tag "Phone" phone)
181 (symbol :menu-tag "Other" :tag "Attribute name"))))
182 :version "25.1")
184 ;; Default to nil so that the most common use of eudc-expand-inline,
185 ;; where replace is nil, does not affect the kill ring.
186 (defcustom eudc-expansion-overwrites-query nil
187 "If non-nil, expanding a query overwrites the query string."
188 :type 'boolean
189 :version "25.1")
191 (defcustom eudc-inline-expansion-format '("%s %s <%s>" firstname name email)
192 "A list specifying the format of the expansion of inline queries.
193 This variable controls what `eudc-expand-inline' actually inserts in
194 the buffer. First element is a string passed to `format'. Remaining
195 elements are symbols indicating attribute names; the corresponding values
196 are passed as additional arguments to `format'."
197 :type '(list
198 (string :tag "Format String")
199 (repeat :inline t
200 :tag "Attributes"
201 (choice
202 :tag "Attribute"
203 (const :menu-tag "First Name" :tag "First Name" firstname)
204 (const :menu-tag "Surname" :tag "Surname" name)
205 (const :menu-tag "Email Address" :tag "Email Address" email)
206 (const :menu-tag "Phone" :tag "Phone" phone)
207 (symbol :menu-tag "Other")
208 (symbol :tag "Attribute name"))))
209 :version "25.1")
211 (defcustom eudc-inline-expansion-servers 'server-then-hotlist
212 "Which servers to contact for the expansion of inline queries.
213 Possible values are:
214 `current-server': the EUDC current server.
215 `hotlist': the servers of the hotlist in the order they appear,
216 `server-then-hotlist': the current server and then the servers of
217 the hotlist."
218 :type '(choice :tag "Servers"
219 :menu-tag "Servers"
220 (const :menu-tag "Current server" current-server)
221 (const :menu-tag "Servers in the hotlist" hotlist)
222 (const :menu-tag "Current server then hotlist" server-then-hotlist)))
224 (defcustom eudc-max-servers-to-query nil
225 "Maximum number of servers to query for an inline expansion.
226 If nil, query all servers available from `eudc-inline-expansion-servers'."
227 :tag "Max Number of Servers to Query"
228 :type '(choice :tag "Max. Servers"
229 :menu-tag "Max. Servers"
230 (const :menu-tag "No limit" nil)
231 (const :menu-tag "1" 1)
232 (const :menu-tag "2" 2)
233 (const :menu-tag "3" 3)
234 (const :menu-tag "4" 4)
235 (const :menu-tag "5" 5)
236 (integer :menu-tag "Set")))
238 (defcustom eudc-query-form-attributes '(name firstname email phone)
239 "A list of attributes presented in the query form."
240 :tag "Attributes in Query Forms"
241 :type '(repeat
242 (choice
243 :tag "Attribute"
244 (const :menu-tag "First Name" :tag "First Name" firstname)
245 (const :menu-tag "Surname" :tag "Surname" name)
246 (const :menu-tag "Email Address" :tag "Email Address" email)
247 (const :menu-tag "Phone" :tag "Phone" phone)
248 (symbol :menu-tag "Other" :tag "Attribute name"))))
250 (defcustom eudc-user-attribute-names-alist '((url . "URL")
251 (callsign . "HAM Call Sign")
252 (id . "ID")
253 (email . "E-Mail")
254 (firstname . "First Name")
255 (cn . "Full Name")
256 (sn . "Surname")
257 (givenname . "First Name")
258 (ou . "Unit")
259 (labeledurl . "URL")
260 (postaladdress . "Address")
261 (postalcode . "Postal Code")
262 (l . "Location")
263 (c . "Country")
264 (o . "Organization")
265 (roomnumber . "Office")
266 (telephonenumber . "Phone")
267 (uniqueidentifier . "ID")
268 (objectclass . "Object Class"))
269 "Alist of user-defined names for directory attributes.
270 These names are used as prompt strings in query/response forms
271 instead of the raw directory attribute names.
272 Prompt strings for attributes that are not listed here
273 are derived by splitting the attribute name
274 at `_' characters and capitalizing the individual words."
275 :tag "User-defined Names of Directory Attributes"
276 :type '(repeat (cons :tag "Field"
277 (symbol :tag "Directory attribute")
278 (string :tag "User friendly name "))))
280 (defcustom eudc-use-raw-directory-names nil
281 "If non-nil, use attributes names as defined in the directory.
282 Otherwise, directory query/response forms display the user attribute
283 names defined in `eudc-user-attribute-names-alist'."
284 :type 'boolean)
286 (defcustom eudc-attribute-display-method-alist nil
287 "An alist specifying methods to display attribute values.
288 Each member of the list is of the form (NAME . FUNC) where NAME is a lowercased
289 string naming a directory attribute (translated according to
290 `eudc-user-attribute-names-alist' if `eudc-use-raw-directory-names' is
291 non-nil) and FUNC a function that will be passed the corresponding
292 attribute values for display."
293 :tag "Attribute Decoding Functions"
294 :type '(repeat (cons :tag "Attribute"
295 (symbol :tag "Name")
296 (symbol :tag "Display Function"))))
298 (defcustom eudc-external-viewers '(("ImageMagick" "display" "-")
299 ("ShowAudio" "showaudio"))
300 "A list of viewer program specifications.
301 Viewers are programs which can be piped a directory attribute value for
302 display or arbitrary processing. Each specification is a list whose
303 first element is a string naming the viewer. The second element is the
304 executable program which should be invoked, and following elements are
305 arguments that should be passed to the program."
306 :tag "External Viewer Programs"
307 :type '(repeat (list :tag "Viewer"
308 (string :tag "Name")
309 (string :tag "Executable program")
310 (repeat
311 :tag "Arguments"
312 :inline t
313 (string :tag "Argument")))))
315 (defcustom eudc-options-file
316 (locate-user-emacs-file "eudc-options" ".eudc-options")
317 "A file where the `servers' hotlist is stored."
318 :type '(file :Tag "File Name:")
319 :version "25.1")
321 (defcustom eudc-mode-hook nil
322 "Normal hook run on entry to EUDC mode."
323 :type 'hook)
325 ;;}}}
327 ;;{{{ PH Custom Group
329 (defgroup eudc-ph nil
330 "Emacs Unified Directory Client - CCSO PH/QI Backend."
331 :group 'eudc)
333 (defcustom eudc-ph-bbdb-conversion-alist
334 '((name . name)
335 (net . email)
336 (address . (eudc-bbdbify-address address "Address"))
337 (phone . ((eudc-bbdbify-phone phone "Phone")
338 (eudc-bbdbify-phone office_phone "Office Phone"))))
339 "A mapping from BBDB to PH/QI fields.
340 This is a list of cons cells (BBDB-FIELD . SPEC-OR-LIST) where
341 BBDB-FIELD is the name of a field that must be defined in your BBDB
342 environment (standard field names are `name', `company', `net', `phone',
343 `address' and `notes'). SPEC-OR-LIST is either a single SPEC or a list
344 of SPECs. Lists of specs are valid only for the `phone' and `address'
345 BBDB fields. SPECs are sexps which are evaluated:
346 a string evaluates to itself,
347 a symbol evaluates to the symbol value. Symbols naming PH/QI fields
348 present in the record evaluate to the value of the field in the record,
349 a form is evaluated as a function. The argument list may contain PH/QI
350 field names which eval to the corresponding values in the
351 record. The form evaluation should return something appropriate for
352 the particular BBDB-FIELD (see `bbdb-create-internal').
353 `eudc-bbdbify-phone' and `eudc-bbdbify-address' are provided as convenience
354 functions to parse phones and addresses."
355 :tag "BBDB to PH Field Name Mapping"
356 :type '(repeat (cons :tag "Field Name"
357 (symbol :tag "BBDB Field")
358 (sexp :tag "Conversion Spec"))))
360 (make-obsolete-variable 'eudc-ph-bbdb-conversion-alist
361 "the EUDC PH/QI backend is obsolete."
362 "25.1")
364 ;;}}}
366 ;;{{{ LDAP Custom Group
368 (defgroup eudc-ldap nil
369 "Emacs Unified Directory Client - LDAP Backend."
370 :group 'eudc)
372 (defcustom eudc-ldap-bbdb-conversion-alist
373 '((name . cn)
374 (net . mail)
375 (address . (eudc-bbdbify-address postaladdress "Address"))
376 (phone . (eudc-bbdbify-phone telephonenumber "Phone"))
377 (company . (eudc-bbdbify-company o)))
378 "A mapping from BBDB to LDAP attributes.
379 This is a list of cons cells (BBDB-FIELD . SPEC-OR-LIST) where
380 BBDB-FIELD is the name of a field that must be defined in your BBDB
381 environment (standard field names are `name', `company', `net', `phone',
382 `address' and `notes'). SPEC-OR-LIST is either a single SPEC or a list
383 of SPECs. Lists of specs are valid only for the `phone' and `address'
384 BBDB fields. SPECs are sexps which are evaluated:
385 a string evaluates to itself,
386 a symbol evaluates to the symbol value. Symbols naming LDAP attributes
387 present in the record evaluate to the value of the field in the record,
388 a form is evaluated as a function. The argument list may contain LDAP
389 field names which eval to the corresponding values in the
390 record. The form evaluation should return something appropriate for
391 the particular BBDB-FIELD (see `bbdb-create-internal').
392 `eudc-bbdbify-phone' and `eudc-bbdbify-address' are provided as convenience
393 functions to parse phones and addresses."
394 :tag "BBDB to LDAP Attribute Names Mapping"
395 :type '(repeat (cons :tag "Field Name"
396 (symbol :tag "BBDB Field")
397 (sexp :tag "Conversion Spec"))))
399 ;;}}}
401 ;;{{{ BBDB Custom Group
403 (defgroup eudc-bbdb nil
404 "Emacs Unified Directory Client - BBDB Backend."
405 :group 'eudc)
407 (defcustom eudc-bbdb-use-locations-as-attribute-names t
408 "If non-nil, BBDB address and phone locations are used as attribute names.
409 This has no effect on queries (you can't search for a specific location)
410 but influences the way records are displayed."
411 :type 'boolean)
413 (defcustom eudc-bbdb-enable-substring-matches t
414 "If non-nil, authorize substring match in the same way BBDB does.
415 Otherwise records must match queries exactly."
416 :type 'boolean)
418 ;;}}}
421 (provide 'eudc-vars)
423 ;;; eudc-vars.el ends here