On Friday 22 March 2002 6:55 pm, Angus Leeming wrote:
> On Thursday 21 March 2002 8:16 am, Allan Rae wrote:
> > On Wed, 20 Mar 2002, Lars Gullik Bjønnes wrote:
> > > What about:
> > >      delete-trailing-whitespace
> > >      whitespace-cleanup
> >
> > Actually XEmacs doesn't seem to have these (in either 21.1.14 or
> > 21.4.6).  Which emacs and is there a package to load first?
> >
> > I did find whitespace-mode which does a nice job of distinguishing
> > spaces from tabs.  I might use it in future so silly lines which use
> > spaces instead of tabs stand out.
> >
> > Allan. (ARRae)
>
> My emacs (20.7 --- bang up to date?) doesn't have them either. However,
> google is a fabulous resourse:
>       gg:delete-trailing-whitespace
> gives
>       http://www.unixguide.net/unix/sedoneliner.shtml
>
>       # delete trailing whitespace (spaces, tabs) from end of each line
>       sed 's/[ \t]*$//' # see note on '\t' at end of file
>
> where \t is a tab.
>
> and
>       gg:emacs delete-trailing-whitespace
> gives
>       http://www.dotemacs.de/emacro/emacs/functions.html
>
> which contains the magical expression.
>
> So now my question becomes, how do I modify my .emacs to load this file in
> c-mode and in c++-mode and how do I follow Lars' example and have it on by
> default. Lars"?

Partially answering my own question. To enable delete-trailing-whitespace I 
have this in my .emacs file. Note the (load "functions").

That just leaves how do I turn it on by default?

;;; Common hook
(defun my-c-mode-common-hook ()
;; Enable delete-trailing-whitespace
(load "functions")
;; Set return Style
(local-set-key [return] 'newline-and-indent)
(local-set-key [S-return] 'newline)
(c-set-style "CC-MODE")
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)                   

;; C++ mode hook
(defun my-c++-mode-hook ()
;; Style parameters
(setq c-basic-offset 8)
(c-set-offset 'innamespace 0)
(imenu-add-to-menubar "Index")
(c-toggle-auto-state 0)
)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)

Reply via email to