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