Skip to content

Instantly share code, notes, and snippets.

@xmaillard
Forked from unhammer/fastmail-sms.el
Created July 1, 2014 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmaillard/7fff13fdda829d41c032 to your computer and use it in GitHub Desktop.
Save xmaillard/7fff13fdda829d41c032 to your computer and use it in GitHub Desktop.
(defvar bbdb-smsable-phones-label '("Mobil") ; TODO: make it a list?
"The member of `bbdb-phone-label-list' that can receive sms-es.")
(defun bbdb-send-sms (record)
;; TODO: no signature, how? gnus-posting-styles possible?
(interactive (list (bbdb-current-record)))
(let* ((phones (bbdb-record-phone record))
(cellphone (replace-regexp-in-string
"[ -]" ""
(catch 'found
(mapc (lambda (p)
(when (member (aref p 0) bbdb-smsable-phones-label)
(throw 'found (aref p 1))))
phones)))))
(if cellphone
(if (string-match "^\\+\\([0-9]+\\)$" cellphone)
(progn
(bbdb-compose-mail (concat (bbdb-record-name record)
" <"
(match-string 1 cellphone)
"@sms.messagingengine.com"
">")
" ")
(when (search-forward "--text follows this line--\n")
(delete-region (point) (point-max))))
(message "Malformed cellphone number: \"%s\"\nIt should look like \"+123456789\""
cellphone))
(message "No field from %s found!" bbdb-smsable-phones-label))))
(define-key bbdb-mode-map (kbd "M") 'bbdb-send-sms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment