My problem is that my formatting hook is ignored when new Java files are
created. When I reload the file, however, it works fine. My hook is added to
the jde-mode-hook, not to the c-mode-common-hook. Could this be the problem?
I don't necessarily want to have my Java formatting hook called for all
c-mode buffers, which your suggestion seems to imply.
I just want to be able to create new .java files and get my hook to load.
See bottom of mail for my .emacs.
/Markus
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: den 22 januari 2001 10:31
> To: [EMAIL PROTECTED]
> Subject: RE: two questions... offsets and jdebug
>
>
> you could (customize-variable 'c-basic-offset), if that is
> any help. or
> maybe adding your hook function to c-mode-common-hook helps. but maybe
> that's not what you want...
>
> --
> knut
>
> > -----Original Message-----
> > From: Markus Torpvret [SMTP:[EMAIL PROTECTED]]
> > Sent: Monday, January 22, 2001 10:16 AM
> > To: 'Mark Pollack'; [EMAIL PROTECTED]
> > Subject: RE: two questions... offsets and jdebug
> >
> > > 1) In my .emacs I have.
> > >
> > > (defun my-jde-mode-hook ()
> > > (setq c-basic-offset 2))
> > > (add-hook 'jde-mode-hook 'my-jde-mode-hook)
> > >
> > > This works fine, I get 2 spaces working on .java files.
> > > However, when a
> > > create a new .java file using the generator,
> > > jde-gen-class-buffer (I am
> > > using the template that comes with jde) this somehow gets set
> > > back to 4 spaces. Any idea how to make my 2 space setting
> > > stick? This did
> > > not happen when I was using jde-2.2.1.
> >
> > I get this too. I found out that saving and re-visiting the file
> > solves the problem, but I haven't taken it further than that...
> >
> > /Markus
>
(defconst java-style
'((c-tab-always-indent . t)
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((class-open after)
(defun-open after)
(block-open after)
(inline-open after)
(substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . nil)
)
"Markus Java Style")
(defun my-jde-mode-hook ()
;; Set java style
(c-add-style "Markus Java Style" java-style t)
;; set auto-indent and hungry delete
(c-toggle-auto-hungry-state 1)
;; Make sure spaces are used instead of tabs
(setq tab-width 4
indent-tabs-mode nil))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)