From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: phone links... Date: Sat, 13 Apr 2013 22:43:12 +0800 Message-ID: <87vc7qv6db.fsf@news.tumashu-localhost.org> References: <5156228C.4010400@sift.info> <871uaq7aqy.fsf@bzg.ath.cx> <515E3938.2030202@sift.info> <20130408103832.GE659@strey.biz> <5162BC78.7010509@sift.info> <20130408140731.GF659@strey.biz> <5162D7BC.3020303@sift.info> <20130409073140.GJ659@strey.biz> <87d2tya59e.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:35565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URHQp-0007eJ-FQ for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 03:33:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URHQo-0001wp-6a for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 03:32:59 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:57792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URHQn-0001wh-Sx for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 03:32:58 -0400 Received: by mail-pa0-f50.google.com with SMTP id bg2so2087134pad.37 for ; Sun, 14 Apr 2013 00:32:56 -0700 (PDT) Received: from feng by news.tumashu-localhost.org with local (Exim 4.80) (envelope-from ) id 1UR1fc-0007Cp-DN for emacs-orgmode@gnu.org; Sat, 13 Apr 2013 22:43:12 +0800 In-Reply-To: <87d2tya59e.fsf@news.tumashu-localhost.org> (Feng Shu's message of "Sat, 13 Apr 2013 22:12:45 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain [update diff] make output format more beautiful --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-org-contacts.el-export-contacts-to-outline-format.patch Content-Transfer-Encoding: quoted-printable >From 500694de70f14095acc765875182d65feab7ef85 Mon Sep 17 00:00:00 2001 From: Feng Shu Date: Sat, 13 Apr 2013 22:00:03 +0800 Subject: [PATCH] org-contacts.el, export contacts to outline-format * contrib/lisp/org-contacts.el (org-contacts-outline-file): new variable (org-contacts-outline-format): new function which formats a contact to outline-format (org-contacts-export-as-outline-format): new function, formats all contacts to outline-format * NAME :PROPERTIES: :EMAIL: n1@n.com n2@n.com :PHONE: 123456789 :END: export as: * NAME ** EMAIL: [[mailto:n1@n.com]] ** EMAIL: [[mailto:n2@n.com]] ** PHONE: [[tel:123456789]] ** PHONE: [[tel:123456789]] --- contrib/lisp/org-contacts.el | 72 ++++++++++++++++++++++++++++++++++++++= ++++ 1 =E4=B8=AA=E6=96=87=E4=BB=B6=E8=A2=AB=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=8F=92= =E5=85=A5 72 =E8=A1=8C(+) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index a3c4aed..c65ebf0 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -156,6 +156,12 @@ This overrides `org-email-link-description-format' if = set." :group 'org-contacts :type 'file) =20 +(defcustom org-contacts-outline-file "contacts-outline.org" + "Default file for outline-format export." + :group 'org-contacts + :type 'file) + + (defcustom org-contacts-enable-completion t "Enable or not the completion in `message-mode' with `org-contacts'." :group 'org-contacts @@ -896,6 +902,72 @@ is created and the VCard is written into that buffer." (current-buffer) (progn (save-buffer) (kill-buffer))))) =20 +(defun org-contacts-outline-format (contact) + "Formats CONTACT in outline format." + (let* ((properties (caddr contact)) + (name (org-contacts-vcard-escape (car contact))) + (n (org-contacts-vcard-encode-name name)) + (email (cdr (assoc-string org-contacts-email-property properties))) + (alias (cdr (assoc-string org-contacts-alias-property properties))) + (tel (cdr (assoc-string org-contacts-tel-property properties))) + (note (cdr (assoc-string org-contacts-note-property properties))) + (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthda= y-property properties)))) + (addr (cdr (assoc-string org-contacts-address-property properties))) + (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nicknam= e-property properties)))) + (head (format "* %s\n" name))) + (concat head + (when alias + (format "** ALIAS: %s\n" alias)) + (when email (progn + (setq emails-list (split-string email "[,;: ]+")) + (setq result "") + (while emails-list + (setq result (concat result "** EMAIL: " (concat "[[mailto:" (ca= r emails-list) "]]") "\n")) + (setq emails-list (cdr emails-list))) + result)) + (when addr + (format "** ADRESS: " (replace-regexp-in-string "\\, ?" ";" addr))) + (when tel (progn + (setq phones-list (split-string tel "[,;: ]+")) + (setq result "") + (while phones-list + (setq result (concat result "** TEL: " (concat "[[tel:" (car pho= nes-list) "]]" ) "\n")) + (setq phones-list (cdr phones-list))) + result)) + (when bday + (let ((cal-bday (calendar-gregorian-from-absolute (org-time-string-= to-absolute bday)))) + (format "** BDAY:%04d-%02d-%02d\n" + (calendar-extract-year cal-bday) + (calendar-extract-month cal-bday) + (calendar-extract-day cal-bday)))) + (when nick (format "** NICKNAME: %s\n" nick)) + (when note (format "** NOTE: %s\n" note))))) + + + +(defun org-contacts-export-as-outline-format (&optional name file to-buffe= r) + "Export all contacts matching NAME as outline format +If TO-BUFFER is nil, the content is written to FILE or +`org-contacts-outline-file'. If TO-BUFFER is non-nil, the buffer +is created and the outlines is written into that buffer." + (interactive) ; TODO ask for name? + (let* ((filename (or file org-contacts-outline-file)) + (buffer (if to-buffer + (get-buffer-create to-buffer) + (find-file-noselect filename)))) + (message "Exporting...") + (set-buffer buffer) + (let ((inhibit-read-only t)) (erase-buffer)) + (fundamental-mode) + (when (fboundp 'set-buffer-file-coding-system) + (set-buffer-file-coding-system coding-system-for-write)) + (loop for contact in (org-contacts-filter name) + do (insert (org-contacts-outline-format contact))) + (if to-buffer + (current-buffer) + (progn (save-buffer) (kill-buffer))))) + + (defun org-contacts-show-map (&optional name) "Show contacts on a map. Requires google-maps-el." --=20 1.7.10.4 --=-=-= Content-Type: text/plain -- --=-=-=--