[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-contacts-rebased d3509e4 076/118: contrib/lisp/org-co
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/org-contacts-rebased d3509e4 076/118: contrib/lisp/org-contacts.el: Complete contacts using tags and properties |
Date: |
Fri, 12 Nov 2021 15:37:07 -0500 (EST) |
branch: scratch/org-contacts-rebased
commit d3509e44ed46c5c528dacb5d6b0dfdbd5988e03d
Author: Grégoire Jadi <gregoire.jadi@gmail.com>
Commit: Grégoire Jadi <gregoire.jadi@gmail.com>
contrib/lisp/org-contacts.el: Complete contacts using tags and properties
* contrib/lisp/org-contacts.el (org-contacts-complete-tags-props): New
function that allows the user to retrieve contacts based on tags and
properties.
(org-contacts-complete-functions): Add
org-contacts-complete-tags-props to the completion functions.
(org-contacts-tags-props-prefix): Prefix used to detect the
completion method wished.
Based on the idea and implementation of John Kitchin
---
org-contacts.el | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/org-contacts.el b/org-contacts.el
index a7559f7..9ddf28d 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -155,6 +155,11 @@ The following replacements are available:
:type 'string
:group 'org-contacts)
+(defcustom org-contacts-tags-props-prefix "#"
+ "Tags and properties prefix."
+ :type 'string
+ :group 'org-contacts)
+
(defcustom org-contacts-matcher
(mapconcat 'identity (list org-contacts-email-property
org-contacts-alias-property
@@ -184,7 +189,7 @@ This overrides `org-email-link-description-format' if set."
:type 'boolean)
(defcustom org-contacts-complete-functions
- '(org-contacts-complete-group org-contacts-complete-name)
+ '(org-contacts-complete-group org-contacts-complete-tags-props
org-contacts-complete-name)
"List of functions used to complete contacts in `message-mode'."
:group 'org-contacts
:type 'hook)
@@ -523,6 +528,43 @@ 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-complete-tags-props (start end matcher)
+ "Insert emails that match the tags expression.
+
+For example: FOO-BAR will match entries tagged with FOO but not
+with BAR.
+
+See (org) Matching tags and properties for a complete
+description."
+ (let* ((completion-ignore-case org-contacts-completion-ignore-case)
+ (completion-p (org-string-match-p
+ (concat "^" org-contacts-tags-props-prefix)
string)))
+ (when completion-p
+ (let ((result
+ (mapconcat
+ 'identity
+ (loop for contact in (org-contacts-db)
+ for contact-name = (car contact)
+ for email = (org-contacts-strip-link (car
(org-contacts-split-property
+ (or
+ (cdr
(assoc-string org-contacts-email-property
+
(caddr contact)))
+ ""))))
+ for tags = (cdr (assoc "TAGS" (nth 2 contact)))
+ for tags-list = (if tags
+ (split-string (substring (cdr (assoc
"TAGS" (nth 2 contact))) 1 -1) ":")
+ '())
+ if (let ((todo-only nil))
+ (eval (cdr (org-make-tags-matcher matcher))))
+
+ collect (org-contacts-format-email contact-name email))
+ ",")))
+ (when (not (string= "" result))
+ ;; return (start end function)
+ (lexical-let* ((to-return result))
+ (list start end
+ (lambda (string pred &optional to-ignore) to-return))))))))
+
(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."
- [elpa] scratch/org-contacts-rebased 03dc64d 110/118: Change how completion is done, (continued)
- [elpa] scratch/org-contacts-rebased 03dc64d 110/118: Change how completion is done, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 18ba907 114/118: Try to support different type of AVATAR property., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 45bc95a 083/118: org-contacts: Fix org-contacts-matcher for BIRTHDAYs, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 49dd482 089/118: Use `string-match-p' instead of `org-string-match-p', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 124cc7a 098/118: org-contacts.el: Add usage comments, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased b2837af 109/118: simplify logic, remove unused variables, switch to lexical binding, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5174678 116/118: Fix AVATAR property value not exist problem, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 1be8aa9 069/118: Merge branch 'maint', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 9c233be 070/118: Revert "Update copyright years.", Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased fc25530 074/118: contrib/lisp/org-contacts.el: Add a hook to allow users to plug completion functions, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased d3509e4 076/118: contrib/lisp/org-contacts.el: Complete contacts using tags and properties,
Stefan Monnier <=
- [elpa] scratch/org-contacts-rebased 6bcb093 079/118: contrib: Fix error messages., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 44968ec 084/118: Make `org-make-tags-matcher' lexical binding friendly, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 034be20 093/118: org-contacts.el: Add new link type "contact:", Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 7161351 094/118: contrib/lisp/org-contacts.el: Add stardiviner as the maintainer, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 3beb906 057/118: org-contacts: Use progress-reporter for cache update message, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 0c439a4 102/118: org-contacts.el: Fix store link function does not return link., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased cf0668a 064/118: org-contacts: Provide ordering when using cycle completion, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 8e07b36 082/118: contrib: move a few libraries to cl-lib in place of compile-time cl., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 9a80cca 085/118: org-contacts: Register "tel" link, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 3ed6376 086/118: org-agenda: Remove unnecessary visibility modification, Stefan Monnier, 2021/11/12