comparison lisp/whitespace.el @ 91085:880960b70474

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
author Miles Bader <miles@gnu.org>
date Sun, 11 Nov 2007 00:56:44 +0000
parents 14c4a6aac623 d3e87ee5aa0e
children 2fcaae6177a5
comparison
equal deleted inserted replaced
91084:a4347a111894 91085:880960b70474
782 782
783 ;;;###autoload 783 ;;;###autoload
784 (defun whitespace-write-file-hook () 784 (defun whitespace-write-file-hook ()
785 "Hook function to be called on the buffer when whitespace check is enabled. 785 "Hook function to be called on the buffer when whitespace check is enabled.
786 This is meant to be added buffer-locally to `write-file-functions'." 786 This is meant to be added buffer-locally to `write-file-functions'."
787 (interactive)
788 (let ((werr nil)) 787 (let ((werr nil))
789 (if whitespace-auto-cleanup 788 (if whitespace-auto-cleanup
790 (whitespace-cleanup-internal) 789 (whitespace-cleanup-internal)
791 (setq werr (whitespace-buffer))) 790 (setq werr (whitespace-buffer)))
792 (if (and whitespace-abort-on-error werr) 791 (if (and whitespace-abort-on-error werr)
793 (error (concat "Abort write due to whitespaces in " 792 (error (concat "Abort write due to whitespaces in "
794 buffer-file-name)))) 793 buffer-file-name))))
795 nil) 794 nil)
796 795
796 (defun whitespace-unload-function ()
797 "Unload the whitespace library."
798 (if (unintern "whitespace-unload-hook")
799 ;; if whitespace-unload-hook is defined, let's get rid of it
800 ;; and recursively call `unload-feature'
801 (progn (unload-feature 'whitespace) t)
802 ;; this only happens in the recursive call
803 (whitespace-global-mode -1)
804 (save-current-buffer
805 (dolist (buf (buffer-list))
806 (set-buffer buf)
807 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
808 ;; continue standard unloading
809 nil))
810
797 (defun whitespace-unload-hook () 811 (defun whitespace-unload-hook ()
798 (remove-hook 'find-file-hook 'whitespace-buffer) 812 (remove-hook 'find-file-hook 'whitespace-buffer)
799 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) 813 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
800 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) 814 (remove-hook 'kill-buffer-hook 'whitespace-buffer))
801 815