From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: [PATCH] org-contacts.el: add expire feature Date: Thu, 30 May 2013 19:32:17 +0800 Message-ID: <871u8on1oe.fsf@news.tumashu-localhost.org> References: <87li6yx8u9.fsf@news.tumashu-localhost.org> <87wqqhlchq.fsf@tanger.home> <8738t5xpwe.fsf@news.tumashu-localhost.org> <87ip20vjnp.fsf@tanger.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui16s-0001hQ-1F for emacs-orgmode@gnu.org; Thu, 30 May 2013 07:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui16m-0002Qi-OR for emacs-orgmode@gnu.org; Thu, 30 May 2013 07:33:33 -0400 Received: from mail-pb0-x231.google.com ([2607:f8b0:400e:c01::231]:64901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui16m-0002QR-Eh for emacs-orgmode@gnu.org; Thu, 30 May 2013 07:33:28 -0400 Received: by mail-pb0-f49.google.com with SMTP id rp8so181373pbb.36 for ; Thu, 30 May 2013 04:33:27 -0700 (PDT) In-Reply-To: <87ip20vjnp.fsf@tanger.home> (daimrod@gmail.com's message of "Thu, 30 May 2013 12:36:42 +0200") 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: Daimrod Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Daimrod writes: > Feng Shu writes: > >> Daimrod writes: >> >>> >>> This is not very idiomatic elisp, I would write something more like: >>> #+BEGIN_SRC emacs-lisp >>> (remove-if (lambda (el) >>> (member el expire-list)) >>> list) >>> #+END_SRC >> >> Thanks! >> >> Is this possible? >> >> test1@g = test1@gmail.com > > Yes, you could do it like this: > #+BEGIN_SRC emacs-lisp > (remove-if (lambda (el) > (find-if (lambda (x) > (string-match-p x el)) > expire-list)) > list) > #+END_SRC > > This way you can use regular expressions in the ignore list. Hi Daimrod! This is the 3 updated patch, if possible, please include it to master. Thanks for your help! --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Add-a-feature-which-can-ignore-emails-or-phones-with.patch Content-Transfer-Encoding: quoted-printable >From 362bf0657a0a270416d5e9b51aaba868ad963439 Mon Sep 17 00:00:00 2001 From: Feng Shu Date: Wed, 29 May 2013 20:30:43 +0800 Subject: [PATCH] Add a feature, which can ignore emails or phones with property * contrib/lisp/org-contacts.el (org-contacts-ignore-property): New variable. (org-contacts-remove-ignored-property-values): New function, which remove all ignore-list's elements from list. (org-contacts-complete-name): When completing, ignore the values which has been included into the ignore property. (org-contacts-vcard-format): Don't export the values which has been included into the ignore property. If emails or phones is included into the ignore property, they will not show in complete buffer. When the contact is exported to vcard, they will be ignored too. --- contrib/lisp/org-contacts.el | 34 +++++++++++++++++++++++++++++----- 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 29 =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..2aee0f6 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-ignore-property "IGNORE" + "Name of the property, which values will be ignored when complete or ex= port to vcard." + :type 'string + :group 'org-contacts) + =20 (defcustom org-contacts-birthday-format "Birthday: %l (%Y)" "Format of the anniversary agenda entry. @@ -476,6 +481,16 @@ 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-ignored-property-values (ignore-list list) + "Remove all ignore-list's elements from list and you can use + regular expressions in the ignore list." + (remove-if (lambda (el) + (find-if (lambda (x) + (string-match-p x el)) + ignore-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 +499,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 ignore-list =3D (org-contacts-split-property (or + (cdr (assoc-string org-contacts-ignore-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-ignored-property-values ignore-l= ist + (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 +891,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))) + (ignore (cdr (assoc-string org-contacts-ignore-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)) + (ignore-list (when ignore (setq ignore-list (org-contacts-split-property= ignore)))) emails-list result phones-list) (concat head (when email (progn - (setq emails-list (org-contacts-split-property email)) + (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")) @@ -886,7 +910,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-ignored-property-values ignore-l= ist (org-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 -- --=-=-=--