From 9bd8101c56e72ae32421cbd27a3abebee3718fb6 Mon Sep 17 00:00:00 2001 From: Michael Strey Date: Fri, 26 Apr 2013 13:57:46 +0200 Subject: [PATCH] contrib/lisp/org-contacts: Introduce the constant `org-contacts-property-values-separators' * contrib/lisp/org-contacts.el (org-contacts-property-values-separators): Definition of a new constant that will be used as default value of separators for `org-contacts-split-property'. * contrib/lisp/org-contacts.el (org-contacts-vcard-format): We are now using the default separator in general. * contrib/lisp/org-contacts.el (org-contacts-show-map): Line break corrected. * contrib/lisp/org-contacts.el (org-contacts-split-property): Correct the comment describing the function. Application of the newly defined constant `org-contacts-property-values-separators'. --- org-contacts.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/org-contacts.el b/org-contacts.el index eb3fc09..84ebc9d 100644 --- a/org-contacts.el +++ b/org-contacts.el @@ -174,6 +174,11 @@ This overrides `org-email-link-description-format' if set." (declare-function std11-narrow-to-header "ext:std11") (declare-function std11-fetch-field "ext:std11") +(defconst org-contacts-property-values-separators "[,; \f\t\n\r\v]+" + "The default value of separators for `org-contacts-split-property'. + +A regexp matching strings of whitespace, `,' and `;'.") + (defvar org-contacts-keymap (let ((map (make-sparse-keymap))) (define-key map "M" 'org-contacts-view-send-email) @@ -850,7 +855,7 @@ to do our best." (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name))) (concat head (when email (progn - (setq emails-list (org-contacts-split-property email "[,; ]+")) + (setq emails-list (org-contacts-split-property email)) (setq result "") (while emails-list (setq result (concat result "EMAIL:" (org-contacts-strip-link (car emails-list)) "\n")) @@ -859,7 +864,7 @@ to do our best." (when addr (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr))) (when tel (progn - (setq phones-list (org-contacts-split-property tel "[,; ]+")) + (setq phones-list (org-contacts-split-property tel)) (setq result "") (while phones-list (setq result (concat result "TEL:" (org-contacts-strip-link (car phones-list)) "\n")) @@ -912,7 +917,8 @@ Requires google-maps-el." collect (cons (list addr) (list :label (string-to-char (car contact))))))) (defun org-contacts-strip-link (link) - "Remove brackets, description, link type and colon from an org link string and return the pure link target." + "Remove brackets, description, link type and colon from an org +link string and return the pure link target." (let (startpos colonpos endpos) (setq startpos (string-match (regexp-opt '("[[tel:" "[[mailto:")) link)) (if startpos @@ -935,16 +941,16 @@ splitting points. The substrings matching SEPARATORS are removed, and the substrings between the splitting points are collected as a list, which is returned. -If SEPARATORS is non-nil, it should be a regular expression matching text -which separates, but is not part of, the substrings. If nil it defaults to -`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and -OMIT-NULLS is forced to t. +If SEPARATORS is non-nil, it should be a regular expression +matching text which separates, but is not part of, the +substrings. If nil it defaults to `org-contacts-property-values-separators', +normally \"[,; \f\t\n\r\v]+\", and OMIT-NULLS is forced to t. If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so that for the default value of SEPARATORS leading and trailing whitespace are effectively trimmed). If nil, all zero-length substrings are retained." (let* ((keep-nulls (or nil omit-nulls)) - (rexp (or separators split-string-default-separators)) + (rexp (or separators org-contacts-property-values-separators)) (inputlist (split-string string rexp keep-nulls)) (linkstring "") (bufferstring "")