From 2952ee0a9a140b1fab3e1dfe465d4f55f1313fc3 Mon Sep 17 00:00:00 2001
From: David Maus <dmaus@dmaus.name>
Date: Sun, 29 Nov 2015 09:41:12 +0100
Subject: [PATCH] Prevent incidental creation of hook variables

* lisp/bbdb-mua.el (bbdb-mua-auto-update-init): Prevent incidental
  creation of hook variables.
---
 ChangeLog        | 5 +++++
 lisp/bbdb-mua.el | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 295c48d..e0e655d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-29  David Maus  <dmaus@dmaus.name>
+
+	* lisp/bbdb-mua.el (bbdb-mua-auto-update-init): Prevent incidental
+	creation of hook variables.
+
 2015-11-14  Roland Winkler  <winkler@gnu.org>
 	* lisp/bbdb.el (bbdb-auto-revert, bbdb-dedicated-window)
 	(bbdb-default-domain, bbdb-mua-pop-up)
diff --git a/lisp/bbdb-mua.el b/lisp/bbdb-mua.el
index 29cf223..6cda7a2 100644
--- a/lisp/bbdb-mua.el
+++ b/lisp/bbdb-mua.el
@@ -901,7 +901,8 @@ See `bbdb-mua-auto-update' for details about the auto update feature."
                  (vm . vm-select-message-hook)))
     (if (memq (car mua) muas)
         (add-hook (cdr mua) 'bbdb-mua-auto-update)
-      (remove-hook (cdr mua) 'bbdb-mua-auto-update))))
+      (when (boundp (cdr mua))
+        (remove-hook (cdr mua) 'bbdb-mua-auto-update)))))
 
 ;;;###autoload
 (defun bbdb-auto-notes (record)
-- 
2.4.10

