From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: [PATCH] org-contacts.el: add expire feature Date: Wed, 29 May 2013 20:35:10 +0800 Message-ID: <87li6yx8u9.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfcA-0002Ui-LZ for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:36:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uhfc5-0005pV-PJ for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:36:26 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:37627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhfc5-0005pO-FV for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:36:21 -0400 Received: by mail-pd0-f169.google.com with SMTP id y11so8894557pdj.14 for ; Wed, 29 May 2013 05:36:20 -0700 (PDT) Received: from tumashu ([175.49.155.147]) by mx.google.com with ESMTPSA id cq1sm37218183pbc.13.2013.05.29.05.36.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 29 May 2013 05:36:19 -0700 (PDT) Received: from feng by news.tumashu-localhost.org with local (Exim 4.80) (envelope-from ) id 1Uhfaw-0001OA-Ec for emacs-orgmode@gnu.org; Wed, 29 May 2013 20:35:10 +0800 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: orgmode --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-contrib-lisp-org-contacts.el-Add-a-feature-which-can.patch Content-Transfer-Encoding: quoted-printable >From e974db131d88acf06bb6b250eac2fae8c7d0a96e Mon Sep 17 00:00:00 2001 From: Feng Shu Date: Wed, 29 May 2013 20:30:43 +0800 Subject: [PATCH] * contrib/lisp/org-contacts.el: Add a feature which can expire emails and phones * test :PROPERTIES: :EMAIL: test1@gmail.com test2@gmail.com test3@gmail.com :PHONE: 123456 123457 123458 :EXPIRE: test2@gmail.com 123457 :END: when completing or exporting to vcard, the emails and phones in the expire property (test2@gmail.com and 123457) will be ignore --- contrib/lisp/org-contacts.el | 32 +++++++++++++++++++++++++++----- 1 =E4=B8=AA=E6=96=87=E4=BB=B6=E8=A2=AB=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=8F=92= =E5=85=A5 27 =E8=A1=8C(+)=EF=BC=8C=E5=88=A0=E9=99=A4 5 =E8=A1=8C(-) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index 7b0b603..ae6c6f1 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -86,6 +86,11 @@ When set to nil, all your Org files will be used." :type 'string :group 'org-contacts) =20 +(defcustom org-contacts-expire-property "EXPIRE" + "Name of the property for emails or phones which will be expired" + :type 'string + :group 'org-contacts) + =20 (defcustom org-contacts-birthday-format "Birthday: %l (%Y)" "Format of the anniversary agenda entry. @@ -476,6 +481,14 @@ A group FOO is composed of contacts with the tag FOO." (completion-table-case-fold completion-list (not org-contacts-completion-ignore-case)))))))) =20 + +(defun org-contacts-remove-expired-property (expire-list list) + "Remove emails or phones in list-expired from list" + (while expire-list + (setq list (remove (car expire-list) list)) + (setq expire-list (cdr expire-list))) + list) + (defun org-contacts-complete-name (start end string) "Complete text at START with a user name and email." (let* ((completion-ignore-case org-contacts-completion-ignore-case) @@ -484,10 +497,17 @@ A group FOO is composed of contacts with the tag FOO." ;; The contact name is always the car of the assoc-list ;; returned by `org-contacts-filter'. for contact-name =3D (car contact) + + ;; Build the list of the email addresses which has + ;; been expired + for expire-list =3D (org-contacts-split-property (or + (cdr (assoc-string org-contacts-expire-property + (caddr contact))) "")) ;; Build the list of the user email addresses. - for email-list =3D (org-contacts-split-property (or - (cdr (assoc-string org-contacts-email-property - (caddr contact))) "")) + for email-list =3D (org-contacts-remove-expired-property expire-list + (org-contacts-split-property (or + (cdr (assoc-string org-contacts-email-property + (caddr contact))) ""))) ;; If the user has email addresses=E2=80=A6 if email-list ;; =E2=80=A6 append a list of USER . @@ -869,15 +889,17 @@ to do our best." (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))) + (expire (cdr (assoc-string org-contacts-expire-property properties))) (note (cdr (assoc-string org-contacts-note-property properties))) (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthda= y-property properties)))) (addr (cdr (assoc-string org-contacts-address-property properties))) (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nicknam= e-property properties)))) (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)) + (expire-list (when expire (setq expire-list (org-contacts-split-property= expire)))) emails-list result phones-list) (concat head (when email (progn - (setq emails-list (org-contacts-split-property email)) + (setq emails-list (org-contacts-remove-expired-property expire-list (= org-contacts-split-property email))) ; (setq result "") (while emails-list (setq result (concat result "EMAIL:" (org-contacts-strip-link (car= emails-list)) "\n")) @@ -886,7 +908,7 @@ to do our best." (when addr (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr))) (when tel (progn - (setq phones-list (org-contacts-split-property tel)) + (setq phones-list (org-contacts-remove-expired-property expire-list (or= g-contacts-split-property tel))) (setq result "") (while phones-list (setq result (concat result "TEL:" (org-contacts-strip-link (car pho= nes-list)) "\n")) --=20 1.7.10.4 --=-=-= Content-Type: text/plain -- --=-=-=--