emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 090cbf9 01/17: Change eudc-server-hotlist from a de


From: Stefan Monnier
Subject: [Emacs-diffs] master 090cbf9 01/17: Change eudc-server-hotlist from a defvar to a defcustom
Date: Fri, 23 Jan 2015 22:20:29 +0000

branch: master
commit 090cbf9b46465ffb46430021be782a4569afd5a6
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>

    Change eudc-server-hotlist from a defvar to a defcustom
    
    * 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        |   10 ++++++++++
 lisp/net/eudc-vars.el |   25 ++++++++++++++++++++++++-
 lisp/net/eudc.el      |   35 ++++++++++++++++++++---------------
 3 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4c9b60e..3a68f33 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-13  Thomas Fitzsimmons  <address@hidden>
+
+       * 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  <address@hidden>
 
        * Version 24.4 released.
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el
index 419b764..54995a3 100644
--- a/lisp/net/eudc-vars.el
+++ b/lisp/net/eudc-vars.el
@@ -41,7 +41,10 @@
   "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
diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el
index bf67e4b..e038b28 100644
--- a/lisp/net/eudc.el
+++ b/lisp/net/eudc.el
@@ -76,10 +76,6 @@
 
 (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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]