From c32dbab1147401b637f2d5097e20a97adb7dc307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= Date: Sat, 26 Jul 2014 13:15:30 +0900 Subject: [PATCH] contrib/lisp/org-contacts.el: Allow the user to customize interactively the vcard export * contrib/lisp/org-contacts.el (org-contacts-export-as-vcard): Wrap `org-contacts-export-as-vcard-internal' to prompt for the parameters when called interactively. (org-contacts-export-as-vcard-internal): The old function `org-contacts-export-as-vcard'. Thanks to Esben Stien for the suggestion. --- org-contacts.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/org-contacts.el b/org-contacts.el index 583da4a..88aef9d 100644 --- a/org-contacts.el +++ b/org-contacts.el @@ -1016,11 +1016,39 @@ to do our best." "END:VCARD\n\n"))) (defun org-contacts-export-as-vcard (&optional name file to-buffer) + "Export org contacts to V-Card 3.0. + +By default, all contacts are exported to `org-contacts-vcard-file'. + +When NAME is \\[universal-argument], prompts for a contact name. + +When NAME is \\[universal-argument] \\[universal-argument], +prompts for a contact name and a file name where to export. + +When NAME is \\[universal-argument] \\[universal-argument] +\\[universal-argument], prompts for a contact name and a buffer where to export. + +If the function is not called interactively, all parameters are +passed to `org-contacts-export-as-vcard-internal'." + (interactive "P") + (when (called-interactively-p 'any) + (cl-psetf name + (when name + (read-string "Contact name: " + (first (org-contacts-at-point)))) + file + (when (equal name '(16)) + (read-file-name "File: " nil org-contacts-vcard-file)) + to-buffer + (when (equal name '(64)) + (read-buffer "Buffer: ")))) + (org-contacts-export-as-vcard-internal name file to-buffer)) + +(defun org-contacts-export-as-vcard-internal (&optional name file to-buffer) "Export all contacts matching NAME as VCard 3.0. If TO-BUFFER is nil, the content is written to FILE or `org-contacts-vcard-file'. If TO-BUFFER is non-nil, the buffer is created and the VCard is written into that buffer." - (interactive) ; TODO ask for name? (let* ((filename (or file org-contacts-vcard-file)) (buffer (if to-buffer (get-buffer-create to-buffer)