emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-contacts fe466ab2ae 139/154: Add org-mode mailto: l


From: ELPA Syncer
Subject: [elpa] externals/org-contacts fe466ab2ae 139/154: Add org-mode mailto: link type :complete supporting
Date: Fri, 9 Sep 2022 15:58:55 -0400 (EDT)

branch: externals/org-contacts
commit fe466ab2aeeb4201179be88ac58a997473214aad
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    Add org-mode mailto: link type :complete supporting
---
 org-contacts.el | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/org-contacts.el b/org-contacts.el
index b06e39f16a..d452118f90 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -1318,7 +1318,7 @@ Each element has the form (NAME . (FILE . POSITION))."
 ;;;###autoload
 (defun org-contacts-link-complete (&optional _arg)
   "Create a org-contacts link using completion."
-  (let ((name (completing-read "org-contact Name: "
+  (let ((name (completing-read "org-contacts NAME: "
                                (mapcar
                                 (lambda (plist) (plist-get plist :name))
                                 (org-contacts--all-contacts)))))
@@ -1331,6 +1331,32 @@ Each element has the form (NAME . (FILE . POSITION))."
     '(:background "sky blue" :overline t :slant 'italic))
    (t '(:inherit 'org-link))))
 
+
+;;; org-mode link "mailto:"; email completion.
+(org-link-set-parameters "mailto" :complete 
#'org-contacts-mailto-link-completion)
+
+(defun org-contacts-mailto-link--get-all-emails ()
+  "Retrieve all org-contacts EMAIL property values."
+  (mapcar
+   (lambda (contact)
+     (let* ((org-contacts-buffer (find-file-noselect (car org-contacts-files)))
+            (name (plist-get contact :name))
+            (position (plist-get contact :position))
+            (email (save-excursion
+                     (with-current-buffer org-contacts-buffer
+                       (goto-char position)
+                       ;; (symbol-name (org-property-or-variable-value 'EMAIL))
+                       (org-entry-get (point) "EMAIL")))))
+       ;; (cons name email)
+       email))
+   (org-contacts--all-contacts)))
+
+(defun org-contacts-mailto-link-completion (&optional _arg)
+  "Org mode link `mailto:' completion with org-contacts emails."
+  (let ((email (completing-read "org-contacts EMAIL: "
+                                (org-contacts-mailto-link--get-all-emails))))
+    (concat "mailto:"; email)))
+
 (provide 'org-contacts)
 
 ;;; org-contacts.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]