Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Addressee tagging generating a mailto link in the message body #179

Open
molok opened this issue Jan 17, 2024 · 2 comments

Comments

@molok
Copy link

molok commented Jan 17, 2024

In my work environment (Outlook based) I often see people tagging each other using @Name, which in Outlook actually generates a mailto link. I think it might be appropriate to have this kind of feature in org-msg.

@molok
Copy link
Author

molok commented Jan 31, 2024

example of such function

(defun org-msg-tag-addressee()
  "Completes an email address in the current buffer with an org-mode mailto link"
  (interactive)
  (let* ((addressees
          (append
           (mail-extract-address-components (org-msg-message-fetch-field "to") t)
           (mail-extract-address-components (org-msg-message-fetch-field "cc") t)))
         (mail-addresses (mapcar (lambda(e)
                                   (if (car e)
                                     (format "%s <%s>" (car e) (cadr e))
                                     (format "<%s>" (cadr e)))) addressees))
         (end (point))
         (start (save-excursion
                  (skip-chars-backward "^@")
                  (point)))
         (prefix (buffer-substring start end))
         (completion (completing-read "Complete email for: "
                                      mail-addresses
                                      (lambda (c)
                                        (string-match-p (regexp-quote prefix)
                                                        (downcase c)))
                                      t)))
    (if (not (string-equal prefix completion))
        (progn
          (delete-region (- start 1) end)
          (insert
            (if (string-match "\\(.*\\) <\\(.*\\)>" completion)
                (let ((name (match-string 1 completion))
                      (email (match-string 2 completion)))
                  (format "[[mailto:%s][@%s]]" email name))
              (if (string-match "<\\(.*\\)>" completion)
                  (let ((email (match-string 1 completion)))
                    (format "[[mailto:%s][@%s]]" email (car (split-string email "@")))))))))))

jeremy-compostella added a commit that referenced this issue Mar 19, 2024
It has become more and more popular in the last few years to refer to
a recipient of an email by adding a mailto link.  The
`org-msg-insert-recipient-mailto' function can be use to insert such a
mailto link. It is bound to "C-c @" in place of the default
`org-mark-subtree' org-mode function.

This commit addresses #179.

Signed-off-by: Jeremy Compostella <jeremy.compostella@gmail.com>
Suggested-by: Alessio Bolognino (molok)
@jeremy-compostella
Copy link
Owner

@molok Please review the pull request implementing this feature.

jeremy-compostella added a commit that referenced this issue Mar 19, 2024
It has become more and more popular in the last few years to refer to
a recipient of an email by adding a mailto link.  The
`org-msg-insert-recipient-mailto' function can be use to insert such a
mailto link. It is bound to "C-c @" in place of the default
`org-mark-subtree' org-mode function.

This commit addresses #179.

Signed-off-by: Jeremy Compostella <jeremy.compostella@gmail.com>
Suggested-by: Alessio Bolognino (molok)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants