]> git.eshelyaron.com Git - emacs.git/commitdiff
(whitespace-unload-function): New-style unload function.
authorJuanma Barranquero <lekktu@gmail.com>
Wed, 31 Oct 2007 18:45:14 +0000 (18:45 +0000)
committerJuanma Barranquero <lekktu@gmail.com>
Wed, 31 Oct 2007 18:45:14 +0000 (18:45 +0000)
When run, unintern `whitespace-unload-hook' and call
`unload-feature' recursively to stop the old hook from
messing with the unloading.

lisp/ChangeLog
lisp/whitespace.el

index e1720346d26661ef4d061e388cdf8597d3de51d5..c6326fed8c30dae054f3ec148b264d9d46e2a685 100644 (file)
@@ -6,8 +6,9 @@
 2007-10-31  Juanma Barranquero  <lekktu@gmail.com>
 
        * whitespace.el (whitespace-write-file-hook): Remove interactive spec.
-       (whitespace-unload-function): New-style unload function.
-       If run, stop old style `-hook' function from running.
+       (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.
 
        * strokes.el (strokes-alphabetic-lessp): Doc fix.
 
index 0251618f0996f3aee55c09ddb9195b557311cc77..9c3a6cc18d8a28f5f9df9a057320b0a37ff77172 100644 (file)
@@ -793,15 +793,18 @@ This is meant to be added buffer-locally to `write-file-functions'."
 
 (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)