diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2012-07-05 09:50:34 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2012-07-05 09:50:34 +0200 |
commit | 53237dbc9ea6490f0234ede2cd5679324ca93276 (patch) | |
tree | e467974f6f7e597fd0fb354b532582890e0478f3 /helm-bbdb.el | |
parent | 37d0dd40a8b3af75d736697ca88daf2f171efbac (diff) |
* helm-bbdb.el: Issue #78 Give more choice when creating contacts.
(helm-read-repeat-string,
helm-bbdb-phone-read-string): new
(helm-c-bbdb-create-contact): Use repeat prompts.
Diffstat (limited to 'helm-bbdb.el')
-rw-r--r-- | helm-bbdb.el | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/helm-bbdb.el b/helm-bbdb.el index b40bfbf6..005cf483 100644 --- a/helm-bbdb.el +++ b/helm-bbdb.el @@ -41,19 +41,39 @@ is \"Firstname Lastname\"." (concat (aref bbdb-record 0) " " (aref bbdb-record 1)))) (bbdb-records))) +(defun helm-bbdb-phone-read-string (prompt &rest args) + "Return a list of vectors composed of two string for each elm of SEQ. +See docstring of `bbdb-create-internal' for more info on phone entries." + (loop with elm for i in args + when (string= elm "") return (remove "" lis) + for str = (symbol-name i) collect + (vector str (setq elm (read-string (concat prompt "(" str "): ")))) + into lis + finally return (remove "" lis))) + +;; TODO move this to helm-utils when finish +(defun helm-read-repeat-string (prompt) + "Prompt as many time PROMPT is not empty." + (loop with elm while (not (string= elm "")) + collect (setq elm (read-string prompt)) into lis + finally return (remove "" lis))) + (defun helm-c-bbdb-create-contact (actions candidate) "Action transformer that returns only an entry to add the current `helm-pattern' as new contact. All other actions are removed." (if (string= candidate "*Add to contacts*") - '(("Add to contacts" . (lambda (actions) - (bbdb-create-internal - (read-from-minibuffer "Name: " helm-c-bbdb-name) - (read-from-minibuffer "Company: ") - (read-from-minibuffer "Email: ") - nil - nil - (read-from-minibuffer "Note: "))))) + '(("Add to contacts" + . (lambda (actions) + (bbdb-create-internal + (read-from-minibuffer "Name: " helm-c-bbdb-name) + (read-from-minibuffer "Company: ") + (helm-read-repeat-string "Email: ") + ;[\"location\" (\"line1\" \"line2\" ... ) \"City\" \"State\" \"Zip\" \"Country\"]. + nil + (helm-bbdb-phone-read-string + "Phone" 'home 'office 'mobile 'other) + (read-from-minibuffer "Note: "))))) actions)) (defun helm-c-bbdb-get-record (candidate) |