Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-31 Thread Karl Voit
* Feng Shu tuma...@gmail.com wrote:

 I have changed it to IGNORE

Thank you very much!

It will help your users to learn and understand this cool feature!

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
get Memacs from https://github.com/novoid/Memacs 

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github




Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

 Daimrod daim...@gmail.com 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  =  te...@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.

-- 
Daimrod/Greg


signature.asc
Description: PGP signature


Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Feng Shu
Daimrod daim...@gmail.com writes:

 Feng Shu tuma...@gmail.com writes:

 Daimrod daim...@gmail.com 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  =  te...@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.

It's very power,I will copy it! 
Thanks!

-- 



Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Feng Shu
Daimrod daim...@gmail.com writes:

 Feng Shu tuma...@gmail.com writes:

 Daimrod daim...@gmail.com 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  =  te...@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!

From 362bf0657a0a270416d5e9b51aaba868ad963439 Mon Sep 17 00:00:00 2001
From: Feng Shu tuma...@gmail.com
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 个文件被修改,插入 29 行(+),删除 5 行(-)

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)
 
+(defcustom org-contacts-ignore-property IGNORE
+  Name of the property,  which values will be ignored when complete or export to vcard.
+  :type 'string
+  :group 'org-contacts)
+
 
 (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
 
+
+(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 = (car contact)
+
+		;; Build the list of the email addresses which has
+		;; been expired
+		for ignore-list = (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 = (org-contacts-split-property (or
-		(cdr (assoc-string org-contacts-email-property
-   (caddr contact))) ))
+		for email-list = (org-contacts-remove-ignored-property-values ignore-list
+	  (org-contacts-split-property (or
+	(cdr (assoc-string org-contacts-email-property
+			   (caddr contact))) )))
 		;; If the user has email addresses…
 		if email-list
 		;; … append a list of USER EMAIL.
@@ -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-birthday-property properties
 	 (addr (cdr (assoc-string org-contacts-address-property properties)))
 	 (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-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 )
 			  

Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Karl Voit
* Daimrod daim...@gmail.com wrote:

 Feng Shu tuma...@gmail.com writes:

 * test
   :PROPERTIES:
   :EMAIL: te...@gmail.com  te...@gmail.com  te...@gmail.com
   :PHONE:  123456  123457 123458
   :EXPIRE:  te...@gmail.com 123457
   :END:

 when completing or exporting to vcard,  the emails and  phones in the
 expire property (te...@gmail.com and 123457) will be ignore

This is a very good patch, fixing an issue I also do have currently.

 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)

I totally agree.

At first, I could not follow Feng Shu's explanation because I
thought that some (meta-) data gets expired after a certain period
of time. But then I realized that he meant that these things expired
in the past.

From the user point of view, I also do think that renaming the
property from :EXPIRE: to :IGNORE: would be better in terms of
understanding its purpose and how it works.

(If you do tend to keep the wording, I would at least rename it to
:EXPIRED: which emphasizes the fact that these things expired in the
past.)

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
get Memacs from https://github.com/novoid/Memacs 

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github




Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Feng Shu
Karl Voit devn...@karl-voit.at writes:

 * Daimrod daim...@gmail.com wrote:

 Feng Shu tuma...@gmail.com writes:

 * test
   :PROPERTIES:
   :EMAIL: te...@gmail.com  te...@gmail.com  te...@gmail.com
   :PHONE:  123456  123457 123458
   :EXPIRE:  te...@gmail.com 123457
   :END:

 when completing or exporting to vcard,  the emails and  phones in the
 expire property (te...@gmail.com and 123457) will be ignore

 This is a very good patch, fixing an issue I also do have currently.

 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)

 I totally agree.


I have changed it to IGNORE
 At first, I could not follow Feng Shu's explanation because I
 thought that some (meta-) data gets expired after a certain period
 of time. But then I realized that he meant that these things expired
 in the past.

 From the user point of view, I also do think that renaming the
 property from :EXPIRE: to :IGNORE: would be better in terms of
 understanding its purpose and how it works.

 (If you do tend to keep the wording, I would at least rename it to
 :EXPIRED: which emphasizes the fact that these things expired in the
 past.)

-- 



Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

 Hi Daimrod!
 This is the 3 updated patch, if possible, please include it to master.

It's merged and pushed. I've also pushed another commit to fix the
formatting in some parts of the code and I've found a bug in
`org-contacts-split-property', but it should be fixed now.

 Thanks for your help!

-- 
Daimrod/Greg


signature.asc
Description: PGP signature


Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Daimrod
Karl Voit devn...@karl-voit.at writes:

Hi Karl,

 This is a very good patch, fixing an issue I also do have currently.

I am curious, what was the issue?

Regards,

-- 
Daimrod/Greg


signature.asc
Description: PGP signature


Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-30 Thread Feng Shu
Daimrod daim...@gmail.com writes:

 Feng Shu tuma...@gmail.com writes:

 Hi Daimrod!
 This is the 3 updated patch, if possible, please include it to master.

 It's merged and pushed. I've also pushed another commit to fix the
 formatting in some parts of the code and I've found a bug in
 `org-contacts-split-property', but it should be fixed now.

Thanks! 

Now I want to code a function:
(defun org-contacts-add-value-to-ignore-property (value)
  Create agenda view for contacts matching NAME.
  (interactive (list (read-string Ignored email or phone: )))

...

)


1. find a contact which email or phone property include the value ,If the
   result is two or more different contacts, message: Two or more
   contacts, abort!.
  
2. add the value to the ignore property of  the result contact


Any suggestion?

Thanks!

 Thanks for your help!

-- 



Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-29 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

Hello Feng,

Thanks for this interesting feature, here are some remarks:

 From e974db131d88acf06bb6b250eac2fae8c7d0a96e Mon Sep 17 00:00:00 2001
 From: Feng Shu tuma...@gmail.com
 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 phones
  
  ,* contrib/lisp/org-contacts.el: Add a feature which can expire
  emails and phones.
  
  ...[rest of the commit message]...
#+END_SRC

 * test
   :PROPERTIES:
   :EMAIL: te...@gmail.com  te...@gmail.com  te...@gmail.com
   :PHONE:  123456  123457 123458
   :EXPIRE:  te...@gmail.com 123457
   :END:

 when completing or exporting to vcard,  the emails and  phones in the
 expire property (te...@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 个文件被修改,插入 27 行(+),删除 5 行(-)

 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)
  
 +(defcustom org-contacts-expire-property EXPIRE
 +  Name of the property for emails or phones which will be expired
 +  :type 'string
 +  :group 'org-contacts)
 +
  
  (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
  
 +
 +(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)) 
 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 FOO.
   ;; The contact name is always the car of the assoc-list
   ;; returned by `org-contacts-filter'.
   for contact-name = (car contact)
 +
 + ;; Build the list of the email addresses which has
 + ;; been expired
 + for expire-list = (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 = (org-contacts-split-property (or
 - (cdr (assoc-string 
 org-contacts-email-property
 -(caddr 
 contact))) ))
 + for email-list = (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…
   if email-list
   ;; … append a list of USER EMAIL.
 @@ -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-birthday-property properties
(addr (cdr (assoc-string org-contacts-address-property properties)))
(nick (org-contacts-vcard-escape (cdr (assoc-string 
 

Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-29 Thread Daimrod
Feng Shu tuma...@gmail.com writes:

  (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 = (car contact)
 +
 + ;; Build the list of the email addresses which has
 + ;; been expired
 + for expire-list = (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 = (org-contacts-split-property (or
 - (cdr (assoc-string 
 org-contacts-email-property
 -(caddr 
 contact))) ))
 + for email-list = (org-contacts-remove-expired-property 
 expire-list
 +
 (org-contacts-split-property (or
 + 
  (cdr (assoc-string org-contacts-email-property
 + 
 (caddr contact))) )))

I forgot to ask, why do you also modify org-contacts-complete-name? This
function isn't used to export to VCARD, but to complete the email in
Gnus.

-- 
Daimrod/Greg


signature.asc
Description: PGP signature


Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-29 Thread Feng Shu
Daimrod daim...@gmail.com writes:

 Feng Shu tuma...@gmail.com writes:

  (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 = (car contact)
 +
 +;; Build the list of the email addresses which has
 +;; been expired
 +for expire-list = (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 = (org-contacts-split-property (or
 -(cdr (assoc-string 
 org-contacts-email-property
 -   (caddr 
 contact))) ))
 +for email-list = (org-contacts-remove-expired-property 
 expire-list
 +   
 (org-contacts-split-property (or
 +
  (cdr (assoc-string org-contacts-email-property
 +
 (caddr contact))) )))

 I forgot to ask, why do you also modify org-contacts-complete-name? This
 function isn't used to export to VCARD, but to complete the email in
 Gnus.

I want to ignore the emails which have been expired when I complete in
the gnus

-- 



Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-29 Thread Feng Shu
Daimrod daim...@gmail.com writes:

updated patch;

From b0851e4c48e4c2e67fd8aafdf04951e764e07ccf Mon Sep 17 00:00:00 2001
From: Feng Shu tuma...@gmail.com
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 |   31 ++-
 1 个文件被修改,插入 26 行(+),删除 5 行(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 7b0b603..1be0ac9 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)
 
+(defcustom org-contacts-ignore-property IGNORE
+  Name of the property,  which values will be ignored when complete or export to vcard.
+  :type 'string
+  :group 'org-contacts)
+
 
 (defcustom org-contacts-birthday-format Birthday: %l (%Y)
   Format of the anniversary agenda entry.
@@ -476,6 +481,13 @@ A group FOO is composed of contacts with the tag FOO.
 		(completion-table-case-fold completion-list
 	(not org-contacts-completion-ignore-case
 
+
+(defun org-contacts-remove-ignored-property-values (ignore-list list)
+  Remove all ignore-list's elements from list.
+  (remove-if (lambda (el)
+	   (member 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 +496,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 = (car contact)
+
+		;; Build the list of the email addresses which has
+		;; been expired
+		for ignore-list = (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 = (org-contacts-split-property (or
-		(cdr (assoc-string org-contacts-email-property
-   (caddr contact))) ))
+		for email-list = (org-contacts-remove-ignored-property-values ignore-list
+	  (org-contacts-split-property (or
+	(cdr (assoc-string org-contacts-email-property
+			   (caddr contact))) )))
 		;; If the user has email addresses…
 		if email-list
 		;; … append a list of USER EMAIL.
@@ -869,15 +888,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-birthday-property properties
 	 (addr (cdr (assoc-string org-contacts-address-property properties)))
 	 (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-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 +907,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-list (org-contacts-split-property tel)))
 			(setq result )
 			(while phones-list
 			  (setq result (concat result  TEL: (org-contacts-strip-link (car phones-list)) \n))
-- 
1.7.10.4



Re: [O] [PATCH] org-contacts.el: add expire feature

2013-05-29 Thread Feng Shu
Daimrod daim...@gmail.com 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  =  te...@gmail.com