helm-org-contacts icon indicating copy to clipboard operation
helm-org-contacts copied to clipboard

A helm source address books in org-contacts format

#+TITLE: helm-org-contacts – A Helm source for org-contacts #+AUTHOR: Titus von der Malsburg #+EMAIL: [email protected]

This helm source can be used to search contacts stored in org-contacts format.

[[file:screenshot.png]]

The screenshot shows the entries stored in the org-contacts file shown below.

#+BEGIN_SRC

  • Forrest Gump :PROPERTIES: :ADDRESS: 100 Waters Edge, 30314 Baytown, LA, United States of America (WORK) :ADDRESS: 42 Plantation St., 30314 Baytown, LA, United States of America (HOME) :PHONE: +1-111-555-1212 (WORK, VOICE) :PHONE: +1-404-555-1212 (HOME, VOICE) :TITLE: Shrimp Man :PHOTO: http://www.example.com/dir_photos/my_photo.gif (GIF) :REV: [2008-04-24 Thu 19:52] :N: Gump;Forrest;Mr.;; :ORG: Bubba Gump Shrimp Co. :LABEL: 100 Waters Edge, Baytown (WORK) :LABEL: 42 Plantation St., Baytown (HOME) :EMAIL: [email protected] (PREF, INTERNET) :END:
  • Derik Stenerson :PROPERTIES: :PHONE: +1-425-936-5522 (WORK, MSG) :PHONE: +1-425-936-7329 (WORK, FAX) :ADDRESS: One Microsoft Way, 98052-6399 Redmond, WA, USA (WORK, POSTAL, PARCEL) :BDAY: 1963-09-21 :N: Stenerson;Derik;;; :ORG: Microsoft Corporation :EMAIL: [email protected] (INTERNET) :END:
  • Anik Ganguly :PROPERTIES: :PHONE: +1-734-542-5955 (WORK, MSG) :ADDRESS: 38777 West Six Mile Road, 48152 Livonia, MI, USA, Suite 101 (WORK, POSTAL, PARCEL) :ORG: Open Text Inc. :N: Ganguly;Anik;;; :EMAIL: [email protected] (INTERNET) :END:
  • Robert Moskowitz :PROPERTIES: :EMAIL: [email protected] (INTERNET) :N: Moskowitz;Robert;;; :END: #+END_SRC

This file was generated from a Vcard file using [[https://gist.github.com/tmalsburg/9747104][a simple python script]].

** Install and configure

  • Place ~helm-org-contacts.el~ somewhere in the load path.
  • Add ~(require 'helm-org-contacts)~ to init files.
  • Helm-org-contacts uses the first entry in ~org-contact-files~ as the address book. If this value changes, helm-org-contacts automatically loads the new file.

** Usage Call ~M-x helm-org-contacts~ to start searching. Alternatively bind ~helm-org-contacts~ to some key combination.

The following actions are available for contacts:

  • insert postal addresses
  • insert plain email address
  • insert email address decorated with name (e.g., ~Forrest Gump [email protected]~)
  • insert phone number
  • insert org link to contact
  • show entry (for editing) Contacts are cached for optimal responsiveness with large address books. Contacts are automatically reloaded when the contacts file changes on disk. A reload can be forced with a prefix argument, e.g., ~C-u M-x helm-org-contacts~ or ~C-u~ followed by whatever key binding is used to invoke ~helm-org-contacts~.

** Combine with ~helm-mu-contacts~ [[https://github.com/emacs-helm/helm-mu][helm-mu-contacts]] lists email addresses extracted from mailboxes (via the Maildir indexer [[https://github.com/djcb/mu][mu]]). Helm-mu-contacts is not a general contacts manager and for large mailboxes it tends to show a lot of false positives, e.g., outdated email addresses. However, helm-mu-contacts and helm-org-contacts can be usufully combined into one helm search via the following code:

#+BEGIN_SRC elisp ;; Combine mu contacts with org contacts: (defun helm-contacts (&optional arg) (interactive "P") (when arg (setq helm-org-contacts-cache nil)) (helm :sources '(helm-source-org-contacts helm-source-mu-contacts) :full-frame t :candidate-number-limit 500)) #+END_SRC

This way we get clean contact data from our address books and we can fall back to email addresses extracted from our mailboxes when the person in question is missing in the address book.