Mercurial > emacs
comparison lisp/net/eudc.el @ 42781:cd8db5bd4819
New maintainer. Change author's address.
(eudc-pre-select-window-configuration, eudc-insertion-marker): Variables
removed.
(eudc-insert-selected): Function removed.
(eudc-select): Reimplemented.
(eudc-expand-inline): Delete the strings only after its expansion is chosen
not before.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Wed, 16 Jan 2002 08:21:29 +0000 |
parents | 24c994803548 |
children | 036e57c15cdc |
comparison
equal
deleted
inserted
replaced
42780:b136d94976d9 | 42781:cd8db5bd4819 |
---|---|
1 ;;; eudc.el --- Emacs Unified Directory Client | 1 ;;; eudc.el --- Emacs Unified Directory Client |
2 | 2 |
3 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Oscar Figueiredo <oscar@xemacs.org> | 5 ;; Author: Oscar Figueiredo <oscar@cpe.fr> |
6 ;; Maintainer: Oscar Figueiredo <oscar@xemacs.org> | 6 ;; Maintainer: Pavel Janík <Pavel@Janik.cz> |
7 ;; Keywords: comm | 7 ;; Keywords: comm |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
72 (defconst eudc-emacs-mule-p (and eudc-emacs-p | 72 (defconst eudc-emacs-mule-p (and eudc-emacs-p |
73 (featurep 'mule))) | 73 (featurep 'mule))) |
74 | 74 |
75 (defvar eudc-form-widget-list nil) | 75 (defvar eudc-form-widget-list nil) |
76 (defvar eudc-mode-map nil) | 76 (defvar eudc-mode-map nil) |
77 ;; Used by the selection insertion mechanism | |
78 (defvar eudc-pre-select-window-configuration nil) | |
79 (defvar eudc-insertion-marker nil) | |
80 | 77 |
81 ;; List of known servers | 78 ;; List of known servers |
82 ;; Alist of (SERVER . PROTOCOL) | 79 ;; Alist of (SERVER . PROTOCOL) |
83 (defvar eudc-server-hotlist nil) | 80 (defvar eudc-server-hotlist nil) |
84 | 81 |
373 (cdr trans) | 370 (cdr trans) |
374 attribute)) | 371 attribute)) |
375 list)) | 372 list)) |
376 list)) | 373 list)) |
377 | 374 |
378 (defun eudc-select (choices) | 375 (defun eudc-select (choices beg end) |
379 "Choose one from CHOICES using a completion buffer." | 376 "Choose one from CHOICES using a completion. |
380 (setq eudc-pre-select-window-configuration (current-window-configuration)) | 377 BEG and END delimit the text which is to be replaced." |
381 (setq eudc-insertion-marker (point-marker)) | 378 (let ((replacement)) |
382 (with-output-to-temp-buffer "*EUDC Completions*" | 379 (setq replacement |
383 (apply 'display-completion-list | 380 (completing-read "Multiple matches found; choose one:" |
384 choices | 381 (mapcar 'list choices))) |
385 (if eudc-xemacs-p | 382 (delete-region beg end) |
386 '(:activate-callback eudc-insert-selected))))) | 383 (insert replacement))) |
387 | |
388 (defun eudc-insert-selected (event extent user) | |
389 "Insert a completion at the appropriate point." | |
390 (when eudc-insertion-marker | |
391 (set-buffer (marker-buffer eudc-insertion-marker)) | |
392 (goto-char eudc-insertion-marker) | |
393 (insert (extent-string extent))) | |
394 (if eudc-pre-select-window-configuration | |
395 (set-window-configuration eudc-pre-select-window-configuration)) | |
396 (setq eudc-pre-select-window-configuration nil | |
397 eudc-insertion-marker nil)) | |
398 | 384 |
399 (defun eudc-query (query &optional return-attributes no-translation) | 385 (defun eudc-query (query &optional return-attributes no-translation) |
400 "Query the current directory server with QUERY. | 386 "Query the current directory server with QUERY. |
401 QUERY is a list of cons cells (ATTR . VALUE) where ATTR is an attribute | 387 QUERY is a list of cons cells (ATTR . VALUE) where ATTR is an attribute |
402 name and VALUE the corresponding value. | 388 name and VALUE the corresponding value. |
822 the preceding comma, colon or beginning of line. | 808 the preceding comma, colon or beginning of line. |
823 The variable `eudc-inline-query-format' controls how to associate the | 809 The variable `eudc-inline-query-format' controls how to associate the |
824 individual inline query words with directory attribute names. | 810 individual inline query words with directory attribute names. |
825 After querying the server for the given string, the expansion specified by | 811 After querying the server for the given string, the expansion specified by |
826 `eudc-inline-expansion-format' is inserted in the buffer at point. | 812 `eudc-inline-expansion-format' is inserted in the buffer at point. |
827 If REPLACE is non nil, then this expansion replaces the name in the buffer. | 813 If REPLACE is non-nil, then this expansion replaces the name in the buffer. |
828 `eudc-expansion-overwrites-query' being non nil inverts the meaning of REPLACE. | 814 `eudc-expansion-overwrites-query' being non-nil inverts the meaning of REPLACE. |
829 Multiple servers can be tried with the same query until one finds a match, | 815 Multiple servers can be tried with the same query until one finds a match, |
830 see `eudc-inline-expansion-servers'" | 816 see `eudc-inline-expansion-servers'" |
831 (interactive) | 817 (interactive) |
832 (if (memq eudc-inline-expansion-servers | 818 (if (memq eudc-inline-expansion-servers |
833 '(current-server server-then-hotlist)) | 819 '(current-server server-then-hotlist)) |
921 (setq response (cdr response))) | 907 (setq response (cdr response))) |
922 | 908 |
923 (if (or | 909 (if (or |
924 (and replace (not eudc-expansion-overwrites-query)) | 910 (and replace (not eudc-expansion-overwrites-query)) |
925 (and (not replace) eudc-expansion-overwrites-query)) | 911 (and (not replace) eudc-expansion-overwrites-query)) |
926 (delete-region beg end)) | 912 (kill-ring-save beg end)) |
927 (cond | 913 (cond |
928 ((or (= (length response-strings) 1) | 914 ((or (= (length response-strings) 1) |
929 (null eudc-multiple-match-handling-method) | 915 (null eudc-multiple-match-handling-method) |
930 (eq eudc-multiple-match-handling-method 'first)) | 916 (eq eudc-multiple-match-handling-method 'first)) |
917 (delete-region beg end) | |
931 (insert (car response-strings))) | 918 (insert (car response-strings))) |
932 ((eq eudc-multiple-match-handling-method 'select) | 919 ((eq eudc-multiple-match-handling-method 'select) |
933 (eudc-select response-strings)) | 920 (eudc-select response-strings beg end)) |
934 ((eq eudc-multiple-match-handling-method 'all) | 921 ((eq eudc-multiple-match-handling-method 'all) |
935 (insert (mapconcat 'identity response-strings ", "))) | 922 (insert (mapconcat 'identity response-strings ", "))) |
936 ((eq eudc-multiple-match-handling-method 'abort) | 923 ((eq eudc-multiple-match-handling-method 'abort) |
937 (error "There is more than one match for the query")) | 924 (error "There is more than one match for the query")))) |
938 )) | |
939 (or (and (equal eudc-server eudc-former-server) | 925 (or (and (equal eudc-server eudc-former-server) |
940 (equal eudc-protocol eudc-former-protocol)) | 926 (equal eudc-protocol eudc-former-protocol)) |
941 (eudc-set-server eudc-former-server eudc-former-protocol t))) | 927 (eudc-set-server eudc-former-server eudc-former-protocol t))) |
942 (t | 928 (t |
943 (or (and (equal eudc-server eudc-former-server) | 929 (or (and (equal eudc-server eudc-former-server) |
1113 (let ((pt (previous-overlay-change (point)))) | 1099 (let ((pt (previous-overlay-change (point)))) |
1114 (if (> pt (point-min)) | 1100 (if (> pt (point-min)) |
1115 (goto-char pt) | 1101 (goto-char pt) |
1116 (error "No more records before point"))))) | 1102 (error "No more records before point"))))) |
1117 | 1103 |
1118 | |
1119 ;;}}} | 1104 ;;}}} |
1120 | 1105 |
1121 ;;{{{ Menus an keymaps | 1106 ;;{{{ Menus an keymaps |
1122 | 1107 |
1123 (require 'easymenu) | 1108 (require 'easymenu) |