diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2007-10-31 18:45:14 +0000 |
---|---|---|
committer | Juanma Barranquero <lekktu@gmail.com> | 2007-10-31 18:45:14 +0000 |
commit | 3e1da21463d582c0f3c9f989c435b5021d09741f (patch) | |
tree | 40933fad4dfea0eed20f60e5b23715b736320f29 /lisp/whitespace.el | |
parent | 89242dda1535be54a1540858b17e4444147e496c (diff) | |
download | emacs-3e1da21463d582c0f3c9f989c435b5021d09741f.tar.gz |
(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.
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r-- | lisp/whitespace.el | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 0251618f099..9c3a6cc18d8 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -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) |