emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/org-contacts-rebased 9c27250 078/118: contrib/lisp/org-co


From: Stefan Monnier
Subject: [elpa] scratch/org-contacts-rebased 9c27250 078/118: contrib/lisp/org-contacts.el: Allow the user to customize interactively the vcard export
Date: Fri, 12 Nov 2021 15:37:08 -0500 (EST)

branch: scratch/org-contacts-rebased
commit 9c2725077ec62ee02dab1413d48679aae57e82ce
Author: Grégoire Jadi <gregoire.jadi@gmail.com>
Commit: Grégoire Jadi <gregoire.jadi@gmail.com>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]