Browse Source

org-contacts: check that completion-at-point-functions is bound

Julien Danjou 8 years ago
parent
commit
ea96f4cda6
1 changed files with 6 additions and 5 deletions
  1. 6 5
      contrib/lisp/org-contacts.el

+ 6 - 5
contrib/lisp/org-contacts.el

@@ -224,11 +224,6 @@ If both match values are nil, return all contacts."
         (when (mail-abbrev-in-expansion-header-p)
           (org-contacts-complete-name))))
 
-(add-hook 'message-mode-hook
-          (lambda ()
-            (add-to-list 'completion-at-point-functions
-                         'org-contacts-message-complete-function)))
-
 (defun org-contacts-gnus-get-name-email ()
   "Get name and email address from Gnus message."
   (gnus-with-article-headers
@@ -403,6 +398,12 @@ 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))
 
+(when (boundp 'completion-at-point-functions)
+  (add-hook 'message-mode-hook
+	    (lambda ()
+	      (add-to-list 'completion-at-point-functions
+			   'org-contacts-message-complete-function))))
+
 (defun org-contacts-wl-get-from-header-content ()
   "Retrieve the content of the `From' header of an email.
 Works from wl-summary-mode and mime-view-mode - that is while viewing email.