Mercurial > emacs
annotate lisp/net/eudc.el @ 72413:0e8b738d2b51
(Variable Definitions): Explain when the
standard value expression is evaluated.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 16 Aug 2006 05:10:55 +0000 |
parents | 067115a6e738 |
children | f7702c5f335d c5406394f567 |
rev | line source |
---|---|
27313 | 1 ;;; eudc.el --- Emacs Unified Directory Client |
2 | |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, |
68648
067115a6e738
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
66591
diff
changeset
|
4 ;; 2005, 2006 Free Software Foundation, Inc. |
27313 | 5 |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
6 ;; Author: Oscar Figueiredo <oscar@cpe.fr> |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
7 ;; Maintainer: Pavel Janík <Pavel@Janik.cz> |
42575
24c994803548
(top-level): Revert previous change.
Pavel Janík <Pavel@Janik.cz>
parents:
42569
diff
changeset
|
8 ;; Keywords: comm |
27313 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
27313 | 26 |
27 ;;; Commentary: | |
28 ;; This package provides a common interface to query directory servers using | |
29 ;; different protocols such as LDAP, CCSO PH/QI or BBDB. Queries can be | |
30 ;; made through an interactive form or inline. Inline query strings in | |
31 ;; buffers are expanded with appropriately formatted query results | |
32 ;; (especially used to expand email addresses in message buffers). EUDC | |
33 ;; also interfaces with the BBDB package to let you register query results | |
34 ;; into your own BBDB database. | |
35 | |
36 ;;; Usage: | |
37 ;; EUDC comes with an extensive documentation, please refer to it. | |
38 ;; | |
39 ;; The main entry points of EUDC are: | |
40 ;; `eudc-query-form': Query a directory server from a query form | |
41 ;; `eudc-expand-inline': Query a directory server for the e-mail address | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
42 ;; of the name before cursor and insert it in the |
27313 | 43 ;; buffer |
44 ;; `eudc-get-phone': Get a phone number from a directory server | |
45 ;; `eudc-get-email': Get an e-mail address from a directory server | |
46 ;; `eudc-customize': Customize various aspects of EUDC | |
47 | |
48 ;;; Code: | |
49 | |
50 (require 'wid-edit) | |
51 | |
52 (eval-and-compile | |
53 (if (not (fboundp 'make-overlay)) | |
54 (require 'overlay)) | |
55 (if (not (fboundp 'unless)) | |
56 (require 'cl))) | |
57 | |
58 (unless (fboundp 'custom-menu-create) | |
59 (autoload 'custom-menu-create "cus-edit")) | |
60 | |
61 (require 'eudc-vars) | |
62 | |
63 | |
64 | |
65 ;;{{{ Internal cooking | |
66 | |
67 ;;{{{ Internal variables and compatibility tricks | |
68 | |
69 (defconst eudc-xemacs-p (string-match "XEmacs" emacs-version)) | |
70 (defconst eudc-emacs-p (not eudc-xemacs-p)) | |
71 (defconst eudc-xemacs-mule-p (and eudc-xemacs-p | |
72 (featurep 'mule))) | |
73 (defconst eudc-emacs-mule-p (and eudc-emacs-p | |
74 (featurep 'mule))) | |
75 | |
76 (defvar eudc-form-widget-list nil) | |
77 (defvar eudc-mode-map nil) | |
78 | |
65221
33a4813c9bf4
(mode-popup-menu): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64701
diff
changeset
|
79 (defvar mode-popup-menu) |
33a4813c9bf4
(mode-popup-menu): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64701
diff
changeset
|
80 |
27313 | 81 ;; List of known servers |
82 ;; Alist of (SERVER . PROTOCOL) | |
83 (defvar eudc-server-hotlist nil) | |
84 | |
85 ;; List of variables that have server- or protocol-local bindings | |
86 (defvar eudc-local-vars nil) | |
87 | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
88 ;; Protocol local. Query function |
27313 | 89 (defvar eudc-query-function nil) |
90 | |
91 ;; Protocol local. A function that retrieves a list of valid attribute names | |
92 (defvar eudc-list-attributes-function nil) | |
93 | |
94 ;; Protocol local. A mapping between EUDC attribute names and corresponding | |
95 ;; protocol specific names. The following names are defined by EUDC and may be | |
96 ;; included in that list: `name' , `firstname', `email', `phone' | |
97 (defvar eudc-protocol-attributes-translation-alist nil) | |
98 | |
99 ;; Protocol local. Mapping between protocol attribute names and BBDB field | |
100 ;; names | |
101 (defvar eudc-bbdb-conversion-alist nil) | |
102 | |
103 ;; Protocol/Server local. Hook called upon switching to that server | |
104 (defvar eudc-switch-to-server-hook nil) | |
105 | |
106 ;; Protocol/Server local. Hook called upon switching from that server | |
107 (defvar eudc-switch-from-server-hook nil) | |
108 | |
109 ;; Protocol local. Whether the protocol supports queries with no specified | |
110 ;; attribute name | |
111 (defvar eudc-protocol-has-default-query-attributes nil) | |
112 | |
113 (defun eudc-cadr (obj) | |
114 (car (cdr obj))) | |
115 | |
116 (defun eudc-cdar (obj) | |
117 (cdr (car obj))) | |
118 | |
119 (defun eudc-caar (obj) | |
120 (car (car obj))) | |
121 | |
122 (defun eudc-cdaar (obj) | |
123 (cdr (car (car obj)))) | |
124 | |
125 (defun eudc-plist-member (plist prop) | |
126 "Return t if PROP has a value specified in PLIST." | |
127 (if (not (= 0 (% (length plist) 2))) | |
128 (error "Malformed plist")) | |
129 (catch 'found | |
130 (while plist | |
131 (if (eq prop (car plist)) | |
132 (throw 'found t)) | |
133 (setq plist (cdr (cdr plist)))) | |
134 nil)) | |
135 | |
136 ;; Emacs' plist-get lacks third parameter | |
137 (defun eudc-plist-get (plist prop &optional default) | |
138 "Extract a value from a property list. | |
139 PLIST is a property list, which is a list of the form | |
47497
036e57c15cdc
* xscheme.el (scheme-interaction-mode): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
42781
diff
changeset
|
140 \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value |
27313 | 141 corresponding to the given PROP, or DEFAULT if PROP is not |
142 one of the properties on the list." | |
143 (if (eudc-plist-member plist prop) | |
144 (plist-get plist prop) | |
145 default)) | |
146 | |
147 (defun eudc-lax-plist-get (plist prop &optional default) | |
148 "Extract a value from a lax property list. | |
149 | |
150 PLIST is a lax property list, which is a list of the form (PROP1 | |
151 VALUE1 PROP2 VALUE2...), where comparisons between properties are done | |
152 using `equal' instead of `eq'. This function returns the value | |
153 corresponding to PROP, or DEFAULT if PROP is not one of the | |
154 properties on the list." | |
155 (if (not (= 0 (% (length plist) 2))) | |
156 (error "Malformed plist")) | |
157 (catch 'found | |
158 (while plist | |
159 (if (equal prop (car plist)) | |
160 (throw 'found (car (cdr plist)))) | |
161 (setq plist (cdr (cdr plist)))) | |
162 default)) | |
163 | |
164 (if (not (fboundp 'split-string)) | |
165 (defun split-string (string &optional pattern) | |
166 "Return a list of substrings of STRING which are separated by PATTERN. | |
167 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | |
168 (or pattern | |
169 (setq pattern "[ \f\t\n\r\v]+")) | |
170 (let (parts (start 0)) | |
171 (when (string-match pattern string 0) | |
172 (if (> (match-beginning 0) 0) | |
173 (setq parts (cons (substring string 0 (match-beginning 0)) nil))) | |
174 (setq start (match-end 0)) | |
175 (while (and (string-match pattern string start) | |
176 (> (match-end 0) start)) | |
177 (setq parts (cons (substring string start (match-beginning 0)) parts) | |
178 start (match-end 0)))) | |
179 (nreverse (if (< start (length string)) | |
180 (cons (substring string start) parts) | |
181 parts))))) | |
182 | |
183 (defun eudc-replace-in-string (str regexp newtext) | |
184 "Replace all matches in STR for REGEXP with NEWTEXT. | |
185 Value is the new string." | |
186 (let ((rtn-str "") | |
187 (start 0) | |
188 match prev-start) | |
189 (while (setq match (string-match regexp str start)) | |
190 (setq prev-start start | |
191 start (match-end 0) | |
192 rtn-str | |
193 (concat rtn-str | |
194 (substring str prev-start match) | |
195 newtext))) | |
196 (concat rtn-str (substring str start)))) | |
197 | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
198 ;;}}} |
27313 | 199 |
200 ;;{{{ Server and Protocol Variable Routines | |
201 | |
202 (defun eudc-server-local-variable-p (var) | |
203 "Return non-nil if VAR has server-local bindings." | |
204 (eudc-plist-member (get var 'eudc-locals) 'server)) | |
205 | |
206 (defun eudc-protocol-local-variable-p (var) | |
207 "Return non-nil if VAR has protocol-local bindings." | |
208 (eudc-plist-member (get var 'eudc-locals) 'protocol)) | |
209 | |
210 (defun eudc-default-set (var val) | |
211 "Set the EUDC default value of VAR to VAL. | |
212 The current binding of VAR is not changed." | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
213 (put var 'eudc-locals |
27313 | 214 (plist-put (get var 'eudc-locals) 'default val)) |
215 (add-to-list 'eudc-local-vars var)) | |
216 | |
217 (defun eudc-protocol-set (var val &optional protocol) | |
218 "Set the PROTOCOL-local binding of VAR to VAL. | |
219 If omitted PROTOCOL defaults to the current value of `eudc-protocol'. | |
220 The current binding of VAR is changed only if PROTOCOL is omitted." | |
221 (if (eq 'unbound (eudc-variable-default-value var)) | |
222 (eudc-default-set var (symbol-value var))) | |
223 (let* ((eudc-locals (get var 'eudc-locals)) | |
224 (protocol-locals (eudc-plist-get eudc-locals 'protocol))) | |
225 (setq protocol-locals (plist-put protocol-locals (or protocol | |
226 eudc-protocol) val)) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
227 (setq eudc-locals |
27313 | 228 (plist-put eudc-locals 'protocol protocol-locals)) |
229 (put var 'eudc-locals eudc-locals) | |
230 (add-to-list 'eudc-local-vars var) | |
231 (unless protocol | |
232 (eudc-update-variable var)))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
233 |
27313 | 234 (defun eudc-server-set (var val &optional server) |
235 "Set the SERVER-local binding of VAR to VAL. | |
236 If omitted SERVER defaults to the current value of `eudc-server'. | |
237 The current binding of VAR is changed only if SERVER is omitted." | |
238 (if (eq 'unbound (eudc-variable-default-value var)) | |
239 (eudc-default-set var (symbol-value var))) | |
240 (let* ((eudc-locals (get var 'eudc-locals)) | |
241 (server-locals (eudc-plist-get eudc-locals 'server))) | |
242 (setq server-locals (plist-put server-locals (or server | |
243 eudc-server) val)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
244 (setq eudc-locals |
27313 | 245 (plist-put eudc-locals 'server server-locals)) |
246 (put var 'eudc-locals eudc-locals) | |
247 (add-to-list 'eudc-local-vars var) | |
248 (unless server | |
249 (eudc-update-variable var)))) | |
250 | |
251 | |
252 (defun eudc-set (var val) | |
253 "Set the most local (server, protocol or default) binding of VAR to VAL. | |
254 The current binding of VAR is also set to VAL" | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
255 (cond |
27313 | 256 ((not (eq 'unbound (eudc-variable-server-value var))) |
257 (eudc-server-set var val)) | |
258 ((not (eq 'unbound (eudc-variable-protocol-value var))) | |
259 (eudc-protocol-set var val)) | |
260 (t | |
261 (eudc-default-set var val))) | |
262 (set var val)) | |
263 | |
264 (defun eudc-variable-default-value (var) | |
265 "Return the default binding of VAR. | |
266 Return `unbound' if VAR has no EUDC default value." | |
267 (let ((eudc-locals (get var 'eudc-locals))) | |
268 (if (and (boundp var) | |
269 eudc-locals) | |
270 (eudc-plist-get eudc-locals 'default 'unbound) | |
271 'unbound))) | |
272 | |
273 (defun eudc-variable-protocol-value (var &optional protocol) | |
274 "Return the value of VAR local to PROTOCOL. | |
275 Return `unbound' if VAR has no value local to PROTOCOL. | |
276 PROTOCOL defaults to `eudc-protocol'" | |
277 (let* ((eudc-locals (get var 'eudc-locals)) | |
278 protocol-locals) | |
279 (if (not (and (boundp var) | |
280 eudc-locals | |
281 (eudc-plist-member eudc-locals 'protocol))) | |
282 'unbound | |
283 (setq protocol-locals (eudc-plist-get eudc-locals 'protocol)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
284 (eudc-lax-plist-get protocol-locals |
27313 | 285 (or protocol |
286 eudc-protocol) 'unbound)))) | |
287 | |
288 (defun eudc-variable-server-value (var &optional server) | |
289 "Return the value of VAR local to SERVER. | |
290 Return `unbound' if VAR has no value local to SERVER. | |
291 SERVER defaults to `eudc-server'" | |
292 (let* ((eudc-locals (get var 'eudc-locals)) | |
293 server-locals) | |
294 (if (not (and (boundp var) | |
295 eudc-locals | |
296 (eudc-plist-member eudc-locals 'server))) | |
297 'unbound | |
298 (setq server-locals (eudc-plist-get eudc-locals 'server)) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
299 (eudc-lax-plist-get server-locals |
27313 | 300 (or server |
301 eudc-server) 'unbound)))) | |
302 | |
303 (defun eudc-update-variable (var) | |
304 "Set the value of VAR according to its locals. | |
305 If the VAR has a server- or protocol-local value corresponding | |
306 to the current `eudc-server' and `eudc-protocol' then it is set | |
307 accordingly. Otherwise it is set to its EUDC default binding" | |
308 (let (val) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
309 (cond |
27313 | 310 ((not (eq 'unbound (setq val (eudc-variable-server-value var)))) |
311 (set var val)) | |
312 ((not (eq 'unbound (setq val (eudc-variable-protocol-value var)))) | |
313 (set var val)) | |
314 ((not (eq 'unbound (setq val (eudc-variable-default-value var)))) | |
315 (set var val))))) | |
316 | |
317 (defun eudc-update-local-variables () | |
318 "Update all EUDC variables according to their local settings." | |
319 (interactive) | |
320 (mapcar 'eudc-update-variable eudc-local-vars)) | |
321 | |
322 (eudc-default-set 'eudc-query-function nil) | |
323 (eudc-default-set 'eudc-list-attributes-function nil) | |
324 (eudc-default-set 'eudc-protocol-attributes-translation-alist nil) | |
325 (eudc-default-set 'eudc-bbdb-conversion-alist nil) | |
326 (eudc-default-set 'eudc-switch-to-server-hook nil) | |
327 (eudc-default-set 'eudc-switch-from-server-hook nil) | |
328 (eudc-default-set 'eudc-protocol-has-default-query-attributes nil) | |
329 (eudc-default-set 'eudc-attribute-display-method-alist nil) | |
330 | |
331 ;;}}} | |
332 | |
333 | |
334 ;; Add PROTOCOL to the list of supported protocols | |
335 (defun eudc-register-protocol (protocol) | |
336 (unless (memq protocol eudc-supported-protocols) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
337 (setq eudc-supported-protocols |
27313 | 338 (cons protocol eudc-supported-protocols)) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
339 (put 'eudc-protocol 'custom-type |
27313 | 340 `(choice :menu-tag "Protocol" |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
341 ,@(mapcar (lambda (s) |
27313 | 342 (list 'string ':tag (symbol-name s))) |
343 eudc-supported-protocols)))) | |
344 (or (memq protocol eudc-known-protocols) | |
345 (setq eudc-known-protocols | |
346 (cons protocol eudc-known-protocols)))) | |
347 | |
348 | |
349 (defun eudc-translate-query (query) | |
350 "Translate attribute names of QUERY. | |
351 The translation is done according to | |
352 `eudc-protocol-attributes-translation-alist'." | |
353 (if eudc-protocol-attributes-translation-alist | |
354 (mapcar '(lambda (attribute) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
355 (let ((trans (assq (car attribute) |
27313 | 356 (symbol-value eudc-protocol-attributes-translation-alist)))) |
357 (if trans | |
358 (cons (cdr trans) (cdr attribute)) | |
359 attribute))) | |
360 query) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
361 query)) |
27313 | 362 |
363 (defun eudc-translate-attribute-list (list) | |
364 "Translate a list of attribute names LIST. | |
365 The translation is done according to | |
366 `eudc-protocol-attributes-translation-alist'." | |
367 (if eudc-protocol-attributes-translation-alist | |
368 (let (trans) | |
369 (mapcar '(lambda (attribute) | |
370 (setq trans (assq attribute | |
371 (symbol-value eudc-protocol-attributes-translation-alist))) | |
372 (if trans | |
373 (cdr trans) | |
374 attribute)) | |
375 list)) | |
376 list)) | |
377 | |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
378 (defun eudc-select (choices beg end) |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
379 "Choose one from CHOICES using a completion. |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
380 BEG and END delimit the text which is to be replaced." |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
381 (let ((replacement)) |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
382 (setq replacement |
66591
5f00d2caf8cf
(eudc-expand-inline): If the `eudc-multiple-match-handling-method' is
John Wiegley <johnw@newartisans.com>
parents:
65221
diff
changeset
|
383 (completing-read "Multiple matches found; choose one: " |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
384 (mapcar 'list choices))) |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
385 (delete-region beg end) |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
386 (insert replacement))) |
27313 | 387 |
388 (defun eudc-query (query &optional return-attributes no-translation) | |
389 "Query the current directory server with QUERY. | |
390 QUERY is a list of cons cells (ATTR . VALUE) where ATTR is an attribute | |
391 name and VALUE the corresponding value. | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
392 If NO-TRANSLATION is non-nil, ATTR is translated according to |
27313 | 393 `eudc-protocol-attributes-translation-alist'. |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
394 RETURN-ATTRIBUTES is a list of attributes to return defaulting to |
27313 | 395 `eudc-default-return-attributes'." |
396 (unless eudc-query-function | |
397 (error "Don't know how to perform the query")) | |
398 (if no-translation | |
399 (funcall eudc-query-function query (or return-attributes | |
400 eudc-default-return-attributes)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
401 |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
402 (funcall eudc-query-function |
27313 | 403 (eudc-translate-query query) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
404 (cond |
27313 | 405 (return-attributes |
406 (eudc-translate-attribute-list return-attributes)) | |
407 ((listp eudc-default-return-attributes) | |
408 (eudc-translate-attribute-list eudc-default-return-attributes)) | |
409 (t | |
410 eudc-default-return-attributes))))) | |
411 | |
412 (defun eudc-format-attribute-name-for-display (attribute) | |
413 "Format a directory attribute name for display. | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
414 ATTRIBUTE is looked up in `eudc-user-attribute-names-alist' and replaced |
27313 | 415 by the corresponding user name if any. Otherwise it is capitalized and |
416 underscore characters are replaced by spaces." | |
417 (let ((match (assq attribute eudc-user-attribute-names-alist))) | |
418 (if match | |
419 (cdr match) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
420 (capitalize |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
421 (mapconcat 'identity |
27313 | 422 (split-string (symbol-name attribute) "_") |
423 " "))))) | |
424 | |
425 (defun eudc-print-attribute-value (field) | |
426 "Insert the value of the directory FIELD at point. | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
427 The directory attribute name in car of FIELD is looked up in |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
428 `eudc-attribute-display-method-alist' and the corresponding method, |
27313 | 429 if any, is called to print the value in cdr of FIELD." |
430 (let ((match (assoc (downcase (car field)) | |
431 eudc-attribute-display-method-alist)) | |
432 (col (current-column)) | |
433 (val (cdr field))) | |
434 (if match | |
435 (progn | |
436 (eval (list (cdr match) val)) | |
437 (insert "\n")) | |
438 (mapcar | |
439 (function | |
440 (lambda (val-elem) | |
441 (indent-to col) | |
442 (insert val-elem "\n"))) | |
443 (cond | |
444 ((listp val) val) | |
445 ((stringp val) (split-string val "\n")) | |
446 ((null val) '("")) | |
447 (t (list val))))))) | |
448 | |
449 (defun eudc-print-record-field (field column-width) | |
450 "Print the record field FIELD. | |
451 FIELD is a list (ATTR VALUE1 VALUE2 ...) or cons-cell (ATTR . VAL) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
452 COLUMN-WIDTH is the width of the first display column containing the |
27313 | 453 attribute name ATTR." |
454 (let ((field-beg (point))) | |
455 ;; The record field that is passed to this function has already been processed | |
456 ;; by `eudc-format-attribute-name-for-display' so we don't need to call it | |
457 ;; again to display the attribute name | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
458 (insert (format (concat "%" (int-to-string column-width) "s: ") |
27313 | 459 (car field))) |
460 (put-text-property field-beg (point) 'face 'bold) | |
461 (indent-to (+ 2 column-width)) | |
462 (eudc-print-attribute-value field))) | |
463 | |
464 (defun eudc-display-records (records &optional raw-attr-names) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
465 "Display the record list RECORDS in a formatted buffer. |
27313 | 466 If RAW-ATTR-NAMES is non-nil, the raw attribute names are displayed |
467 otherwise they are formatted according to `eudc-user-attribute-names-alist'." | |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
468 (let (inhibit-read-only |
27313 | 469 precords |
470 (width 0) | |
471 beg | |
472 first-record | |
473 attribute-name) | |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
474 (with-output-to-temp-buffer "*Directory Query Results*" |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
475 (with-current-buffer standard-output |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
476 (setq buffer-read-only t) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
477 (setq inhibit-read-only t) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
478 (erase-buffer) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
479 (insert "Directory Query Result\n") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
480 (insert "======================\n\n\n") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
481 (if (null records) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
482 (insert "No match found.\n" |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
483 (if eudc-strict-return-matches |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
484 "Try setting `eudc-strict-return-matches' to nil or change `eudc-default-return-attributes'.\n" |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
485 "")) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
486 ;; Replace field names with user names, compute max width |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
487 (setq precords |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
488 (mapcar |
27313 | 489 (function |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
490 (lambda (record) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
491 (mapcar |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
492 (function |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
493 (lambda (field) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
494 (setq attribute-name |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
495 (if raw-attr-names |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
496 (symbol-name (car field)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
497 (eudc-format-attribute-name-for-display (car field)))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
498 (if (> (length attribute-name) width) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
499 (setq width (length attribute-name))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
500 (cons attribute-name (cdr field)))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
501 record))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
502 records)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
503 ;; Display the records |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
504 (setq first-record (point)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
505 (mapcar |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
506 (function |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
507 (lambda (record) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
508 (setq beg (point)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
509 ;; Map over the record fields to print the attribute/value pairs |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
510 (mapcar (function |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
511 (lambda (field) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
512 (eudc-print-record-field field width))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
513 record) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
514 ;; Store the record internal format in some convenient place |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
515 (overlay-put (make-overlay beg (point)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
516 'eudc-record |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
517 (car records)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
518 (setq records (cdr records)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
519 (insert "\n"))) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
520 precords)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
521 (insert "\n") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
522 (widget-create 'push-button |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
523 :notify (lambda (&rest ignore) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
524 (eudc-query-form)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
525 "New query") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
526 (widget-insert " ") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
527 (widget-create 'push-button |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
528 :notify (lambda (&rest ignore) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
529 (kill-this-buffer)) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
530 "Quit") |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
531 (eudc-mode) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
532 (widget-setup) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
533 (if first-record |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
534 (goto-char first-record)))))) |
27313 | 535 |
536 (defun eudc-process-form () | |
537 "Process the query form in current buffer and display the results." | |
538 (let (query-alist | |
539 value) | |
540 (if (not (and (boundp 'eudc-form-widget-list) | |
541 eudc-form-widget-list)) | |
542 (error "Not in a directory query form buffer") | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
543 (mapcar (function |
27313 | 544 (lambda (wid-field) |
545 (setq value (widget-value (cdr wid-field))) | |
546 (if (not (string= value "")) | |
547 (setq query-alist (cons (cons (car wid-field) value) | |
548 query-alist))))) | |
549 eudc-form-widget-list) | |
550 (kill-buffer (current-buffer)) | |
551 (eudc-display-records (eudc-query query-alist) eudc-use-raw-directory-names)))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
552 |
27313 | 553 |
554 (defun eudc-filter-duplicate-attributes (record) | |
555 "Filter RECORD according to `eudc-duplicate-attribute-handling-method'." | |
556 (let ((rec record) | |
557 unique | |
558 duplicates | |
559 result) | |
560 | |
561 ;; Search for multiple records | |
562 (while (and rec | |
563 (not (listp (eudc-cdar rec)))) | |
564 (setq rec (cdr rec))) | |
565 | |
566 (if (null (eudc-cdar rec)) | |
567 (list record) ; No duplicate attrs in this record | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
568 (mapcar (function |
27313 | 569 (lambda (field) |
570 (if (listp (cdr field)) | |
571 (setq duplicates (cons field duplicates)) | |
572 (setq unique (cons field unique))))) | |
573 record) | |
574 (setq result (list unique)) | |
575 ;; Map over the record fields that have multiple values | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
576 (mapcar |
27313 | 577 (function |
578 (lambda (field) | |
579 (let ((method (if (consp eudc-duplicate-attribute-handling-method) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
580 (cdr |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
581 (assq |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
582 (or |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
583 (car |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
584 (rassq |
27313 | 585 (car field) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
586 (symbol-value |
27313 | 587 eudc-protocol-attributes-translation-alist))) |
588 (car field)) | |
589 eudc-duplicate-attribute-handling-method)) | |
590 eudc-duplicate-attribute-handling-method))) | |
591 (cond | |
592 ((or (null method) (eq 'list method)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
593 (setq result |
27313 | 594 (eudc-add-field-to-records field result))) |
595 ((eq 'first method) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
596 (setq result |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
597 (eudc-add-field-to-records (cons (car field) |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
598 (eudc-cadr field)) |
27313 | 599 result))) |
600 ((eq 'concat method) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
601 (setq result |
27313 | 602 (eudc-add-field-to-records (cons (car field) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
603 (mapconcat |
27313 | 604 'identity |
605 (cdr field) | |
606 "\n")) result))) | |
607 ((eq 'duplicate method) | |
608 (setq result | |
609 (eudc-distribute-field-on-records field result))))))) | |
610 duplicates) | |
611 result))) | |
612 | |
613 (defun eudc-filter-partial-records (records attrs) | |
42575
24c994803548
(top-level): Revert previous change.
Pavel Janík <Pavel@Janik.cz>
parents:
42569
diff
changeset
|
614 "Eliminate records that do not contain all ATTRS from RECORDS." |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
615 (delq nil |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
616 (mapcar |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
617 (function |
27313 | 618 (lambda (rec) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
619 (if (eval (cons 'and |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
620 (mapcar |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
621 (function |
27313 | 622 (lambda (attr) |
623 (consp (assq attr rec)))) | |
624 attrs))) | |
625 rec))) | |
626 records))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
627 |
27313 | 628 (defun eudc-add-field-to-records (field records) |
629 "Add FIELD to each individual record in RECORDS and return the resulting list." | |
630 (mapcar (function | |
631 (lambda (r) | |
632 (cons field r))) | |
633 records)) | |
634 | |
635 (defun eudc-distribute-field-on-records (field records) | |
636 "Duplicate each individual record in RECORDS according to value of FIELD. | |
637 Each copy is added a new field containing one of the values of FIELD." | |
638 (let (result | |
639 (values (cdr field))) | |
640 ;; Uniquify values first | |
641 (while values | |
642 (setcdr values (delete (car values) (cdr values))) | |
643 (setq values (cdr values))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
644 (mapcar |
27313 | 645 (function |
646 (lambda (value) | |
647 (let ((result-list (copy-sequence records))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
648 (setq result-list (eudc-add-field-to-records |
27313 | 649 (cons (car field) value) |
650 result-list)) | |
651 (setq result (append result-list result)) | |
652 ))) | |
653 (cdr field)) | |
654 result)) | |
655 | |
656 | |
657 (defun eudc-mode () | |
658 "Major mode used in buffers displaying the results of directory queries. | |
659 There is no sense in calling this command from a buffer other than | |
660 one containing the results of a directory query. | |
661 | |
662 These are the special commands of EUDC mode: | |
663 q -- Kill this buffer. | |
664 f -- Display a form to query the current directory server. | |
665 n -- Move to next record. | |
666 p -- Move to previous record. | |
667 b -- Insert record at point into the BBDB database." | |
668 (interactive) | |
669 (kill-all-local-variables) | |
670 (setq major-mode 'eudc-mode) | |
671 (setq mode-name "EUDC") | |
672 (use-local-map eudc-mode-map) | |
673 (if eudc-emacs-p | |
674 (easy-menu-define eudc-emacs-menu eudc-mode-map "" (eudc-menu)) | |
675 (setq mode-popup-menu (eudc-menu))) | |
62768 | 676 (run-mode-hooks 'eudc-mode-hook)) |
27313 | 677 |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
678 ;;}}} |
27313 | 679 |
680 ;;{{{ High-level interfaces (interactive functions) | |
681 | |
682 (defun eudc-customize () | |
683 "Customize the EUDC package." | |
684 (interactive) | |
685 (customize-group 'eudc)) | |
686 | |
687 ;;;###autoload | |
688 (defun eudc-set-server (server protocol &optional no-save) | |
689 "Set the directory server to SERVER using PROTOCOL. | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
690 Unless NO-SAVE is non-nil, the server is saved as the default |
27313 | 691 server for future sessions." |
692 (interactive (list | |
693 (read-from-minibuffer "Directory Server: ") | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
694 (intern (completing-read "Protocol: " |
27313 | 695 (mapcar '(lambda (elt) |
696 (cons (symbol-name elt) | |
697 elt)) | |
698 eudc-known-protocols))))) | |
699 (unless (or (member protocol | |
700 eudc-supported-protocols) | |
701 (load (concat "eudcb-" (symbol-name protocol)) t)) | |
702 (error "Unsupported protocol: %s" protocol)) | |
703 (run-hooks 'eudc-switch-from-server-hook) | |
704 (setq eudc-protocol protocol) | |
705 (setq eudc-server server) | |
706 (eudc-update-local-variables) | |
707 (run-hooks 'eudc-switch-to-server-hook) | |
708 (if (interactive-p) | |
709 (message "Current directory server is now %s (%s)" eudc-server eudc-protocol)) | |
710 (if (null no-save) | |
711 (eudc-save-options))) | |
712 | |
713 ;;;###autoload | |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
714 (defun eudc-get-email (name &optional error) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
715 "Get the email field of NAME from the directory server. |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
716 If ERROR is non-nil, report an error if there is none." |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
717 (interactive "sName: \np") |
27313 | 718 (or eudc-server |
719 (call-interactively 'eudc-set-server)) | |
720 (let ((result (eudc-query (list (cons 'name name)) '(email))) | |
721 email) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
722 (if (null (cdr result)) |
27313 | 723 (setq email (eudc-cdaar result)) |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
724 (error "Multiple match--use the query form")) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
725 (if error |
27313 | 726 (if email |
727 (message "%s" email) | |
728 (error "No record matching %s" name))) | |
729 email)) | |
730 | |
731 ;;;###autoload | |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
732 (defun eudc-get-phone (name &optional error) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
733 "Get the phone field of NAME from the directory server. |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
734 If ERROR is non-nil, report an error if there is none." |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
735 (interactive "sName: \np") |
27313 | 736 (or eudc-server |
737 (call-interactively 'eudc-set-server)) | |
738 (let ((result (eudc-query (list (cons 'name name)) '(phone))) | |
739 phone) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
740 (if (null (cdr result)) |
27313 | 741 (setq phone (eudc-cdaar result)) |
57828
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
742 (error "Multiple match--use the query form")) |
7957cb0def89
(eudc-display-records): Use with-output-to-temp-buffer;
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
743 (if error |
27313 | 744 (if phone |
745 (message "%s" phone) | |
746 (error "No record matching %s" name))) | |
747 phone)) | |
748 | |
749 (defun eudc-get-attribute-list () | |
750 "Return a list of valid attributes for the current server. | |
751 When called interactively the list is formatted in a dedicated buffer | |
752 otherwise a list of symbols is returned." | |
753 (interactive) | |
754 (if eudc-list-attributes-function | |
755 (let ((entries (funcall eudc-list-attributes-function (interactive-p)))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
756 (if entries |
27313 | 757 (if (interactive-p) |
758 (eudc-display-records entries t) | |
759 entries))) | |
760 (error "The %s protocol has no support for listing attributes" eudc-protocol))) | |
761 | |
762 (defun eudc-format-query (words format) | |
763 "Use FORMAT to build a EUDC query from WORDS." | |
764 (let (query | |
765 query-alist | |
766 key val cell) | |
767 (if format | |
768 (progn | |
769 (while (and words format) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
770 (setq query-alist (cons (cons (car format) (car words)) |
27313 | 771 query-alist)) |
772 (setq words (cdr words) | |
773 format (cdr format))) | |
774 ;; If the same attribute appears more than once, merge | |
775 ;; the corresponding values | |
776 (setq query-alist (nreverse query-alist)) | |
777 (while query-alist | |
778 (setq key (eudc-caar query-alist) | |
779 val (eudc-cdar query-alist) | |
780 cell (assq key query)) | |
781 (if cell | |
782 (setcdr cell (concat (cdr cell) " " val)) | |
783 (setq query (cons (car query-alist) query))) | |
784 (setq query-alist (cdr query-alist))) | |
785 query) | |
786 (if eudc-protocol-has-default-query-attributes | |
787 (mapconcat 'identity words " ") | |
788 (list (cons 'name (mapconcat 'identity words " "))))))) | |
789 | |
790 (defun eudc-extract-n-word-formats (format-list n) | |
791 "Extract a list of N-long formats from FORMAT-LIST. | |
792 If none try N - 1 and so forth." | |
793 (let (formats) | |
794 (while (and (null formats) | |
795 (> n 0)) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
796 (setq formats |
27313 | 797 (delq nil |
798 (mapcar '(lambda (format) | |
799 (if (= n | |
800 (length format)) | |
801 format | |
802 nil)) | |
803 format-list))) | |
804 (setq n (1- n))) | |
805 formats)) | |
806 | |
807 | |
808 ;;;###autoload | |
809 (defun eudc-expand-inline (&optional replace) | |
810 "Query the directory server, and expand the query string before point. | |
811 The query string consists of the buffer substring from the point back to | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
812 the preceding comma, colon or beginning of line. |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
813 The variable `eudc-inline-query-format' controls how to associate the |
27313 | 814 individual inline query words with directory attribute names. |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
815 After querying the server for the given string, the expansion specified by |
27313 | 816 `eudc-inline-expansion-format' is inserted in the buffer at point. |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
817 If REPLACE is non-nil, then this expansion replaces the name in the buffer. |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
818 `eudc-expansion-overwrites-query' being non-nil inverts the meaning of REPLACE. |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
819 Multiple servers can be tried with the same query until one finds a match, |
27313 | 820 see `eudc-inline-expansion-servers'" |
821 (interactive) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
822 (if (memq eudc-inline-expansion-servers |
27313 | 823 '(current-server server-then-hotlist)) |
824 (or eudc-server | |
825 (call-interactively 'eudc-set-server)) | |
826 (or eudc-server-hotlist | |
827 (error "No server in the hotlist"))) | |
828 (let* ((end (point)) | |
829 (beg (save-excursion | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
830 (if (re-search-backward "\\([:,]\\|^\\)[ \t]*" |
27313 | 831 (save-excursion |
832 (beginning-of-line) | |
833 (point)) | |
834 'move) | |
835 (goto-char (match-end 0))) | |
836 (point))) | |
837 (query-words (split-string (buffer-substring beg end) "[ \t]+")) | |
838 query-formats | |
839 response | |
840 response-string | |
841 response-strings | |
842 (eudc-former-server eudc-server) | |
843 (eudc-former-protocol eudc-protocol) | |
844 servers) | |
845 | |
846 ;; Prepare the list of servers to query | |
847 (setq servers (copy-sequence eudc-server-hotlist)) | |
848 (setq servers | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
849 (cond |
27313 | 850 ((eq eudc-inline-expansion-servers 'hotlist) |
851 eudc-server-hotlist) | |
852 ((eq eudc-inline-expansion-servers 'server-then-hotlist) | |
853 (cons (cons eudc-server eudc-protocol) | |
854 (delete (cons eudc-server eudc-protocol) servers))) | |
855 ((eq eudc-inline-expansion-servers 'current-server) | |
856 (list (cons eudc-server eudc-protocol))) | |
857 (t | |
858 (error "Wrong value for `eudc-inline-expansion-servers': %S" | |
859 eudc-inline-expansion-servers)))) | |
860 (if (and eudc-max-servers-to-query | |
861 (> (length servers) eudc-max-servers-to-query)) | |
862 (setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil)) | |
863 | |
864 (condition-case signal | |
865 (progn | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
866 (setq response |
27313 | 867 (catch 'found |
868 ;; Loop on the servers | |
869 (while servers | |
870 (eudc-set-server (eudc-caar servers) (eudc-cdar servers) t) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
871 |
27313 | 872 ;; Determine which formats apply in the query-format list |
873 (setq query-formats | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
874 (or |
27313 | 875 (eudc-extract-n-word-formats eudc-inline-query-format |
876 (length query-words)) | |
877 (if (null eudc-protocol-has-default-query-attributes) | |
878 '(name)))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
879 |
27313 | 880 ;; Loop on query-formats |
881 (while query-formats | |
882 (setq response | |
883 (eudc-query | |
884 (eudc-format-query query-words (car query-formats)) | |
885 (eudc-translate-attribute-list | |
886 (cdr eudc-inline-expansion-format)))) | |
887 (if response | |
888 (throw 'found response)) | |
889 (setq query-formats (cdr query-formats))) | |
890 (setq servers (cdr servers))) | |
891 ;; No more servers to try... no match found | |
892 nil)) | |
893 | |
894 | |
895 (if (null response) | |
896 (error "No match") | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
897 |
27313 | 898 ;; Process response through eudc-inline-expansion-format |
899 (while response | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
900 (setq response-string (apply 'format |
27313 | 901 (car eudc-inline-expansion-format) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
902 (mapcar (function |
27313 | 903 (lambda (field) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
904 (or (cdr (assq field (car response))) |
27313 | 905 ""))) |
906 (eudc-translate-attribute-list | |
907 (cdr eudc-inline-expansion-format))))) | |
908 (if (> (length response-string) 0) | |
909 (setq response-strings | |
910 (cons response-string response-strings))) | |
911 (setq response (cdr response))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
912 |
27313 | 913 (if (or |
914 (and replace (not eudc-expansion-overwrites-query)) | |
915 (and (not replace) eudc-expansion-overwrites-query)) | |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
916 (kill-ring-save beg end)) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
917 (cond |
27313 | 918 ((or (= (length response-strings) 1) |
919 (null eudc-multiple-match-handling-method) | |
920 (eq eudc-multiple-match-handling-method 'first)) | |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
921 (delete-region beg end) |
27313 | 922 (insert (car response-strings))) |
923 ((eq eudc-multiple-match-handling-method 'select) | |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
924 (eudc-select response-strings beg end)) |
27313 | 925 ((eq eudc-multiple-match-handling-method 'all) |
66591
5f00d2caf8cf
(eudc-expand-inline): If the `eudc-multiple-match-handling-method' is
John Wiegley <johnw@newartisans.com>
parents:
65221
diff
changeset
|
926 (delete-region beg end) |
27313 | 927 (insert (mapconcat 'identity response-strings ", "))) |
928 ((eq eudc-multiple-match-handling-method 'abort) | |
42781
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
929 (error "There is more than one match for the query")))) |
27313 | 930 (or (and (equal eudc-server eudc-former-server) |
931 (equal eudc-protocol eudc-former-protocol)) | |
932 (eudc-set-server eudc-former-server eudc-former-protocol t))) | |
933 (t | |
934 (or (and (equal eudc-server eudc-former-server) | |
935 (equal eudc-protocol eudc-former-protocol)) | |
936 (eudc-set-server eudc-former-server eudc-former-protocol t)) | |
937 (signal (car signal) (cdr signal)))))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
938 |
27313 | 939 ;;;###autoload |
940 (defun eudc-query-form (&optional get-fields-from-server) | |
941 "Display a form to query the directory server. | |
942 If given a non-nil argument GET-FIELDS-FROM-SERVER, the function first | |
943 queries the server for the existing fields and displays a corresponding form." | |
944 (interactive "P") | |
945 (let ((fields (or (and get-fields-from-server | |
946 (eudc-get-attribute-list)) | |
947 eudc-query-form-attributes)) | |
948 (buffer (get-buffer-create "*Directory Query Form*")) | |
949 prompts | |
950 widget | |
951 (width 0) | |
952 inhibit-read-only | |
953 pt) | |
954 (switch-to-buffer buffer) | |
955 (setq inhibit-read-only t) | |
956 (erase-buffer) | |
957 (kill-all-local-variables) | |
958 (make-local-variable 'eudc-form-widget-list) | |
959 (widget-insert "Directory Query Form\n") | |
960 (widget-insert "====================\n\n") | |
961 (widget-insert "Current server is: " (or eudc-server | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
962 (progn |
27313 | 963 (call-interactively 'eudc-set-server) |
964 eudc-server)) | |
965 "\n") | |
966 (widget-insert "Protocol : " (symbol-name eudc-protocol) "\n") | |
967 ;; Build the list of prompts | |
968 (setq prompts (if eudc-use-raw-directory-names | |
969 (mapcar 'symbol-name (eudc-translate-attribute-list fields)) | |
970 (mapcar (function | |
971 (lambda (field) | |
972 (or (and (assq field eudc-user-attribute-names-alist) | |
973 (cdr (assq field eudc-user-attribute-names-alist))) | |
974 (capitalize (symbol-name field))))) | |
975 fields))) | |
976 ;; Loop over prompt strings to find the longest one | |
977 (mapcar (function | |
978 (lambda (prompt) | |
979 (if (> (length prompt) width) | |
980 (setq width (length prompt))))) | |
981 prompts) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
982 ;; Insert the first widget out of the mapcar to leave the cursor |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
983 ;; in the first field |
27313 | 984 (widget-insert "\n\n" (format (concat "%" (int-to-string width) "s: ") (car prompts))) |
985 (setq pt (point)) | |
986 (setq widget (widget-create 'editable-field :size 15)) | |
987 (setq eudc-form-widget-list (cons (cons (car fields) widget) | |
988 eudc-form-widget-list)) | |
989 (setq fields (cdr fields)) | |
990 (setq prompts (cdr prompts)) | |
991 (mapcar (function | |
992 (lambda (field) | |
993 (widget-insert "\n\n" (format (concat "%" (int-to-string width) "s: ") (car prompts))) | |
994 (setq widget (widget-create 'editable-field | |
995 :size 15)) | |
996 (setq eudc-form-widget-list (cons (cons field widget) | |
997 eudc-form-widget-list)) | |
998 (setq prompts (cdr prompts)))) | |
999 fields) | |
1000 (widget-insert "\n\n") | |
1001 (widget-create 'push-button | |
1002 :notify (lambda (&rest ignore) | |
1003 (eudc-process-form)) | |
1004 "Query Server") | |
1005 (widget-insert " ") | |
1006 (widget-create 'push-button | |
1007 :notify (lambda (&rest ignore) | |
1008 (eudc-query-form)) | |
1009 "Reset Form") | |
1010 (widget-insert " ") | |
1011 (widget-create 'push-button | |
1012 :notify (lambda (&rest ignore) | |
1013 (kill-this-buffer)) | |
1014 "Quit") | |
1015 (goto-char pt) | |
1016 (use-local-map widget-keymap) | |
1017 (widget-setup)) | |
1018 ) | |
1019 | |
1020 (defun eudc-bookmark-server (server protocol) | |
1021 "Add SERVER using PROTOCOL to the EUDC `servers' hotlist." | |
1022 (interactive "sDirectory server: \nsProtocol: ") | |
1023 (if (member (cons server protocol) eudc-server-hotlist) | |
1024 (error "%s:%s is already in the hotlist" protocol server) | |
1025 (setq eudc-server-hotlist (cons (cons server protocol) eudc-server-hotlist)) | |
1026 (eudc-install-menu) | |
1027 (eudc-save-options))) | |
1028 | |
1029 (defun eudc-bookmark-current-server () | |
1030 "Add current server to the EUDC `servers' hotlist." | |
1031 (interactive) | |
1032 (eudc-bookmark-server eudc-server eudc-protocol)) | |
1033 | |
1034 (defun eudc-save-options () | |
1035 "Save options to `eudc-options-file'." | |
1036 (interactive) | |
1037 (save-excursion | |
1038 (set-buffer (find-file-noselect eudc-options-file t)) | |
1039 (goto-char (point-min)) | |
1040 ;; delete the previous setq | |
1041 (let ((standard-output (current-buffer)) | |
1042 provide-p | |
1043 set-hotlist-p | |
1044 set-server-p) | |
1045 (catch 'found | |
1046 (while t | |
1047 (let ((sexp (condition-case nil | |
1048 (read (current-buffer)) | |
1049 (end-of-file (throw 'found nil))))) | |
1050 (if (listp sexp) | |
1051 (cond | |
1052 ((eq (car sexp) 'eudc-set-server) | |
1053 (delete-region (save-excursion | |
1054 (backward-sexp) | |
1055 (point)) | |
1056 (point)) | |
1057 (setq set-server-p t)) | |
1058 ((and (eq (car sexp) 'setq) | |
1059 (eq (eudc-cadr sexp) 'eudc-server-hotlist)) | |
1060 (delete-region (save-excursion | |
1061 (backward-sexp) | |
1062 (point)) | |
1063 (point)) | |
1064 (setq set-hotlist-p t)) | |
1065 ((and (eq (car sexp) 'provide) | |
1066 (equal (eudc-cadr sexp) '(quote eudc-options-file))) | |
1067 (setq provide-p t))) | |
1068 (if (and provide-p | |
1069 set-hotlist-p | |
1070 set-server-p) | |
1071 (throw 'found t)))))) | |
1072 (if (eq (point-min) (point-max)) | |
1073 (princ ";; This file was automatically generated by eudc.el.\n\n")) | |
1074 (or provide-p | |
1075 (princ "(provide 'eudc-options-file)\n")) | |
1076 (or (bolp) | |
1077 (princ "\n")) | |
1078 (delete-blank-lines) | |
1079 (princ "(eudc-set-server ") | |
1080 (prin1 eudc-server) | |
1081 (princ " '") | |
1082 (prin1 eudc-protocol) | |
1083 (princ " t)\n") | |
1084 (princ "(setq eudc-server-hotlist '") | |
1085 (prin1 eudc-server-hotlist) | |
1086 (princ ")\n") | |
1087 (save-buffer)))) | |
1088 | |
1089 (defun eudc-move-to-next-record () | |
1090 "Move to next record, in a buffer displaying directory query results." | |
1091 (interactive) | |
1092 (if (not (eq major-mode 'eudc-mode)) | |
1093 (error "Not in a EUDC buffer") | |
1094 (let ((pt (next-overlay-change (point)))) | |
1095 (if (< pt (point-max)) | |
1096 (goto-char (1+ pt)) | |
1097 (error "No more records after point"))))) | |
1098 | |
1099 (defun eudc-move-to-previous-record () | |
1100 "Move to previous record, in a buffer displaying directory query results." | |
1101 (interactive) | |
1102 (if (not (eq major-mode 'eudc-mode)) | |
1103 (error "Not in a EUDC buffer") | |
1104 (let ((pt (previous-overlay-change (point)))) | |
1105 (if (> pt (point-min)) | |
1106 (goto-char pt) | |
1107 (error "No more records before point"))))) | |
1108 | |
1109 ;;}}} | |
1110 | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
1111 ;;{{{ Menus and keymaps |
27313 | 1112 |
1113 (require 'easymenu) | |
1114 | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1115 (setq eudc-mode-map |
27313 | 1116 (let ((map (make-sparse-keymap))) |
1117 (define-key map "q" 'kill-this-buffer) | |
1118 (define-key map "x" 'kill-this-buffer) | |
1119 (define-key map "f" 'eudc-query-form) | |
1120 (define-key map "b" 'eudc-try-bbdb-insert) | |
1121 (define-key map "n" 'eudc-move-to-next-record) | |
1122 (define-key map "p" 'eudc-move-to-previous-record) | |
1123 map)) | |
1124 (set-keymap-parent eudc-mode-map widget-keymap) | |
1125 | |
1126 (defconst eudc-custom-generated-menu (cdr (custom-menu-create 'eudc))) | |
1127 | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1128 (defconst eudc-tail-menu |
27313 | 1129 `(["---" nil nil] |
1130 ["Query with Form" eudc-query-form t] | |
1131 ["Expand Inline Query" eudc-expand-inline t] | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1132 ["Insert Record into BBDB" eudc-insert-record-at-point-into-bbdb |
27313 | 1133 (and (or (featurep 'bbdb) |
1134 (prog1 (locate-library "bbdb") (message ""))) | |
1135 (overlays-at (point)) | |
1136 (overlay-get (car (overlays-at (point))) 'eudc-record))] | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1137 ["Insert All Records into BBDB" eudc-batch-export-records-to-bbdb |
27313 | 1138 (and (eq major-mode 'eudc-mode) |
1139 (or (featurep 'bbdb) | |
1140 (prog1 (locate-library "bbdb") (message ""))))] | |
1141 ["---" nil nil] | |
1142 ["Get Email" eudc-get-email t] | |
1143 ["Get Phone" eudc-get-phone t] | |
1144 ["List Valid Attribute Names" eudc-get-attribute-list t] | |
1145 ["---" nil nil] | |
1146 ,(cons "Customize" eudc-custom-generated-menu))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1147 |
27313 | 1148 |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1149 (defconst eudc-server-menu |
27313 | 1150 '(["---" nil nil] |
1151 ["Bookmark Current Server" eudc-bookmark-current-server t] | |
1152 ["Edit Server List" eudc-edit-hotlist t] | |
1153 ["New Server" eudc-set-server t])) | |
1154 | |
1155 (defun eudc-menu () | |
1156 (let (command) | |
1157 (append '("Directory Search") | |
1158 (list | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1159 (append |
27313 | 1160 '("Server") |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1161 (mapcar |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1162 (function |
27313 | 1163 (lambda (servspec) |
1164 (let* ((server (car servspec)) | |
1165 (protocol (cdr servspec)) | |
1166 (proto-name (symbol-name protocol))) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1167 (setq command (intern (concat "eudc-set-server-" |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1168 server |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1169 "-" |
27313 | 1170 proto-name))) |
1171 (if (not (fboundp command)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1172 (fset command |
27313 | 1173 `(lambda () |
1174 (interactive) | |
1175 (eudc-set-server ,server (quote ,protocol)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1176 (message "Selected directory server is now %s (%s)" |
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1177 ,server |
27313 | 1178 ,proto-name)))) |
1179 (vector (format "%s (%s)" server proto-name) | |
1180 command | |
1181 :style 'radio | |
1182 :selected `(equal eudc-server ,server))))) | |
1183 eudc-server-hotlist) | |
1184 eudc-server-menu)) | |
1185 eudc-tail-menu))) | |
1186 | |
1187 (defun eudc-install-menu () | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1188 (cond |
27313 | 1189 ((and eudc-xemacs-p (featurep 'menubar)) |
1190 (add-submenu '("Tools") (eudc-menu))) | |
1191 (eudc-emacs-p | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1192 (cond |
47566
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1193 ((fboundp 'easy-menu-create-menu) |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1194 (define-key |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1195 global-map |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1196 [menu-bar tools directory-search] |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1197 (cons "Directory Search" |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1198 (easy-menu-create-menu "Directory Search" (cdr (eudc-menu)))))) |
27313 | 1199 ((fboundp 'easy-menu-add-item) |
1200 (let ((menu (eudc-menu))) | |
1201 (easy-menu-add-item nil '("tools") (easy-menu-create-menu (car menu) | |
1202 (cdr menu))))) | |
1203 ((fboundp 'easy-menu-create-keymaps) | |
1204 (easy-menu-define eudc-menu-map eudc-mode-map "Directory Client Menu" (eudc-menu)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1205 (define-key |
27313 | 1206 global-map |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1207 [menu-bar tools eudc] |
27313 | 1208 (cons "Directory Search" |
1209 (easy-menu-create-keymaps "Directory Search" (cdr (eudc-menu)))))) | |
1210 (t | |
1211 (error "Unknown version of easymenu")))) | |
1212 )) | |
1213 | |
1214 | |
1215 ;;; Load time initializations : | |
1216 | |
1217 ;;; Load the options file | |
1218 (if (and (not noninteractive) | |
1219 (and (locate-library eudc-options-file) | |
59681
c77eb52a1cca
(top level): Call (message "") via progn, so that
Eli Zaretskii <eliz@gnu.org>
parents:
57828
diff
changeset
|
1220 (progn (message "") t)) ; Remove modeline message |
27313 | 1221 (not (featurep 'eudc-options-file))) |
1222 (load eudc-options-file)) | |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1223 |
27313 | 1224 ;;; Install the full menu |
1225 (unless (featurep 'infodock) | |
1226 (eudc-install-menu)) | |
1227 | |
1228 | |
1229 ;;; The following installs a short menu for EUDC at XEmacs startup. | |
1230 | |
1231 ;;;###autoload | |
1232 (defun eudc-load-eudc () | |
1233 "Load the Emacs Unified Directory Client. | |
1234 This does nothing except loading eudc by autoload side-effect." | |
1235 (interactive) | |
1236 nil) | |
1237 | |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1238 ;;;###autoload |
42575
24c994803548
(top-level): Revert previous change.
Pavel Janík <Pavel@Janik.cz>
parents:
42569
diff
changeset
|
1239 (cond ((not (string-match "XEmacs" emacs-version)) |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1240 (defvar eudc-tools-menu (make-sparse-keymap "Directory Search")) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1241 (fset 'eudc-tools-menu (symbol-value 'eudc-tools-menu)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1242 (define-key eudc-tools-menu [phone] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1243 '("Get Phone" . eudc-get-phone)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1244 (define-key eudc-tools-menu [email] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1245 '("Get Email" . eudc-get-email)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1246 (define-key eudc-tools-menu [separator-eudc-email] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1247 '("--")) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1248 (define-key eudc-tools-menu [expand-inline] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1249 '("Expand Inline Query" . eudc-expand-inline)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1250 (define-key eudc-tools-menu [query] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1251 '("Query with Form" . eudc-query-form)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1252 (define-key eudc-tools-menu [separator-eudc-query] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1253 '("--")) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1254 (define-key eudc-tools-menu [new] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1255 '("New Server" . eudc-set-server)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1256 (define-key eudc-tools-menu [load] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1257 '("Load Hotlist of Servers" . eudc-load-eudc))) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1258 |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1259 (t |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1260 (let ((menu '("Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1261 ["Load Hotlist of Servers" eudc-load-eudc t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1262 ["New Server" eudc-set-server t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1263 ["---" nil nil] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1264 ["Query with Form" eudc-query-form t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1265 ["Expand Inline Query" eudc-expand-inline t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1266 ["---" nil nil] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1267 ["Get Email" eudc-get-email t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1268 ["Get Phone" eudc-get-phone t]))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1269 (if (not (featurep 'eudc-autoloads)) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1270 (if eudc-xemacs-p |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1271 (if (and (featurep 'menubar) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1272 (not (featurep 'infodock))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1273 (add-submenu '("Tools") menu)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1274 (require 'easymenu) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1275 (cond |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1276 ((fboundp 'easy-menu-add-item) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1277 (easy-menu-add-item nil '("tools") |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1278 (easy-menu-create-menu (car menu) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1279 (cdr menu)))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1280 ((fboundp 'easy-menu-create-keymaps) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1281 (define-key |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1282 global-map |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1283 [menu-bar tools eudc] |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1284 (cons "Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1285 (easy-menu-create-keymaps "Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1286 (cdr menu))))))))))) |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1287 |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1288 ;;}}} |
42569
df3f717a3933
(top-level): Use eudc-xemacs-p instead of string-match on emacs-version
Pavel Janík <Pavel@Janik.cz>
parents:
27324
diff
changeset
|
1289 |
27313 | 1290 (provide 'eudc) |
1291 | |
52401 | 1292 ;;; arch-tag: e18872b6-db83-400b-869d-be54e9a4160c |
27313 | 1293 ;;; eudc.el ends here |