From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: Converting org-mode/org-contacts to VCard (importing to Android) Date: Sat, 23 Nov 2013 16:29:07 +0800 Message-ID: <87siunmsh8.fsf@news.tumashu-localhost.org> References: <2013-11-22T17-28-29@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk8e2-0001Rb-Ou for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:32:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vk8dy-0002sC-7r for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:32:50 -0500 Received: from mail-pb0-x233.google.com ([2607:f8b0:400e:c01::233]:39215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk8dy-0002rw-0l for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:32:46 -0500 Received: by mail-pb0-f51.google.com with SMTP id up15so2466752pbc.24 for ; Sat, 23 Nov 2013 00:32:44 -0800 (PST) Received: from news.tumashu-localhost.org ([120.4.247.91]) by mx.google.com with ESMTPSA id hn5sm47443920pbb.25.2013.11.23.00.32.41 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 23 Nov 2013 00:32:43 -0800 (PST) Received: from feng by news.tumashu-localhost.org with local (Exim 4.80) (envelope-from ) id 1Vk8aR-0004lN-3O for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 16:29:07 +0800 In-Reply-To: <2013-11-22T17-28-29@devnull.Karl-Voit.at> (Karl Voit's message of "Fri, 22 Nov 2013 17:37:01 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Karl Voit writes: > Hi! > > I wrote a Python script that parses an Org-mode file in order to > generate a VCard 2.1 compatible output file I am using to import to > my Android 4.4 device: > > https://github.com/novoid/org-contacts2vcard > > The reason I wrote it in Python is that I don't know ELISP well > enough. The reason I wrote the script instead of using existing > export methods: I only want to export a small sub-set (names, phone > numbers, email addresses, contact image) due to privacy reasons. the below function will only export name, phones and email #+begin_src (defun org-contacts-vcard-format (contact) "Formats CONTACT in VCard 3.0 format." (let* ((properties (caddr contact)) (name (org-contacts-vcard-escape (car contact))) (n (org-contacts-vcard-encode-name name)) (email (cdr (assoc-string org-contacts-email-property properties))) (tel (cdr (assoc-string org-contacts-tel-property properties))) (ignore-list (cdr (assoc-string org-contacts-ignore-property properties))) (ignore-list (when ignore-list (org-contacts-split-property ignore-list))) (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)) emails-list result phones-list) (concat head (when email (progn (setq emails-list (org-contacts-remove-ignored-property-values ignore-list (org-contacts-split-property email))) (setq result "") (while emails-list (setq result (concat result "EMAIL:" (org-contacts-strip-link (car emails-list)) "\n")) (setq emails-list (cdr emails-list))) result)) (when tel (progn (setq phones-list (org-contacts-remove-ignored-property-values ignore-list (org-contacts-split-property tel))) (setq result "") (while phones-list (setq result (concat result "TEL:" (org-link-unescape (org-contacts-strip-link (car phones-list))) "\n")) (setq phones-list (cdr phones-list))) result)) "END:VCARD\n\n"))) #+end_src > > So far, it is a one-direction approach and no synchronization > solution. > > > > By the way: does somebody know of any somewhat intelligent tool that > is able to compare two different VCard files? The main issue here is > the fact that VCard order and property order within a single VCard > can be different but the VCard file could still contain the same > information. So line-by-line comparisons like diff do not work here. This may be difficult, I use org-contacts and use a elisp function to merge all the contacs which have same name. then export contacts to a vcard file. --