From cd990eacdf92fa8e7fe7d522cbce4abe4b8ba4fd Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 22 Sep 2007 15:29:04 +0000 Subject: - deal with saving empty buffers - document the knobs in whitespace.el so that people who want to preserve the in config files can. --- share/misc/NetBSD.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/share/misc/NetBSD.el b/share/misc/NetBSD.el index d189989d536..a516eb0a266 100644 --- a/share/misc/NetBSD.el +++ b/share/misc/NetBSD.el @@ -55,9 +55,27 @@ ) "NetBSD KNF Style") +;; NOTE: whitespace-cleanup has the following control knobs. By +;; default these are all true. +;(setq whitespace-check-leading-whitespace nil) +;(setq whitespace-check-trailing-whitespace nil) +;(setq whitespace-check-spacetab-whitespace nil) +;(setq whitespace-check-indent-whitespace nil) +;(setq whitespace-check-ateol-whitespace nil) + +;; XXX - whitespace.el is badly behaved on blank buffers, so we handle +;; those buffers ourselves. +(defun knf-nonblank-buffer-p () + (if (whitespace-buffer-search "[^ \t\n]") + t + (progn + (delete-region (point-min) (point-max)) + nil))) + (defun knf-write-contents-hook () (if (and (string-equal c-indentation-style "netbsd knf") - (require 'whitespace nil t)) + (require 'whitespace nil t) + (knf-nonblank-buffer-p)) (whitespace-cleanup)) nil ;; XXX - make sure we return nil or the file will not be written. ) -- cgit