unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: "Raimund Berger" <raimund.berger@gmail.com>
Cc: 17720@debbugs.gnu.org
Subject: bug#17720: 24.3; EUDC LDAP duplicate mail handling broken.
Date: Wed, 24 Dec 2014 01:30:06 -0500	[thread overview]
Message-ID: <m3vbl1v9u9.fsf@fitzsim.org> (raw)
In-Reply-To: <87ha3yx6xm.fsf@gigli.quasi.internal> (Raimund Berger's message of "Fri, 06 Jun 2014 19:51:33 +0200")

[-- Attachment #1: Type: text/plain, Size: 53 bytes --]

Hi Raimund,

Can you try this patch?

Thanks,
Thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs-eudc-ldap-combine-mail-fields.patch --]
[-- Type: text/x-patch, Size: 2174 bytes --]

diff --git a/lisp/net/eudcb-ldap.el b/lisp/net/eudcb-ldap.el
index 6c806d7..1c5bab2 100644
--- a/lisp/net/eudcb-ldap.el
+++ b/lisp/net/eudcb-ldap.el
@@ -74,16 +74,28 @@
 		   '(eudc-ldap-check-base)
 		   'ldap)
 
+(defun eudc-ldap-combine-mail-fields (record)
+  "Combine mail fields in RECORD."
+  (let (result)
+    (dolist (element record)
+      (let ((result-element (assoc (car element) result)))
+	(if (and result-element (eq (car element) 'mail))
+	    (setf (cdr result-element)
+		  (list (cdr result-element) (cdr element)))
+	  (setq result (append result (list element))))))
+    result))
+
 (defun eudc-ldap-cleanup-record-simple (record)
   "Do some cleanup in a RECORD to make it suitable for EUDC."
-  (mapcar
-   (function
-    (lambda (field)
-      (cons (intern (car field))
-	    (if (cdr (cdr field))
-		(cdr field)
-	      (car (cdr field))))))
-   record))
+  (eudc-ldap-combine-mail-fields
+   (mapcar
+    (function
+     (lambda (field)
+       (cons (intern (car field))
+	     (if (cdr (cdr field))
+		 (cdr field)
+	       (car (cdr field))))))
+    record)))
 
 (defun eudc-filter-$ (string)
   (mapconcat 'identity (split-string string "\\$") "\n"))
@@ -92,18 +104,19 @@
 ;;   Make the record a cons-cell instead of a list if it is single-valued
 ;;   Filter the $ character in addresses into \n if not done by the LDAP lib
 (defun eudc-ldap-cleanup-record-filtering-addresses (record)
-  (mapcar
-   (function
-    (lambda (field)
-      (let ((name (intern (car field)))
-	    (value (cdr field)))
-	(if (memq name '(postaladdress registeredaddress))
-	    (setq value (mapcar 'eudc-filter-$ value)))
-	(cons name
-	      (if (cdr value)
-		  value
-		(car value))))))
-   record))
+  (eudc-ldap-combine-mail-fields
+   (mapcar
+    (function
+     (lambda (field)
+       (let ((name (intern (car field)))
+	     (value (cdr field)))
+	 (if (memq name '(postaladdress registeredaddress))
+	     (setq value (mapcar 'eudc-filter-$ value)))
+	 (cons name
+	       (if (cdr value)
+		   value
+		 (car value))))))
+    record)))
 
 (defun eudc-ldap-simple-query-internal (query &optional return-attrs)
   "Query the LDAP server with QUERY.

  reply	other threads:[~2014-12-24  6:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 17:51 bug#17720: 24.3; EUDC LDAP duplicate mail handling broken Raimund Berger
2014-12-24  6:30 ` Thomas Fitzsimmons [this message]
2015-03-06  3:26   ` Thomas Fitzsimmons
2015-03-06  8:05 ` Thomas Fitzsimmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3vbl1v9u9.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=17720@debbugs.gnu.org \
    --cc=raimund.berger@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).