changeset 79296:82de3a8b0f8d

(whitespace-unload-function): New-style unload function. When run, unintern `whitespace-unload-hook' and call `unload-feature' recursively to stop the old hook from messing with the unloading.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 31 Oct 2007 18:41:37 +0000
parents 7885b35965a1
children d03e9eca4102
files lisp/whitespace.el
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/whitespace.el	Wed Oct 31 18:14:41 2007 +0000
+++ b/lisp/whitespace.el	Wed Oct 31 18:41:37 2007 +0000
@@ -793,15 +793,18 @@
 
 (defun whitespace-unload-function ()
   "Unload the whitespace library."
-  (whitespace-global-mode -1)
-  (save-current-buffer
-    (dolist (buf (buffer-list))
-      (set-buffer buf)
-      (remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
-  ;; new-style unloading, stop old style from running
-  (with-no-warnings (setq whitespace-unload-hook nil))
-  ;; continue standard unloading
-  nil)
+  (if (unintern "whitespace-unload-hook")
+      ;; if whitespace-unload-hook is defined, let's get rid of it
+      ;; and recursively call `unload-feature'
+      (progn (unload-feature 'whitespace) t)
+    ;; this only happens in the recursive call
+    (whitespace-global-mode -1)
+    (save-current-buffer
+      (dolist (buf (buffer-list))
+	(set-buffer buf)
+	(remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
+    ;; continue standard unloading
+    nil))
 
 (defun whitespace-unload-hook ()
   (remove-hook 'find-file-hook 'whitespace-buffer)