[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-contacts bd83216f38 079/154: contrib/lisp/org-conta
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-contacts bd83216f38 079/154: contrib/lisp/org-contacts.el: Complete contacts using tags and properties |
Date: |
Fri, 9 Sep 2022 15:58:32 -0400 (EDT) |
branch: externals/org-contacts
commit bd83216f38f3bf50dee382e0c6057defda0a03a5
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 a7559f75b9..9ddf28d472 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] externals/org-contacts 2f8b3f024c 108/154: Prefer HTTPS to HTTP for links to gnu.org, (continued)
- [elpa] externals/org-contacts 2f8b3f024c 108/154: Prefer HTTPS to HTTP for links to gnu.org, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts f64d6edcd0 121/154: Update source code metadata keywords and usage description, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts bdf172eab8 129/154: Merge branch 'complete-contact', ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts dba21b4895 153/154: Decrease emacs and cl-lib version requirements., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts f5394bc0b6 147/154: Warning user that the custom variable `org-contacts-files' is nil., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 3a24177c3a 070/154: un-hexify TEL links in vCard export, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 58edab6f69 134/154: Add autoload cookirs for completing functions, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 7ed94bcf72 140/154: Fix can't get-buffer when file is not opened which caused `buf` is nil., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 05522de61d 146/154: Setting package require versions list, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts cf8ae48b37 142/154: Add if logic on function erc-nicknames-list, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts bd83216f38 079/154: contrib/lisp/org-contacts.el: Complete contacts using tags and properties,
ELPA Syncer <=
- [elpa] externals/org-contacts 2e77024e89 017/154: Copyright year fixes for contrib/., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 4170ea25f3 090/154: Deprecate `org-find-if' in favor of `cl-find-if', ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts c1a17bf632 076/154: Merge branch 'maint', ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 2de057e423 145/154: Make org-link-set-parameters <- org-add-link-type API compatible., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 21d4ae5367 141/154: Improve the alternative org-contacts headline goto., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts c1c4cadf3f 151/154: Fix Warning: Unused lexical argument, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts a50ced61ef 093/154: Update tel link definition, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts f02da8b4de 088/154: org-contacts: Register "tel" link, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 80ab4708b7 114/154: Change how completion is done, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 1b028de47c 124/154: Fix contacts complete not working problem, ELPA Syncer, 2022/09/09