summaryrefslogtreecommitdiff
path: root/lisp/whitespace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r--lisp/whitespace.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 6e6aeb5fbb7..f6c94534a00 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -784,7 +784,6 @@ When this mode is active, `whitespace-buffer' is added to
(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)
@@ -794,6 +793,21 @@ This is meant to be added buffer-locally to `write-file-functions'."
buffer-file-name))))
nil)
+(defun whitespace-unload-function ()
+ "Unload the whitespace library."
+ (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)
(remove-hook 'write-file-functions 'whitespace-write-file-hook t)