pinoaffe / org-vcard

Export and import vCards from within GNU Emacs' Org mode.
61 stars 7 forks source link

Imported contacts can not be exported to vcard format. #43

Open hwiorn opened 5 months ago

hwiorn commented 5 months ago

I was able to import contacts.vcf file into contacts.org from google contacts. But I can't export to vcard from the contacts.org I think org-vcard needs to test converting back and forth.

Below is a simple example snippet converted to vcf(for ios) from google contacts. Just below a snippet makes an error.

* #G9
:PROPERTIES:
:VERSION: 3.0
:N: #G9;;;;
:CELL: 1111-2222
:CATEGORIES: myContacts
:END:

M-x org-vcard-export choose source: buffer and destination: buffer (or file). Then, I got below error.

Debugger entered--Lisp error: (wrong-type-argument stringp [org-element-deferred org-element--headline-parse-title (nil) nil])
  string-match("\\\\" [org-element-deferred org-element--headline-parse-title (nil) nil] 0)
  replace-regexp-in-string("\\\\" "\\\\" [org-element-deferred org-element--headline-parse-title (nil) nil] nil t)
  org-vcard--escape-value-string(("," ";" "\\") [org-element-deferred org-element--headline-parse-title (nil) nil])
  org-vcard--export-line("FN" [org-element-deferred org-element--headline-parse-title (nil) nil])
  (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get (nth 1 (org-element-headline-parser (line-end-position))) :raw-value)) content (org-vcard--export-line "END" "VCARD"))
  (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get (nth 1 (org-element-headline-parser (line-end-position))) :raw-value)) content (org-vcard--export-line "END" "VCARD")))
  (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or (string= "3.0" org-vcard-active-version) (string= "2.1" org-vcard-active-version)) (not (member "N" (mapcar 'car properties)))) (setq content (concat content (org-vcard--export-line "N" "")))) (let ((tail properties)) (while tail (let ((p (car tail))) (if (and (not (string= "VERSION" ...)) (assoc (car p) flat-style-properties)) (setq content (concat content (org-vcard--export-line ... ...)))) (setq tail (cdr tail))))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get (nth 1 (org-element-headline-parser (line-end-position))) :raw-value)) content (org-vcard--export-line "END" "VCARD"))))
  (if in-contact-entry (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or (string= "3.0" org-vcard-active-version) (string= "2.1" org-vcard-active-version)) (not (member "N" (mapcar 'car properties)))) (setq content (concat content (org-vcard--export-line "N" "")))) (let ((tail properties)) (while tail (let ((p (car tail))) (if (and (not ...) (assoc ... flat-style-properties)) (setq content (concat content ...))) (setq tail (cdr tail))))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get (nth 1 (org-element-headline-parser ...)) :raw-value)) content (org-vcard--export-line "END" "VCARD")))))
  (let ((properties (org-entry-properties)) (in-contact-entry nil) (flat-style-properties (or (car (cdr (assoc org-vcard-active-version (car ...)))) (error "No mapping available for specified vCard version"))) (content (encode-coding-string "" encoding))) (let ((tail properties)) (while tail (let ((p (car tail))) (if (assoc (car p) flat-style-properties) (setq in-contact-entry t)) (setq tail (cdr tail))))) (if in-contact-entry (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or (string= "3.0" org-vcard-active-version) (string= "2.1" org-vcard-active-version)) (not (member "N" (mapcar ... properties)))) (setq content (concat content (org-vcard--export-line "N" "")))) (let ((tail properties)) (while tail (let ((p ...)) (if (and ... ...) (setq content ...)) (setq tail (cdr tail))))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get (nth 1 ...) :raw-value)) content (org-vcard--export-line "END" "VCARD"))))))
  (lambda nil (let ((properties (org-entry-properties)) (in-contact-entry nil) (flat-style-properties (or (car (cdr (assoc org-vcard-active-version ...))) (error "No mapping available for specified vCard version"))) (content (encode-coding-string "" encoding))) (let ((tail properties)) (while tail (let ((p (car tail))) (if (assoc (car p) flat-style-properties) (setq in-contact-entry t)) (setq tail (cdr tail))))) (if in-contact-entry (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or (string= "3.0" org-vcard-active-version) (string= "2.1" org-vcard-active-version)) (not (member "N" ...))) (setq content (concat content (org-vcard--export-line "N" "")))) (let ((tail properties)) (while tail (let (...) (if ... ...) (setq tail ...)))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading (plist-get ... :raw-value)) content (org-vcard--export-line "END" "VCARD")))))))()
  #f(compiled-function (el) #<bytecode 0x1605c7e9a3ac51a6>)((headline (:standard-properties [1 1 7 93 93 0 (:title) first-section element t nil nil nil 1 #<buffer contacts.org> nil nil (org-data (:standard-properties [1 1 1 93 93 0 nil org-data nil t nil 3 93 nil #<buffer contacts.org> nil nil nil] :path "/home/timlee/org/contacts.org" :CATEGORY "contacts"))] :pre-blank 0 :raw-value [org-element-deferred org-element--headline-raw-value (2 5) nil] :title [org-element-deferred org-element-property-2 (:raw-value) nil] :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :footnote-section-p [org-element-deferred org-element--headline-footnote-section-p nil nil] :archivedp [org-element-deferred org-element--headline-archivedp nil nil] :commentedp nil :VERSION [org-element-deferred org-element--substring (29 32) nil] :N [org-element-deferred org-element--substring (37 44) nil] :CELL [org-element-deferred org-element--substring (52 61) nil] :CATEGORIES [org-element-deferred org-element--substring (75 85) nil])))
  org-element-cache-map(#f(compiled-function (el) #<bytecode 0x1605c7e9a3ac51a6>) :next-re "^\\*+ " :fail-re "^\\*+ " :narrow t)
  org-scan-tags((lambda nil (let ((properties (org-entry-properties)) (in-contact-entry nil) (flat-style-properties (or (car (cdr ...)) (error "No mapping available for specified vCard version"))) (content (encode-coding-string "" encoding))) (let ((tail properties)) (while tail (let ((p ...)) (if (assoc ... flat-style-properties) (setq in-contact-entry t)) (setq tail (cdr tail))))) (if in-contact-entry (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or ... ...) (not ...)) (setq content (concat content ...))) (let ((tail properties)) (while tail (let ... ... ...))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading ...) content (org-vcard--export-line "END" "VCARD"))))))) t nil nil)
  org-map-entries((lambda nil (let ((properties (org-entry-properties)) (in-contact-entry nil) (flat-style-properties (or (car (cdr ...)) (error "No mapping available for specified vCard version"))) (content (encode-coding-string "" encoding))) (let ((tail properties)) (while tail (let ((p ...)) (if (assoc ... flat-style-properties) (setq in-contact-entry t)) (setq tail (cdr tail))))) (if in-contact-entry (progn (if (and (string= "FN" org-vcard-default-property-for-heading) (or ... ...) (not ...)) (setq content (concat content ...))) (let ((tail properties)) (while tail (let ... ... ...))) (setq output (concat output (org-vcard--export-line "BEGIN" "VCARD") (org-vcard--export-line "VERSION" org-vcard-active-version) (org-vcard--export-line org-vcard-default-property-for-heading ...) content (org-vcard--export-line "END" "VCARD"))))))) nil nil)
  (let* ((scope (cond ((string= "buffer" source) nil) ((string= "region" source) 'region) ((string= "subtree" source) 'tree) (t (error "Invalid source type")))) (encoding (cond ((string= "4.0" org-vcard-active-version) 'utf-8) ((string= "3.0" org-vcard-active-version) 'utf-8) ((string= "2.1" org-vcard-active-version) 'us-ascii))) (output (encode-coding-string "" encoding))) (org-mode) (org-map-entries #'(lambda nil (let ((properties (org-entry-properties)) (in-contact-entry nil) (flat-style-properties (or ... ...)) (content (encode-coding-string "" encoding))) (let ((tail properties)) (while tail (let ... ... ...))) (if in-contact-entry (progn (if ... ...) (let ... ...) (setq output ...))))) nil scope) (org-vcard--transfer-write 'export output destination))
  org-vcard-export-from-flat("buffer" "buffer")
  org-vcard-transfer-helper("buffer" "buffer" "flat" "en" "4.0" export)
  org-vcard-export(nil)
  funcall-interactively(org-vcard-export nil)
  call-interactively(org-vcard-export record nil)
  command-execute(org-vcard-export record)
  execute-extended-command(nil "org-vcard-export" nil)
  funcall-interactively(execute-extended-command nil "org-vcard-export" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)