comparison lisp/whitespace.el @ 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 7c8949dbfa0d
children 82de3a8b0f8d
comparison
equal deleted inserted replaced
79291:9f847e38fd02 79292:256e724f6460
780 780
781 ;;;###autoload 781 ;;;###autoload
782 (defun whitespace-write-file-hook () 782 (defun whitespace-write-file-hook ()
783 "Hook function to be called on the buffer when whitespace check is enabled. 783 "Hook function to be called on the buffer when whitespace check is enabled.
784 This is meant to be added buffer-locally to `write-file-functions'." 784 This is meant to be added buffer-locally to `write-file-functions'."
785 (interactive)
786 (let ((werr nil)) 785 (let ((werr nil))
787 (if whitespace-auto-cleanup 786 (if whitespace-auto-cleanup
788 (whitespace-cleanup-internal) 787 (whitespace-cleanup-internal)
789 (setq werr (whitespace-buffer))) 788 (setq werr (whitespace-buffer)))
790 (if (and whitespace-abort-on-error werr) 789 (if (and whitespace-abort-on-error werr)
791 (error (concat "Abort write due to whitespaces in " 790 (error (concat "Abort write due to whitespaces in "
792 buffer-file-name)))) 791 buffer-file-name))))
793 nil) 792 nil)
794 793
794 (defun whitespace-unload-function ()
795 "Unload the whitespace library."
796 (whitespace-global-mode -1)
797 (save-current-buffer
798 (dolist (buf (buffer-list))
799 (set-buffer buf)
800 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
801 ;; new-style unloading, stop old style from running
802 (with-no-warnings (setq whitespace-unload-hook nil))
803 ;; continue standard unloading
804 nil)
805
795 (defun whitespace-unload-hook () 806 (defun whitespace-unload-hook ()
796 (remove-hook 'find-file-hook 'whitespace-buffer) 807 (remove-hook 'find-file-hook 'whitespace-buffer)
797 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) 808 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
798 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) 809 (remove-hook 'kill-buffer-hook 'whitespace-buffer))
799 810