Created
June 25, 2013 13:54
-
-
Save unhammer/5858601 to your computer and use it in GitHub Desktop.
send sms using fastmail from emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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