]> git.eshelyaron.com Git - emacs.git/commitdiff
Change eudc-server-hotlist from a defvar to a defcustom
authorThomas Fitzsimmons <fitzsim@fitzsim.org>
Thu, 13 Nov 2014 05:50:01 +0000 (00:50 -0500)
committerThomas Fitzsimmons <fitzsim@fitzsim.org>
Thu, 13 Nov 2014 05:50:01 +0000 (00:50 -0500)
* net/eudc-vars.el (eudc-server): Adjust docstring to mention
eudc-server-hotlist.
(eudc-server-hotlist): Move from eudc.el and make defcustom.
* net/eudc.el (eudc-server-hotlist): Move to eudc-vars.el.
(eudc-set-server): Allow setting protocol to nil.
(eudc-expand-inline): Support hotlist-only expansions when server
is not set.

lisp/ChangeLog
lisp/net/eudc-vars.el
lisp/net/eudc.el

index 4c9b60ea4cd124aec4c0d2e6f519af7b503bbd97..3a68f33044dfe9879ad10b8e10917c5244c51a69 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-13  Thomas Fitzsimmons  <fitzsim@fitzsim.org>
+
+       * net/eudc-vars.el (eudc-server): Adjust docstring to mention
+       eudc-server-hotlist.
+       (eudc-server-hotlist): Move from eudc.el and make defcustom.
+       * net/eudc.el (eudc-server-hotlist): Move to eudc-vars.el.
+       (eudc-set-server): Allow setting protocol to nil.
+       (eudc-expand-inline): Support hotlist-only expansions when server
+       is not set.
+
 2014-10-20  Glenn Morris  <rgm@gnu.org>
 
        * Version 24.4 released.
index 419b764e27e864fea9967ca9eac95da54434eabd..54995a334c99164dc1207c355cfaeacb7cf7e0c6 100644 (file)
   "The name or IP address of the directory server.
 A port number may be specified by appending a colon and a
 number to the name of the server.  Use `localhost' if the directory
-server resides on your computer (BBDB backend)."
+server resides on your computer (BBDB backend).
+
+To specify multiple servers, customize eudc-server-hotlist
+instead."
   :type  '(choice (string :tag "Server") (const :tag "None" nil))
   :group 'eudc)
 
@@ -49,6 +52,26 @@ server resides on your computer (BBDB backend)."
 ;; Not to be mistaken with `eudc-supported-protocols'
 (defvar eudc-known-protocols '(bbdb ph ldap))
 
+(defcustom eudc-server-hotlist nil
+"Directory servers to query.
+This is an alist of the form (SERVER . PROTOCOL).  SERVER is the
+host name or URI of the server, PROTOCOL is a symbol representing
+the EUDC backend with which to access the server.
+
+The BBDB backend ignores SERVER; `localhost' can be used as a
+placeholder string."
+  :tag   "Directory Servers to Query"
+  :type  `(repeat (cons :tag "Directory Server"
+                       (string :tag "Server Host Name or URI")
+                       (choice :tag "Protocol"
+                               :menu-tag "Protocol"
+                               ,@(mapcar (lambda (s)
+                                           (list 'const
+                                                 ':tag (symbol-name s) s))
+                                         eudc-known-protocols)
+                               (const :tag "None" nil))))
+  :group 'eudc)
+
 (defvar eudc-supported-protocols nil
   "Protocols currently supported by EUDC.
 This variable is updated when protocol-specific libraries
index bf67e4b59114c41e64b8d4fd8a7aed75505514bd..e038b280979c8dc1c5b8f464025137fd9569c5c5 100644 (file)
 
 (defvar mode-popup-menu)
 
-;; List of known servers
-;; Alist of (SERVER . PROTOCOL)
-(defvar eudc-server-hotlist nil)
-
 ;; List of variables that have server- or protocol-local bindings
 (defvar eudc-local-vars nil)
 
@@ -688,7 +684,8 @@ server for future sessions."
                                                    (cons (symbol-name elt)
                                                          elt))
                                                 eudc-known-protocols)))))
-  (unless (or (member protocol
+  (unless (or (null protocol)
+             (member protocol
                      eudc-supported-protocols)
              (load (concat "eudcb-" (symbol-name protocol)) t))
     (error "Unsupported protocol: %s" protocol))
@@ -812,12 +809,21 @@ If REPLACE is non-nil, then this expansion replaces the name in the buffer.
 Multiple servers can be tried with the same query until one finds a match,
 see `eudc-inline-expansion-servers'"
   (interactive)
-  (if (memq eudc-inline-expansion-servers
-           '(current-server server-then-hotlist))
-      (or eudc-server
-         (call-interactively 'eudc-set-server))
+  (cond
+   ((eq eudc-inline-expansion-servers 'current-server)
+    (or eudc-server
+       (call-interactively 'eudc-set-server)))
+   ((eq eudc-inline-expansion-servers 'server-then-hotlist)
+    (or eudc-server
+       ;; Allow server to be nil if hotlist is set.
+       eudc-server-hotlist
+       (call-interactively 'eudc-set-server)))
+   ((eq eudc-inline-expansion-servers 'hotlist)
     (or eudc-server-hotlist
        (error "No server in the hotlist")))
+   (t
+    (error "Wrong value for `eudc-inline-expansion-servers': %S"
+          eudc-inline-expansion-servers)))
   (let* ((end (point))
         (beg (save-excursion
                (if (re-search-backward "\\([:,]\\|^\\)[ \t]*"
@@ -840,13 +846,12 @@ see `eudc-inline-expansion-servers'"
           ((eq eudc-inline-expansion-servers 'hotlist)
            eudc-server-hotlist)
           ((eq eudc-inline-expansion-servers 'server-then-hotlist)
-           (cons (cons eudc-server eudc-protocol)
-                 (delete (cons eudc-server eudc-protocol) servers)))
+           (if eudc-server
+               (cons (cons eudc-server eudc-protocol)
+                     (delete (cons eudc-server eudc-protocol) servers))
+             eudc-server-hotlist))
           ((eq eudc-inline-expansion-servers 'current-server)
-           (list (cons eudc-server eudc-protocol)))
-          (t
-           (error "Wrong value for `eudc-inline-expansion-servers': %S"
-                  eudc-inline-expansion-servers))))
+           (list (cons eudc-server eudc-protocol)))))
     (if (and eudc-max-servers-to-query
             (> (length servers) eudc-max-servers-to-query))
        (setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil))