summaryrefslogtreecommitdiff
path: root/share/misc
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2007-09-22 15:29:04 +0000
committerchristos <christos@NetBSD.org>2007-09-22 15:29:04 +0000
commitcd990eacdf92fa8e7fe7d522cbce4abe4b8ba4fd (patch)
treea5a1cf183f142873fffbaf48e75b7e90aedd8f7e /share/misc
parent1e59d2ec471893dfd68beb85ef2b551a3b3dc746 (diff)
- deal with saving empty buffers
- document the knobs in whitespace.el so that people who want to preserve the <space><tab> in config files can.
Diffstat (limited to 'share/misc')
-rw-r--r--share/misc/NetBSD.el20
1 files changed, 19 insertions, 1 deletions
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.
)