contrib/lisp/org-contacts.el: Permit to unload properly `org-contacts'

* contrib/lisp/org-contacts.el (org-contacts-setup-completion-at-point):
Setup `completion-at-point-functions' in a dedicated function so it's
easier to add and to remove it from `message-mode-hook'.
(org-contacts-unload-hook): This function removes all hooks added while
loading `org-contacts' in order to respect Emacs coding conventions.
This commit is contained in:
Grégoire Jadi 2013-05-09 00:31:16 +02:00
parent 43d6571612
commit 271ec25b43

View file

@ -702,12 +702,18 @@ This adds `org-contacts-gnus-check-mail-address' and
(add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-check-mail-address) (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-check-mail-address)
(add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-store-last-mail)) (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-store-last-mail))
(defun org-contacts-setup-completion-at-point ()
"Add `org-contacts-message-complete-function' as a new function
to complete the thing at point."
(add-to-list 'completion-at-point-functions
'org-contacts-message-complete-function))
(defun org-contacts-unload-hook ()
(remove-hook 'message-mode-hook 'org-contacts-setup-completion-at-point))
(when (and org-contacts-enable-completion (when (and org-contacts-enable-completion
(boundp 'completion-at-point-functions)) (boundp 'completion-at-point-functions))
(add-hook 'message-mode-hook (add-hook 'message-mode-hook 'org-contacts-setup-completion-at-point))
(lambda ()
(add-to-list 'completion-at-point-functions
'org-contacts-message-complete-function))))
(defun org-contacts-wl-get-from-header-content () (defun org-contacts-wl-get-from-header-content ()
"Retrieve the content of the `From' header of an email. "Retrieve the content of the `From' header of an email.