From 6341c3fc0b4da35afa56b6c2008a4b56201ef9a9 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Wed, 31 Oct 2007 15:59:19 +0000 Subject: [PATCH] (whitespace-write-file-hook): Remove interactive spec. (whitespace-unload-function): New-style unload function. If run, stop old style `-hook' function from running. --- lisp/ChangeLog | 4 ++++ lisp/whitespace.el | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cf0e02ddfb4..2ab695c5bdd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2007-10-31 Juanma Barranquero + * whitespace.el (whitespace-write-file-hook): Remove interactive spec. + (whitespace-unload-function): New-style unload function. + If run, stop old style `-hook' function from running. + * strokes.el (strokes-alphabetic-lessp): Doc fix. 2007-10-31 Sean O'Rourke diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 3ea8394b0b7..0251618f099 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -782,7 +782,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) @@ -792,6 +791,18 @@ This is meant to be added buffer-locally to `write-file-functions'." buffer-file-name)))) nil) +(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) + (defun whitespace-unload-hook () (remove-hook 'find-file-hook 'whitespace-buffer) (remove-hook 'write-file-functions 'whitespace-write-file-hook t) -- 2.39.2