summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Strey <mstrey@strey.biz>2013-04-26 13:57:46 +0200
committerGrégoire Jadi <gregoire.jadi@gmail.com>2013-04-30 11:07:53 +0200
commitd109e4d83c47aa27ddebf33403203ce0bca93c12 (patch)
tree4bbad84a39a81ddc534fdbce790f7e31c1fda5fc
parent7a879ecb18795423b7337a5560e42ff0d2fc21b9 (diff)
downloadorg-mode-d109e4d83c47aa27ddebf33403203ce0bca93c12.tar.gz
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'.
-rw-r--r--contrib/lisp/org-contacts.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index eb3fc09..84ebc9d 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/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 "")