Merge changes from emacs-23 branch.
[bpt/emacs.git] / lisp / net / eudc.el
index 9fc5d0b..384ddbb 100644 (file)
@@ -1,7 +1,7 @@
 ;;; eudc.el --- Emacs Unified Directory Client
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <oscar@cpe.fr>
 ;; Maintainer: Pavel Janík <Pavel@Janik.cz>
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 ;;    This package provides a common interface to query directory servers using
@@ -708,7 +706,7 @@ server for future sessions."
   (setq eudc-server server)
   (eudc-update-local-variables)
   (run-hooks 'eudc-switch-to-server-hook)
-  (if (interactive-p)
+  (if (called-interactively-p 'interactive)
       (message "Current directory server is now %s (%s)" eudc-server eudc-protocol))
   (if (null no-save)
       (eudc-save-options)))
@@ -755,9 +753,10 @@ When called interactively the list is formatted in a dedicated buffer
 otherwise a list of symbols is returned."
   (interactive)
   (if eudc-list-attributes-function
-      (let ((entries (funcall eudc-list-attributes-function (interactive-p))))
+      (let ((entries (funcall eudc-list-attributes-function
+                             (called-interactively-p 'interactive))))
        (if entries
-           (if (interactive-p)
+           (if (called-interactively-p 'interactive)
                (eudc-display-records entries t)
              entries)))
     (error "The %s protocol has no support for listing attributes" eudc-protocol)))
@@ -933,7 +932,7 @@ see `eudc-inline-expansion-servers'"
          (or (and (equal eudc-server eudc-former-server)
                   (equal eudc-protocol eudc-former-protocol))
              (eudc-set-server eudc-former-server eudc-former-protocol t)))
-      (t
+      (error
        (or (and (equal eudc-server eudc-former-server)
                (equal eudc-protocol eudc-former-protocol))
           (eudc-set-server eudc-former-server eudc-former-protocol t))
@@ -1037,8 +1036,7 @@ queries the server for the existing fields and displays a corresponding form."
 (defun eudc-save-options ()
   "Save options to `eudc-options-file'."
   (interactive)
-  (save-excursion
-    (set-buffer (find-file-noselect eudc-options-file t))
+  (with-current-buffer (find-file-noselect eudc-options-file t)
     (goto-char (point-min))
     ;; delete the previous setq
     (let ((standard-output (current-buffer))
@@ -1243,25 +1241,25 @@ This does nothing except loading eudc by autoload side-effect."
   (defvar eudc-tools-menu
     (let ((map (make-sparse-keymap "Directory Search")))
       (define-key map [phone]
-       '(menu-item "Get Phone" eudc-get-phone
-                   :help "Get the phone field of name from the directory server"))
+       `(menu-item ,(purecopy "Get Phone") eudc-get-phone
+                   :help ,(purecopy "Get the phone field of name from the directory server")))
       (define-key map [email]
-       '(menu-item "Get Email" eudc-get-email
-                   :help "Get the email field of NAME from the directory server"))
-      (define-key map [separator-eudc-email] '("--"))
+       `(menu-item ,(purecopy "Get Email") eudc-get-email
+                   :help ,(purecopy "Get the email field of NAME from the directory server")))
+      (define-key map [separator-eudc-email] menu-bar-separator)
       (define-key map [expand-inline]
-       '(menu-item "Expand Inline Query" eudc-expand-inline
-                   :help "Query the directory server, and expand the query string before point"))
+       `(menu-item ,(purecopy "Expand Inline Query") eudc-expand-inline
+                   :help ,(purecopy "Query the directory server, and expand the query string before point")))
       (define-key map [query]
-       '(menu-item "Query with Form" eudc-query-form
-                   :help "Display a form to query the directory server"))
-      (define-key map [separator-eudc-query] '("--"))
+       `(menu-item ,(purecopy "Query with Form") eudc-query-form
+                   :help ,(purecopy "Display a form to query the directory server")))
+      (define-key map [separator-eudc-query] menu-bar-separator)
       (define-key map [new]
-       '(menu-item "New Server" eudc-set-server
-                   :help "Set the directory server to SERVER using PROTOCOL"))
+       `(menu-item ,(purecopy "New Server") eudc-set-server
+                   :help ,(purecopy "Set the directory server to SERVER using PROTOCOL")))
       (define-key map [load]
-       '(menu-item "Load Hotlist of Servers" eudc-load-eudc
-                   :help "Load the Emacs Unified Directory Client"))
+       `(menu-item ,(purecopy "Load Hotlist of Servers") eudc-load-eudc
+                   :help ,(purecopy "Load the Emacs Unified Directory Client")))
       map))
   (fset 'eudc-tools-menu (symbol-value 'eudc-tools-menu)))
  (t