org-contacts: fix errors when Gnus or ERC are not loaded

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Lomax Escarmant 2011-08-06 11:45:26 +02:00 committed by Julien Danjou
parent 7cae69fce6
commit 5f1806a8d0

View file

@ -239,9 +239,10 @@ If both match values are nil, return all contacts."
(defun org-contacts-gnus-get-name-email () (defun org-contacts-gnus-get-name-email ()
"Get name and email address from Gnus message." "Get name and email address from Gnus message."
(gnus-with-article-headers (if (gnus-alive-p)
(mail-extract-address-components (gnus-with-article-headers
(or (mail-fetch-field "From") "")))) (mail-extract-address-components
(or (mail-fetch-field "From") "")))))
(defun org-contacts-gnus-article-from-get-marker () (defun org-contacts-gnus-article-from-get-marker ()
"Return a marker for a contact based on From." "Return a marker for a contact based on From."
@ -533,10 +534,11 @@ If ASK is set, ask for the email address even if there's only one address."
(defun erc-nicknames-list () (defun erc-nicknames-list ()
"Return all nicknames of all ERC buffers." "Return all nicknames of all ERC buffers."
(loop for buffer in (erc-buffer-list) (if (fboundp 'erc-buffer-list)
nconc (with-current-buffer buffer (loop for buffer in (erc-buffer-list)
(loop for user-entry in (mapcar 'car (erc-get-channel-user-list)) nconc (with-current-buffer buffer
collect (elt user-entry 1))))) (loop for user-entry in (mapcar 'car (erc-get-channel-user-list))
collect (elt user-entry 1))))))
(add-to-list 'org-property-set-functions-alist (add-to-list 'org-property-set-functions-alist
`(,org-contacts-nickname-property . org-contacts-completing-read-nickname)) `(,org-contacts-nickname-property . org-contacts-completing-read-nickname))