From: Feng Shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: phone links...
Date: Sat, 13 Apr 2013 22:43:12 +0800 [thread overview]
Message-ID: <87vc7qv6db.fsf@news.tumashu-localhost.org> (raw)
In-Reply-To: <87d2tya59e.fsf@news.tumashu-localhost.org> (Feng Shu's message of "Sat, 13 Apr 2013 22:12:45 +0800")
[-- Attachment #1: Type: text/plain, Size: 50 bytes --]
[update diff] make output format more beautiful
[-- Attachment #2: 0001-org-contacts.el-export-contacts-to-outline-format.patch --]
[-- Type: text/x-diff, Size: 4655 bytes --]
From 500694de70f14095acc765875182d65feab7ef85 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
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 个文件被修改,插入 72 行(+)
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)
+(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)))))
+(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-birthday-property properties))))
+ (addr (cdr (assoc-string org-contacts-address-property properties)))
+ (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-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:" (car 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 phones-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-buffer)
+ "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."
--
1.7.10.4
[-- Attachment #3: Type: text/plain, Size: 6 bytes --]
--
next prev parent reply other threads:[~2013-04-14 7:33 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 23:23 phone links Robert Goldman
2013-03-30 9:12 ` Karl Voit
2013-04-01 13:30 ` Robert Goldman
2013-04-03 14:52 ` Michael Strey
2013-04-03 15:05 ` Robert Goldman
2013-04-04 8:26 ` Michael Strey
2013-04-04 13:55 ` Michael Strey
2013-04-04 12:15 ` Bastien
2013-04-04 20:38 ` Simon Thum
2013-04-05 3:04 ` Robert P. Goldman
2013-04-05 6:42 ` Bastien
2013-04-06 12:05 ` Simon Thum
2013-04-06 12:10 ` Simon Thum
2013-04-06 20:58 ` Bastien
2013-04-05 2:38 ` Robert P. Goldman
2013-04-08 10:38 ` Michael Strey
2013-04-08 12:47 ` Robert Goldman
2013-04-08 14:07 ` Michael Strey
2013-04-08 14:44 ` Robert Goldman
2013-04-09 7:31 ` Michael Strey
2013-04-09 12:19 ` Robert Goldman
2013-04-09 14:40 ` Michael Strey
2013-04-13 14:12 ` Feng Shu
2013-04-13 14:43 ` Feng Shu [this message]
2013-04-14 8:38 ` Bastien
2013-04-14 14:31 ` Feng Shu
2013-04-15 15:39 ` Bastien
2013-04-15 23:37 ` Feng Shu
2013-04-16 21:11 ` Daimrod
2013-04-17 3:55 ` Feng Shu
2013-04-17 6:10 ` Daimrod
2013-04-14 20:49 ` Michael Strey
2013-04-16 22:22 ` Daimrod
2013-04-17 10:28 ` Michael Strey
2013-04-20 15:59 ` Daimrod
2013-04-26 12:48 ` [Patch] " Michael Strey
2013-04-30 9:09 ` Daimrod
2013-05-31 0:04 ` Daimrod
2013-04-09 9:57 ` Feng Shu
2013-04-10 14:17 ` Michael Strey
2013-04-11 10:27 ` Michael Strey
2013-04-16 7:57 ` Eric S Fraga
2013-04-16 12:25 ` Robert P. Goldman
2013-04-17 8:14 ` Michael Strey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vc7qv6db.fsf@news.tumashu-localhost.org \
--to=tumashu@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.