org-contacts.el: Fix or add docstrings

* org-contacts.el (org-contacts-db)
(org-contacts-try-completion-prefix)
(org-contacts-all-completions-prefix)
(org-contacts-make-collection-prefix)
(org-contacts-display-sort-function)
(org-contacts-icon-as-string, org-contacts-format-name)
(org-contacts-gnus-insinuate): Fix or add docstring.
This commit is contained in:
Bastien Guerry 2013-03-05 14:14:54 +01:00
parent 4b368d7709
commit 81129c4c07

View file

@ -171,7 +171,7 @@ This overrides `org-email-link-description-format' if set."
(org-contacts-files)))) (org-contacts-files))))
(defun org-contacts-db () (defun org-contacts-db ()
"Return the latest Org Contacts Database" "Return the latest Org Contacts Database."
(let* (todo-only (let* (todo-only
(contacts-matcher (contacts-matcher
(cdr (org-make-tags-matcher org-contacts-matcher))) (cdr (org-make-tags-matcher org-contacts-matcher)))
@ -221,9 +221,9 @@ If both match values are nil, return all contacts."
(complete-with-action action table string pred))))) (complete-with-action action table string pred)))))
(defun org-contacts-try-completion-prefix (to-match collection &optional predicate) (defun org-contacts-try-completion-prefix (to-match collection &optional predicate)
"Like `try-completion' but: "Custom implementation of `try-completion'.
- works only with list and alist; This version works only with list and alist and it looks at all
- looks at all prefixes rather than just the beginning of the string;" prefixes rather than just the beginning of the string."
(loop with regexp = (concat "\\b" (regexp-quote to-match)) (loop with regexp = (concat "\\b" (regexp-quote to-match))
with ret = nil with ret = nil
with ret-start = nil with ret-start = nil
@ -307,9 +307,9 @@ This function returns a list whose contains:
(+ new-start (- end1 start1))))) (+ new-start (- end1 start1)))))
(defun org-contacts-all-completions-prefix (to-match collection &optional predicate) (defun org-contacts-all-completions-prefix (to-match collection &optional predicate)
"Like `all-completions' but: "Custom version of `all-completions'.
- works only with list and alist; This version works only with list and alist and it looks at all
- looks at all prefixes rather than just the beginning of the string;" prefixes rather than just the beginning of the string."
(loop with regexp = (concat "\\b" (regexp-quote to-match)) (loop with regexp = (concat "\\b" (regexp-quote to-match))
for el in collection for el in collection
for string = (if (listp el) (car el) el) for string = (if (listp el) (car el) el)
@ -328,8 +328,7 @@ This function returns a list whose contains:
string))) string)))
(defun org-contacts-make-collection-prefix (collection) (defun org-contacts-make-collection-prefix (collection)
"Makes a collection function from COLLECTION which will match "Make a collection function from COLLECTION which will match on prefixes."
on prefixes."
(lexical-let ((collection collection)) (lexical-let ((collection collection))
(lambda (string predicate flag) (lambda (string predicate flag)
(cond ((eq flag nil) (cond ((eq flag nil)
@ -350,6 +349,7 @@ on prefixes."
))))) )))))
(defun org-contacts-display-sort-function (completions) (defun org-contacts-display-sort-function (completions)
"Sort function for contacts display."
(mapcar (lambda (string) (mapcar (lambda (string)
(loop with len = (1- (length string)) (loop with len = (1- (length string))
for i upfrom 0 to len for i upfrom 0 to len
@ -572,6 +572,7 @@ This function should be called from `gnus-article-prepare-hook'."
(org-set-property org-contacts-last-read-mail-property link))))))) (org-set-property org-contacts-last-read-mail-property link)))))))
(defun org-contacts-icon-as-string () (defun org-contacts-icon-as-string ()
"Return the contact icon as a string."
(let ((image (org-contacts-get-icon))) (let ((image (org-contacts-get-icon)))
(concat (concat
(propertize "-" 'display (propertize "-" 'display
@ -609,12 +610,12 @@ This function should be called from `gnus-article-prepare-hook'."
prompt (org-contacts-filter) predicate t initial-input hist def inherit-input-method)) prompt (org-contacts-filter) predicate t initial-input hist def inherit-input-method))
(defun org-contacts-format-name (name) (defun org-contacts-format-name (name)
"Trim any local formatting to get a bare name." "Trim any local formatting to get a bare NAME."
;; Remove radio targets characters ;; Remove radio targets characters
(replace-regexp-in-string org-radio-target-regexp "\\1" name)) (replace-regexp-in-string org-radio-target-regexp "\\1" name))
(defun org-contacts-format-email (name email) (defun org-contacts-format-email (name email)
"Format a mail address." "Format an EMAIL address corresponding to NAME."
(unless email (unless email
(error "`email' cannot be nul")) (error "`email' cannot be nul"))
(if name (if name
@ -869,3 +870,7 @@ Requires google-maps-el."
collect (cons (list addr) (list :label (string-to-char (car contact))))))) collect (cons (list addr) (list :label (string-to-char (car contact)))))))
(provide 'org-contacts) (provide 'org-contacts)
(provide 'org-contacts)
;;; org-contacts.el ends here