Created
August 7, 2023 02:19
-
-
Save jwiegley/9a68fee57c5133baf1ea24cf11387d0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun gnus-harvest-org-contacts-complete-name (string) | |
"Complete text at START with a user name and email." | |
(let* ((completion-ignore-case org-contacts-completion-ignore-case) | |
(completion-list | |
(cl-loop for contact in (org-contacts-filter) | |
;; 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 | |
(nth 2 contact))) "")) | |
;; Build the list of the user email addresses. | |
for email-list = (org-contacts-remove-ignored-property-values | |
ignore-list | |
(org-contacts-split-property | |
(or (cdr (assoc-string org-contacts-email-property | |
(nth 2 contact))) ""))) | |
;; If the user has email addresses… | |
if email-list | |
;; … append a list of USER <EMAIL>. | |
nconc (cl-loop for email in email-list | |
collect (org-contacts-format-email | |
contact-name (org-contacts-strip-link email)))))) | |
(org-contacts-all-completions-prefix | |
string | |
(org-uniquify | |
(append (mapcar #'car (gnus-harvest-complete-stub | |
string gnus-harvest-match-by-prefix)) | |
completion-list))))) | |
(defun gnus-harvest-capf () | |
(save-excursion | |
(let ((end (point))) | |
(goto-char (line-beginning-position)) | |
(while (looking-at "[A-Z][a-z]+:") | |
(goto-char (match-end 0))) | |
(skip-syntax-forward " ") | |
(list (point) end | |
(completion-table-dynamic | |
#'gnus-harvest-org-contacts-complete-name) | |
;; (completion-table-dynamic | |
;; #'(lambda (stub) | |
;; (let ((addrs (and gnus-harvest-search-in-bbdb | |
;; (gnus-harvest-bbdb-complete-stub stub)))) | |
;; (if (stringp addrs) (list addrs) addrs)))) | |
;; (completion-table-dynamic | |
;; #'(lambda (stub) | |
;; (let ((addrs (gnus-harvest-mailalias-complete-stub stub))) | |
;; (if (stringp addrs) (list addrs) addrs)))) | |
)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment