comparison lisp/whitespace.el @ 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 256e724f6460
children c273395cbfd3 d3e87ee5aa0e
comparison
equal deleted inserted replaced
79295:7885b35965a1 79296:82de3a8b0f8d
791 buffer-file-name)))) 791 buffer-file-name))))
792 nil) 792 nil)
793 793
794 (defun whitespace-unload-function () 794 (defun whitespace-unload-function ()
795 "Unload the whitespace library." 795 "Unload the whitespace library."
796 (whitespace-global-mode -1) 796 (if (unintern "whitespace-unload-hook")
797 (save-current-buffer 797 ;; if whitespace-unload-hook is defined, let's get rid of it
798 (dolist (buf (buffer-list)) 798 ;; and recursively call `unload-feature'
799 (set-buffer buf) 799 (progn (unload-feature 'whitespace) t)
800 (remove-hook 'write-file-functions 'whitespace-write-file-hook t))) 800 ;; this only happens in the recursive call
801 ;; new-style unloading, stop old style from running 801 (whitespace-global-mode -1)
802 (with-no-warnings (setq whitespace-unload-hook nil)) 802 (save-current-buffer
803 ;; continue standard unloading 803 (dolist (buf (buffer-list))
804 nil) 804 (set-buffer buf)
805 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
806 ;; continue standard unloading
807 nil))
805 808
806 (defun whitespace-unload-hook () 809 (defun whitespace-unload-hook ()
807 (remove-hook 'find-file-hook 'whitespace-buffer) 810 (remove-hook 'find-file-hook 'whitespace-buffer)
808 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) 811 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
809 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) 812 (remove-hook 'kill-buffer-hook 'whitespace-buffer))