X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fsmime-ldap.el;h=25d3bd8bfcb55c6ba39d279a23ab1951a09437bf;hb=26eca13465f697cd34c9ce6a4a9321eecc17b15c;hp=020c8495213073c1fd6355abe9ae4746295e5f3d;hpb=8ba06f9d7f4b6a0090b36c769622ac3ff0d0bfec;p=gnus diff --git a/lisp/smime-ldap.el b/lisp/smime-ldap.el index 020c84952..25d3bd8bf 100644 --- a/lisp/smime-ldap.el +++ b/lisp/smime-ldap.el @@ -11,7 +11,7 @@ ;; 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 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -21,8 +21,8 @@ ;; 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., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -31,14 +31,7 @@ ;; made to achieve compatibility with OpenLDAP v2 and to make it ;; possible to retrieve LDAP attributes that are tagged ie ";binary". -;; When Gnus drops support for Emacs 21.x this file can be removed and -;; smime.el changed to - -;; - (require 'smime-ldap) => (require 'ldap) -;; - (smime-ldap-search ...) => (ldap-search ...) - -;; If we are running in Emacs 22 or newer it just uses the build-in -;; version of ldap-search. +;; The file also adds a compatibility layer for Emacs and XEmacs. ;;; Code: @@ -57,26 +50,11 @@ its distinguished name WITHDN. Additional search parameters can be specified through `ldap-host-parameters-alist', which see." (interactive "sFilter:") - (if (>= emacs-major-version 22) - (ldap-search filter host attributes attrsonly) - (or host - (setq host ldap-default-host) - (error "No LDAP host specified")) - (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) - result) - (setq result (smime-ldap-search-internal - (append host-plist - (list 'host host - 'filter filter - 'attributes attributes - 'attrsonly attrsonly - 'withdn withdn)))) - (if ldap-ignore-attribute-codings - result - (mapcar (function - (lambda (record) - (mapcar 'ldap-decode-attribute record))) - result))))) + ;; for XEmacs + (if (fboundp 'ldap-search-entries) + (ldap-search-entries filter host attributes attrsonly) + ;; for Emacs + (cdr (ldap-search filter host attributes attrsonly)))) (defun smime-ldap-search-internal (search-plist) "Perform a search on a LDAP server. @@ -122,8 +100,7 @@ an alist of attribute/value pairs." (equal "" filter)) (error "No search filter")) (setq filter (cons filter attributes)) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (erase-buffer) (if (and host (not (equal "" host))) @@ -183,8 +160,7 @@ an alist of attribute/value pairs." "\\(<[\t ]*file://\\)?\\(.*\\)$")) (setq name (match-string 1) value (match-string 4)) - (save-excursion - (set-buffer bufval) + (with-current-buffer bufval (erase-buffer) (insert-file-contents-literally value) (delete-file value)