changeset 79292:256e724f6460

(whitespace-write-file-hook): Remove interactive spec. (whitespace-unload-function): New-style unload function. If run, stop old style `-hook' function from running.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 31 Oct 2007 15:56:23 +0000
parents 9f847e38fd02
children 7b9d5ff05014
files lisp/whitespace.el
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/whitespace.el	Wed Oct 31 13:07:03 2007 +0000
+++ b/lisp/whitespace.el	Wed Oct 31 15:56:23 2007 +0000
@@ -782,7 +782,6 @@
 (defun whitespace-write-file-hook ()
   "Hook function to be called on the buffer when whitespace check is enabled.
 This is meant to be added buffer-locally to `write-file-functions'."
-  (interactive)
   (let ((werr nil))
     (if whitespace-auto-cleanup
 	(whitespace-cleanup-internal)
@@ -792,6 +791,18 @@
 		       buffer-file-name))))
   nil)
 
+(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)
+
 (defun whitespace-unload-hook ()
   (remove-hook 'find-file-hook 'whitespace-buffer)
   (remove-hook 'write-file-functions 'whitespace-write-file-hook t)