Mercurial > emacs
annotate lisp/net/eudc.el @ 66153:e2fa815b43c1
(Quitting): Minor clarification.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 17 Oct 2005 16:19:56 +0000 |
parents | 33a4813c9bf4 |
children | 5f00d2caf8cf a3716f7538f2 |
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 | |
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 |
cd8db5bd4819
New maintainer. Change author's address.
Pavel Janík <Pavel@Janik.cz>
parents:
42575
diff
changeset
|
383 (completing-read "Multiple matches found; choose one:" |
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) |
926 (insert (mapconcat 'identity response-strings ", "))) | |
927 ((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
|
928 (error "There is more than one match for the query")))) |
27313 | 929 (or (and (equal eudc-server eudc-former-server) |
930 (equal eudc-protocol eudc-former-protocol)) | |
931 (eudc-set-server eudc-former-server eudc-former-protocol t))) | |
932 (t | |
933 (or (and (equal eudc-server eudc-former-server) | |
934 (equal eudc-protocol eudc-former-protocol)) | |
935 (eudc-set-server eudc-former-server eudc-former-protocol t)) | |
936 (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
|
937 |
27313 | 938 ;;;###autoload |
939 (defun eudc-query-form (&optional get-fields-from-server) | |
940 "Display a form to query the directory server. | |
941 If given a non-nil argument GET-FIELDS-FROM-SERVER, the function first | |
942 queries the server for the existing fields and displays a corresponding form." | |
943 (interactive "P") | |
944 (let ((fields (or (and get-fields-from-server | |
945 (eudc-get-attribute-list)) | |
946 eudc-query-form-attributes)) | |
947 (buffer (get-buffer-create "*Directory Query Form*")) | |
948 prompts | |
949 widget | |
950 (width 0) | |
951 inhibit-read-only | |
952 pt) | |
953 (switch-to-buffer buffer) | |
954 (setq inhibit-read-only t) | |
955 (erase-buffer) | |
956 (kill-all-local-variables) | |
957 (make-local-variable 'eudc-form-widget-list) | |
958 (widget-insert "Directory Query Form\n") | |
959 (widget-insert "====================\n\n") | |
960 (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
|
961 (progn |
27313 | 962 (call-interactively 'eudc-set-server) |
963 eudc-server)) | |
964 "\n") | |
965 (widget-insert "Protocol : " (symbol-name eudc-protocol) "\n") | |
966 ;; Build the list of prompts | |
967 (setq prompts (if eudc-use-raw-directory-names | |
968 (mapcar 'symbol-name (eudc-translate-attribute-list fields)) | |
969 (mapcar (function | |
970 (lambda (field) | |
971 (or (and (assq field eudc-user-attribute-names-alist) | |
972 (cdr (assq field eudc-user-attribute-names-alist))) | |
973 (capitalize (symbol-name field))))) | |
974 fields))) | |
975 ;; Loop over prompt strings to find the longest one | |
976 (mapcar (function | |
977 (lambda (prompt) | |
978 (if (> (length prompt) width) | |
979 (setq width (length prompt))))) | |
980 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
|
981 ;; 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
|
982 ;; in the first field |
27313 | 983 (widget-insert "\n\n" (format (concat "%" (int-to-string width) "s: ") (car prompts))) |
984 (setq pt (point)) | |
985 (setq widget (widget-create 'editable-field :size 15)) | |
986 (setq eudc-form-widget-list (cons (cons (car fields) widget) | |
987 eudc-form-widget-list)) | |
988 (setq fields (cdr fields)) | |
989 (setq prompts (cdr prompts)) | |
990 (mapcar (function | |
991 (lambda (field) | |
992 (widget-insert "\n\n" (format (concat "%" (int-to-string width) "s: ") (car prompts))) | |
993 (setq widget (widget-create 'editable-field | |
994 :size 15)) | |
995 (setq eudc-form-widget-list (cons (cons field widget) | |
996 eudc-form-widget-list)) | |
997 (setq prompts (cdr prompts)))) | |
998 fields) | |
999 (widget-insert "\n\n") | |
1000 (widget-create 'push-button | |
1001 :notify (lambda (&rest ignore) | |
1002 (eudc-process-form)) | |
1003 "Query Server") | |
1004 (widget-insert " ") | |
1005 (widget-create 'push-button | |
1006 :notify (lambda (&rest ignore) | |
1007 (eudc-query-form)) | |
1008 "Reset Form") | |
1009 (widget-insert " ") | |
1010 (widget-create 'push-button | |
1011 :notify (lambda (&rest ignore) | |
1012 (kill-this-buffer)) | |
1013 "Quit") | |
1014 (goto-char pt) | |
1015 (use-local-map widget-keymap) | |
1016 (widget-setup)) | |
1017 ) | |
1018 | |
1019 (defun eudc-bookmark-server (server protocol) | |
1020 "Add SERVER using PROTOCOL to the EUDC `servers' hotlist." | |
1021 (interactive "sDirectory server: \nsProtocol: ") | |
1022 (if (member (cons server protocol) eudc-server-hotlist) | |
1023 (error "%s:%s is already in the hotlist" protocol server) | |
1024 (setq eudc-server-hotlist (cons (cons server protocol) eudc-server-hotlist)) | |
1025 (eudc-install-menu) | |
1026 (eudc-save-options))) | |
1027 | |
1028 (defun eudc-bookmark-current-server () | |
1029 "Add current server to the EUDC `servers' hotlist." | |
1030 (interactive) | |
1031 (eudc-bookmark-server eudc-server eudc-protocol)) | |
1032 | |
1033 (defun eudc-save-options () | |
1034 "Save options to `eudc-options-file'." | |
1035 (interactive) | |
1036 (save-excursion | |
1037 (set-buffer (find-file-noselect eudc-options-file t)) | |
1038 (goto-char (point-min)) | |
1039 ;; delete the previous setq | |
1040 (let ((standard-output (current-buffer)) | |
1041 provide-p | |
1042 set-hotlist-p | |
1043 set-server-p) | |
1044 (catch 'found | |
1045 (while t | |
1046 (let ((sexp (condition-case nil | |
1047 (read (current-buffer)) | |
1048 (end-of-file (throw 'found nil))))) | |
1049 (if (listp sexp) | |
1050 (cond | |
1051 ((eq (car sexp) 'eudc-set-server) | |
1052 (delete-region (save-excursion | |
1053 (backward-sexp) | |
1054 (point)) | |
1055 (point)) | |
1056 (setq set-server-p t)) | |
1057 ((and (eq (car sexp) 'setq) | |
1058 (eq (eudc-cadr sexp) 'eudc-server-hotlist)) | |
1059 (delete-region (save-excursion | |
1060 (backward-sexp) | |
1061 (point)) | |
1062 (point)) | |
1063 (setq set-hotlist-p t)) | |
1064 ((and (eq (car sexp) 'provide) | |
1065 (equal (eudc-cadr sexp) '(quote eudc-options-file))) | |
1066 (setq provide-p t))) | |
1067 (if (and provide-p | |
1068 set-hotlist-p | |
1069 set-server-p) | |
1070 (throw 'found t)))))) | |
1071 (if (eq (point-min) (point-max)) | |
1072 (princ ";; This file was automatically generated by eudc.el.\n\n")) | |
1073 (or provide-p | |
1074 (princ "(provide 'eudc-options-file)\n")) | |
1075 (or (bolp) | |
1076 (princ "\n")) | |
1077 (delete-blank-lines) | |
1078 (princ "(eudc-set-server ") | |
1079 (prin1 eudc-server) | |
1080 (princ " '") | |
1081 (prin1 eudc-protocol) | |
1082 (princ " t)\n") | |
1083 (princ "(setq eudc-server-hotlist '") | |
1084 (prin1 eudc-server-hotlist) | |
1085 (princ ")\n") | |
1086 (save-buffer)))) | |
1087 | |
1088 (defun eudc-move-to-next-record () | |
1089 "Move to next record, in a buffer displaying directory query results." | |
1090 (interactive) | |
1091 (if (not (eq major-mode 'eudc-mode)) | |
1092 (error "Not in a EUDC buffer") | |
1093 (let ((pt (next-overlay-change (point)))) | |
1094 (if (< pt (point-max)) | |
1095 (goto-char (1+ pt)) | |
1096 (error "No more records after point"))))) | |
1097 | |
1098 (defun eudc-move-to-previous-record () | |
1099 "Move to previous record, in a buffer displaying directory query results." | |
1100 (interactive) | |
1101 (if (not (eq major-mode 'eudc-mode)) | |
1102 (error "Not in a EUDC buffer") | |
1103 (let ((pt (previous-overlay-change (point)))) | |
1104 (if (> pt (point-min)) | |
1105 (goto-char pt) | |
1106 (error "No more records before point"))))) | |
1107 | |
1108 ;;}}} | |
1109 | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
47566
diff
changeset
|
1110 ;;{{{ Menus and keymaps |
27313 | 1111 |
1112 (require 'easymenu) | |
1113 | |
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
|
1114 (setq eudc-mode-map |
27313 | 1115 (let ((map (make-sparse-keymap))) |
1116 (define-key map "q" 'kill-this-buffer) | |
1117 (define-key map "x" 'kill-this-buffer) | |
1118 (define-key map "f" 'eudc-query-form) | |
1119 (define-key map "b" 'eudc-try-bbdb-insert) | |
1120 (define-key map "n" 'eudc-move-to-next-record) | |
1121 (define-key map "p" 'eudc-move-to-previous-record) | |
1122 map)) | |
1123 (set-keymap-parent eudc-mode-map widget-keymap) | |
1124 | |
1125 (defconst eudc-custom-generated-menu (cdr (custom-menu-create 'eudc))) | |
1126 | |
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
|
1127 (defconst eudc-tail-menu |
27313 | 1128 `(["---" nil nil] |
1129 ["Query with Form" eudc-query-form t] | |
1130 ["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
|
1131 ["Insert Record into BBDB" eudc-insert-record-at-point-into-bbdb |
27313 | 1132 (and (or (featurep 'bbdb) |
1133 (prog1 (locate-library "bbdb") (message ""))) | |
1134 (overlays-at (point)) | |
1135 (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
|
1136 ["Insert All Records into BBDB" eudc-batch-export-records-to-bbdb |
27313 | 1137 (and (eq major-mode 'eudc-mode) |
1138 (or (featurep 'bbdb) | |
1139 (prog1 (locate-library "bbdb") (message ""))))] | |
1140 ["---" nil nil] | |
1141 ["Get Email" eudc-get-email t] | |
1142 ["Get Phone" eudc-get-phone t] | |
1143 ["List Valid Attribute Names" eudc-get-attribute-list t] | |
1144 ["---" nil nil] | |
1145 ,(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
|
1146 |
27313 | 1147 |
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
|
1148 (defconst eudc-server-menu |
27313 | 1149 '(["---" nil nil] |
1150 ["Bookmark Current Server" eudc-bookmark-current-server t] | |
1151 ["Edit Server List" eudc-edit-hotlist t] | |
1152 ["New Server" eudc-set-server t])) | |
1153 | |
1154 (defun eudc-menu () | |
1155 (let (command) | |
1156 (append '("Directory Search") | |
1157 (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
|
1158 (append |
27313 | 1159 '("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
|
1160 (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
|
1161 (function |
27313 | 1162 (lambda (servspec) |
1163 (let* ((server (car servspec)) | |
1164 (protocol (cdr servspec)) | |
1165 (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
|
1166 (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
|
1167 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 "-" |
27313 | 1169 proto-name))) |
1170 (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
|
1171 (fset command |
27313 | 1172 `(lambda () |
1173 (interactive) | |
1174 (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
|
1175 (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
|
1176 ,server |
27313 | 1177 ,proto-name)))) |
1178 (vector (format "%s (%s)" server proto-name) | |
1179 command | |
1180 :style 'radio | |
1181 :selected `(equal eudc-server ,server))))) | |
1182 eudc-server-hotlist) | |
1183 eudc-server-menu)) | |
1184 eudc-tail-menu))) | |
1185 | |
1186 (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
|
1187 (cond |
27313 | 1188 ((and eudc-xemacs-p (featurep 'menubar)) |
1189 (add-submenu '("Tools") (eudc-menu))) | |
1190 (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
|
1191 (cond |
47566
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1192 ((fboundp 'easy-menu-create-menu) |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1193 (define-key |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1194 global-map |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1195 [menu-bar tools directory-search] |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1196 (cons "Directory Search" |
65c4cd99d916
(eudc-install-menu): Use `define-key' and
John Paul Wallington <jpw@pobox.com>
parents:
47497
diff
changeset
|
1197 (easy-menu-create-menu "Directory Search" (cdr (eudc-menu)))))) |
27313 | 1198 ((fboundp 'easy-menu-add-item) |
1199 (let ((menu (eudc-menu))) | |
1200 (easy-menu-add-item nil '("tools") (easy-menu-create-menu (car menu) | |
1201 (cdr menu))))) | |
1202 ((fboundp 'easy-menu-create-keymaps) | |
1203 (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
|
1204 (define-key |
27313 | 1205 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
|
1206 [menu-bar tools eudc] |
27313 | 1207 (cons "Directory Search" |
1208 (easy-menu-create-keymaps "Directory Search" (cdr (eudc-menu)))))) | |
1209 (t | |
1210 (error "Unknown version of easymenu")))) | |
1211 )) | |
1212 | |
1213 | |
1214 ;;; Load time initializations : | |
1215 | |
1216 ;;; Load the options file | |
1217 (if (and (not noninteractive) | |
1218 (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
|
1219 (progn (message "") t)) ; Remove modeline message |
27313 | 1220 (not (featurep 'eudc-options-file))) |
1221 (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
|
1222 |
27313 | 1223 ;;; Install the full menu |
1224 (unless (featurep 'infodock) | |
1225 (eudc-install-menu)) | |
1226 | |
1227 | |
1228 ;;; The following installs a short menu for EUDC at XEmacs startup. | |
1229 | |
1230 ;;;###autoload | |
1231 (defun eudc-load-eudc () | |
1232 "Load the Emacs Unified Directory Client. | |
1233 This does nothing except loading eudc by autoload side-effect." | |
1234 (interactive) | |
1235 nil) | |
1236 | |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1237 ;;;###autoload |
42575
24c994803548
(top-level): Revert previous change.
Pavel Janík <Pavel@Janik.cz>
parents:
42569
diff
changeset
|
1238 (cond ((not (string-match "XEmacs" emacs-version)) |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1239 (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
|
1240 (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
|
1241 (define-key eudc-tools-menu [phone] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1242 '("Get Phone" . eudc-get-phone)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1243 (define-key eudc-tools-menu [email] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1244 '("Get Email" . eudc-get-email)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1245 (define-key eudc-tools-menu [separator-eudc-email] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1246 '("--")) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1247 (define-key eudc-tools-menu [expand-inline] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1248 '("Expand Inline Query" . eudc-expand-inline)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1249 (define-key eudc-tools-menu [query] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1250 '("Query with Form" . eudc-query-form)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1251 (define-key eudc-tools-menu [separator-eudc-query] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1252 '("--")) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1253 (define-key eudc-tools-menu [new] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1254 '("New Server" . eudc-set-server)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1255 (define-key eudc-tools-menu [load] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1256 '("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
|
1257 |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1258 (t |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1259 (let ((menu '("Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1260 ["Load Hotlist of Servers" eudc-load-eudc t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1261 ["New Server" eudc-set-server t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1262 ["---" nil nil] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1263 ["Query with Form" eudc-query-form t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1264 ["Expand Inline Query" eudc-expand-inline t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1265 ["---" nil nil] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1266 ["Get Email" eudc-get-email t] |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1267 ["Get Phone" eudc-get-phone t]))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1268 (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
|
1269 (if eudc-xemacs-p |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1270 (if (and (featurep 'menubar) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1271 (not (featurep 'infodock))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1272 (add-submenu '("Tools") menu)) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1273 (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
|
1274 (cond |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1275 ((fboundp 'easy-menu-add-item) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1276 (easy-menu-add-item nil '("tools") |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1277 (easy-menu-create-menu (car menu) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1278 (cdr menu)))) |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1279 ((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
|
1280 (define-key |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1281 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
|
1282 [menu-bar tools eudc] |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1283 (cons "Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1284 (easy-menu-create-keymaps "Directory Search" |
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1285 (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
|
1286 |
27324
e33d394fe874
(toplevel): Define EUDC menu for Emacs.
Gerd Moellmann <gerd@gnu.org>
parents:
27320
diff
changeset
|
1287 ;;}}} |
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
|
1288 |
27313 | 1289 (provide 'eudc) |
1290 | |
52401 | 1291 ;;; arch-tag: e18872b6-db83-400b-869d-be54e9a4160c |
27313 | 1292 ;;; eudc.el ends here |