On Tue, Jun 03, 2003 at 10:58:19AM -0400, Ed L Cashin wrote: > After reading wli on the LKML mention that emacs users leave trailing > whitespace in their files, I added this to my .emacs file. > > It makes sure that when I am working on kernel sources and I save a > buffer, any trailing whitespace is removed. In case anybody else is using this, I found that for large files the recursion is enough that emacs stops it, assuming something's wrong. This version doesn't use recursion and so works on long files: (defun elc-delete-buffer-trailing-ws () "get rid of trailing whitespace in all lines in current buffer" (interactive) (save-excursion (goto-char (point-min)) (end-of-line) (delete-horizontal-space) (loop do (let ((inhibit-field-text-motion t)) (end-of-line 2) (delete-horizontal-space)) while (/= (point) (point-max))))) > > (defun linux-c-mode () > "C mode with adjusted defaults for use with the Linux kernel." > (interactive) > (add-hook 'local-write-file-hooks > 'elc-delete-buffer-trailing-ws) > (c-mode) > (c-set-style "K&R") > (setq c-basic-offset 8)) > > (add-to-list 'auto-mode-alist > '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)) > (add-to-list 'auto-mode-alist > '(".*/kernel/linux-.*/.*\\.[ch]$" . linux-c-mode)) -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/