1

Premise: I am not an expert of emacs-lisp, unfortunately.

I am handling all my emails with mu4e, and since it integrates well with org-contacts, I use the latter to handle my address book. However, I have not yet figured out how to handle mailing lists with org-contacts. I know I can use aliases :

    (setq mail-personal-alias-file (expand-file-name "/path/email-aliases.txt"))

but I find this rather unsatisfying. Is there any other way to specify a mailing list in org-contacts to use in mu4e? I am pretty sure someone has already cooked up a solution for himself, but could not find anything on the web.

1

Finally, I did it myself, and I am posting it here to help people looking for a solution to my problem.

I decided to use tags to specify a group of emails, thus the same contact can be part of several groups simply by tagging it several times.

Here is an example of contacts file:

* John Doe   :MailingListA:GroupB:
:PROPERTIES:
:EMAIL: john.doe@example.com
:NICK:
:DESCRIPTION:
:BIRTHDAY:
:END:

* Nick Smith :GroupB:
:PROPERTIES:
:EMAIL: nick.smith@aaaa.bb
:NICK:
:DESCRIPTION:
:BIRTHDAY:
:END:

* Rick Armstrong :MailingListA:
:PROPERTIES:
:EMAIL: rick.armstrong@bbbb.dd
:NICK:
:DESCRIPTION:
:BIRTHDAY:
:END:

And here is the code for parsing it and putting it in the current buffer:

    (defun my-contact-extract-all (elem)
      (let ((lname (nth 0 elem))
            (ladd (cdr (assoc "EMAIL" (nth 2 elem)))))
        (concat lname " <" ladd ">")))

    (defun get-mailing-list-from-tag(tag) 
      (let ((my-list (org-contacts-filter nil tag nil)))
        (mapconcat 'my-contact-extract-all my-list ", ")))

    (defun org-contacts-get-list-from-tag (tag) 
      "Returns a string containing all addresses from all contacts with a certain TAG"
      (interactive "sEnter tag:")
      (message (get-mailing-list-from-tag tag))
      (insert (get-mailing-list-from-tag tag)))

If you have suggestion on improvements to my code, please post a comment below.

2
  • How this is connected to mu4e? – Navidot Feb 6 at 18:18
  • Not really, indeed. I should have tagged just org-contact. – knulp Feb 14 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.