summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Jadi <gregoire.jadi@gmail.com>2013-05-08 22:31:16 (GMT)
committer Grégoire Jadi <gregoire.jadi@gmail.com>2013-05-08 22:37:53 (GMT)
commitc82b34adb611e2f5652d2aa201276a6862d7ec4d (patch)
tree9b9b4f8c258480d90824d9c67cb7ce52b5eaec6b
parent800ea286c48692f2438550e7eecbc915c1999dc9 (diff)
downloadorg-mode-c82b34adb611e2f5652d2aa201276a6862d7ec4d.zip
org-mode-c82b34adb611e2f5652d2aa201276a6862d7ec4d.tar.gz
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.
-rw-r--r--contrib/lisp/org-contacts.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index c84f1f2..d81d43b 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -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-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
(boundp 'completion-at-point-functions))
- (add-hook 'message-mode-hook
- (lambda ()
- (add-to-list 'completion-at-point-functions
- 'org-contacts-message-complete-function))))
+ (add-hook 'message-mode-hook 'org-contacts-setup-completion-at-point))
(defun org-contacts-wl-get-from-header-content ()
"Retrieve the content of the `From' header of an email.