[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-contacts-rebased 666da7a 061/118: contrib/lisp/org-co
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/org-contacts-rebased 666da7a 061/118: contrib/lisp/org-contacts.el: Add a feature, which can ignore emails or phones with property |
Date: |
Fri, 12 Nov 2021 15:37:04 -0500 (EST) |
branch: scratch/org-contacts-rebased
commit 666da7a493d3c71863378ef7af156f1b9e693214
Author: Feng Shu <tumashu@gmail.com>
Commit: Grégoire Jadi <gregoire.jadi@gmail.com>
contrib/lisp/org-contacts.el: 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.
---
org-contacts.el | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/org-contacts.el b/org-contacts.el
index 7b0b603..2aee0f6 100644
--- a/org-contacts.el
+++ b/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 "")
(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-list
(org-contacts-split-property tel)))
(setq result "")
(while phones-list
(setq result (concat result "TEL:"
(org-contacts-strip-link (car phones-list)) "\n"))
- [elpa] scratch/org-contacts-rebased 7f9ad6a 059/118: contrib/lisp/org-contacts.el: Permit to unload properly `org-contacts', (continued)
- [elpa] scratch/org-contacts-rebased 7f9ad6a 059/118: contrib/lisp/org-contacts.el: Permit to unload properly `org-contacts', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased c71bbd2 060/118: contrib/lisp/org-contacts.el (org-contacts-vcard-format): Silence byte-compiler, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased f259246 063/118: contrib/lisp/org-contacts.el: Add a complex org-contacts template to the file header, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased dbe6325 065/118: org-contacts: Ensure contacts cache is updated if it contains markers with no buffer, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased f62bfeb 066/118: org-contacts: use `org-' prefixed variants of cl functions, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 13d35c9 072/118: Update copyright years again., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased b970428 091/118: Rationalize `org-link-(un)escape', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5a2519c 048/118: org-contacts.el, add note property, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 9dec69a 056/118: contrib/lisp/org-contacts: Introduce the constant `org-contacts-property-values-separators', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5e67fd8 068/118: Update copyright years., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 666da7a 061/118: contrib/lisp/org-contacts.el: Add a feature, which can ignore emails or phones with property,
Stefan Monnier <=
- [elpa] scratch/org-contacts-rebased 7d47f48 062/118: contrib/lisp/org-contacts.el: Various formatting improvements and bug fixes, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased a452869 067/118: un-hexify TEL links in vCard export, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased e6e9fd8 071/118: Merge branch 'maint', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased dc57e62 058/118: org-contacts: Fix org-contacts-gnus-article-from-goto, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 19baaca 073/118: Merge branch 'maint', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5be58f1 075/118: contrib/lisp/org-contacts.el: Factorize the construction of the database, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5e05b4d 077/118: contrib/lisp/org-contacts.el: Fix a bug when contacts don't have an email address, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 9c27250 078/118: contrib/lisp/org-contacts.el: Allow the user to customize interactively the vcard export, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 3b371ff 080/118: org-contacts.el: Catch `nextfile' in `org-contacts-db', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased cfa1db0 081/118: Remove some home-grown copies of cl-lib functions., Stefan Monnier, 2021/11/12