Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; An Org-mode capture template for scheduling a phone call to a BBDB contact.
;; Shortcut key: c
;; Target location: Under headline "Incoming" in file "~/org/ToDo.org".
;; Default tags: @phone
;; The function `ph/capture-bbdb' (see below) handles BBDB contacts with either a name or only an organization.
;;
;; To use this capture template, first mark the whole of the specific phone number you
;; want within the contact record in the *BBDB* buffer, then hit C-c t c.
;;
;; Prompts for:
;; - Any extra tags (the usual tags selection dialog).
;; - Effort (a duration in h:mm or :mm format), meaning the expected clocked-in time.
;; Then leaves point where you should briefly describe the purpose of the call.
;;
;; Given a BBDB record like this:
;;
;; John Doe - ???
;; Home: 555-555-5555
;; Cell: 555-555-5556
;;
;; With the home number marked, creates an entry like this:
;;
;; * Incoming
;; ** TODO Call [[bbdd:John Doe][John Doe]] on [[tel:555-555-5555][555-555-5555]] to plan picnic :fun:@phone:
;; SCHEDULED: <2015-12-07 Mon>
;; :PROPERTIES:
;; :Effort: 10m
;; :END:
;; Created: [2015-12-07 Mon]
;;
;; The task headline renders this way, of course, with underscores indicating underlining:
;;
;; ** TODO Call _John Doe_ on _555-555-5555_ to...
;;
;; Given a BBDB record like this:
;;
;; ??? - Johdone Inc
;; Main: 555-555-5555
;;
;; With the main number marked, creates a similar entry, with a task headline like this:
;;
;; * Incoming
;; ** TODO Call [[bbdb:Johdone Inc][Johdone Inc]] on [[tel:555-555-5555][555-555-5555]] to order widgets :buy:work:@phone:
;; ...
;;
;; See https://github.com/mistrey/org-dial for one way to use the `tel:` URL scheme.
;;
;; The following form is intended to be one element in the list `org-capture-templates'
("c" "Capture a phone call to make" entry
(file+headline "~/org/ToDo.org" "Incoming")
"* TODO Call %(ph/capture-bbdb \"%a\" \"%:company\") on [[tel:%i][%i]] to %? %^G:@phone:
SCHEDULED: %t
%^{Effort|0:10}p
Created: %U" :prepend t :jump-to-captured t)
;; The following form is intended to be one element in the list `org-capture-templates-contexts'
("c" "" ((in-mode . "bbdb-mode")))
;; Here's the function:
(defun ph/capture-bbdb (bbdb-contact-name bbdb-contact-company)
"Return an Org hyperlink for either BBDB-CONTACT-NAME or BBDB-CONTACT-COMPANY.
Favor BBDB-CONTACT-NAME. BBDB-CONTACT-NAME is already formatted as an Org hyperlink,
but BBDB-CONTACT-COMPANY is just a plain company name."
(if (string-match-p "^\\[\\[bbdb:\\]" bbdb-contact-name)
;; Blank name, so use company
(format "[[bbdb:%s][%s]]"
bbdb-contact-company
bbdb-contact-company)
;; already link-formatted
bbdb-contact-name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.