From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daimrod Subject: Re: [PATCH] org-contacts.el: add expire feature Date: Wed, 29 May 2013 23:20:46 +0200 Message-ID: <87wqqhlchq.fsf@tanger.home> References: <87li6yx8u9.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhnko-00080g-TT for emacs-orgmode@gnu.org; Wed, 29 May 2013 17:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhnkO-00057l-2i for emacs-orgmode@gnu.org; Wed, 29 May 2013 17:17:54 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:57623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhnkN-00057K-MQ for emacs-orgmode@gnu.org; Wed, 29 May 2013 17:17:28 -0400 Received: by mail-wi0-f179.google.com with SMTP id hq7so3929708wib.6 for ; Wed, 29 May 2013 14:17:26 -0700 (PDT) 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: Feng Shu Cc: orgmode --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Feng Shu writes: Hello Feng, Thanks for this interesting feature, here are some remarks: > 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 Could you use the org-mode convention for commit messages?[1] It should be: #+BEGIN_SRC change-log contrib/lisp/org-contacts.el: Add a feature which can expire emails and p= hones =20=20 ,* contrib/lisp/org-contacts.el: Add a feature which can expire emails and phones. =20=20 ...[rest of the commit message]... #+END_SRC > * 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 Since the purpose of this property is to ignore some values when exporting to vcard, don't you think it would be better to name it IGNORE or VCARD_IGNORE? (and of course to rename all functions accordingly) > --- > 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=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=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=20 > + > +(defun org-contacts-remove-expired-property (expire-list list) > + "Remove emails or phones in list-expired from list" Don't forget the dot at the end of the sentence. > + (while expire-list > + (setq list (remove (car expire-list) list)) > + (setq expire-list (cdr expire-list))) > + list) > + This is not very idiomatic elisp, I would write something more like: #+BEGIN_SRC emacs-lisp (remove-if (lambda (el) (member el expire-list))=20 list) #+END_SRC > (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 FO= O." > ;; 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-birth= day-property properties)))) > (addr (cdr (assoc-string org-contacts-address-property properties))) > (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickn= ame-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-proper= ty 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))) ; There is a leading semi-colon. = ^^^^ > (setq result "") > (while emails-list > (setq result (concat result "EMAIL:" (org-contacts-strip-link (c= ar 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 (= org-contacts-split-property tel))) > (setq result "") > (while phones-list > (setq result (concat result "TEL:" (org-contacts-strip-link (car p= hones-list)) "\n")) > --=20 > 1.7.10.4 [1] http://orgmode.org/worg/org-contribute.html#sec-5 =2D-=20 Daimrod/Greg --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQIcBAEBAgAGBQJRpnEzAAoJEBNzVHcrZRiUwPYQAItXhZR58+z8/Bq6UywQjnSm phGt6D55tNNDcZktl58FQWSpLx6CPVmuU8pTnUKBSIsPYl0LhlZAzxSyvMB6NvF+ Qov4bb9pY0tPLUd1kxY2P/mGSkW6JNpcRr9W0GClnqLZtraIrkrBwybDjnmJ/rbI nf7Giz3mqqux3QQ2Ph+xIPyJ0T3CErnVTQal5+sk2nTZMhkozaHRfNaT/g0nZN/n ni+VDLy+onFEyI39FZ43/fGuYt5bTW89ceWsNa7xgHCB++XMY31WvV9dk0lSSsSv k6ZNMHKur3BtyPt1PWsjvz7zwRiqII//xu97UNdWJIccOexBesQQhq4xAJCZ3W3r LdlkZriGC7v6+xp7+2eJ0bmE+rOOIKLcs48HwhtqxvrO2VJH3j8I5Bi+g5gKEBm3 9knfkOGMqvMB46MYZG2SyphC27XgQeIn5m/zKzmYf85tYsY1kRNjTar2zY+RU+we 0FAL+5dnEwo2MehpobDBEq5zq4oZOk0MgbAX97o1nHfq+gX7V6/Y36W5uRXTRdAF WTjXBJBTMMfOwOkYrPhIQc0vBfUsRyc72fSaCyULSprZ88A9L9/B/9G3GVva4EK4 MCcVSHGQnhhuhtJ7ZcjWAAyqyPvRiQLLt8epR/IAafS8bv4NyKY8xEbUaR0iPP7Y J70lUiIaWDjd+lg4gmVh =xP8f -----END PGP SIGNATURE----- --=-=-=--