I have been wondering about this too. While I have not yet tried the new
code being developed here, I am not sure of the full overlap between the
feature under discussion and already existing Emacs functionality.
As Klaus mentioned using CC-Mode settings, I too have auto-newline and
indentation happening automatically with base Emacs functionality. I am not
sure what I am missing with regard to that and the new code.
For easy reference and others to try, here are my CC-Mode settings relating
to newline and indentation:
;; turn on auto-newline (C-c C-a toggles)
(add-hook 'c-mode-common-hook
'(lambda () (c-toggle-auto-state 1)))
(setq c-hanging-braces-alist (quote ((substatement-open before after))))
(setq c-offsets-alist (quote ((case-label . +) (substatement-open . 0))))
(setq c-hanging-colons-alist (quote ((case-label after) (label after))))
A key impact point is the new code in development regarding this feature
must play nicely with CC-Mode settings like these. :-)
The only feature missing for me is the auto-insertion of the closing
brace/parenthesis (ala' ye olde' wonderful Brief editor). That is a feature
I miss and would very much like.
I have not yet explored "Erik Hilsdale's balanced.el", mentioned by Suraj
Acharya in this thread (that it auto-inserts the closing brace on typing of
the opening). Perhaps using it will complete the "feature"(?). If so, I
would rather see JDE include that product.
> -----Original Message-----
> From: Berndl, Klaus [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 13, 2004 12:23 PM
> To: 'Paul Kinnucan'; Suraj Acharya
> Cc: [EMAIL PROTECTED]; Petter M�hl�n; [EMAIL PROTECTED]
> Subject: AW: auto newline, indent and close brace on open
> brace, return
>
>
> Here is a better way to determine the syntactiy context of
> current point, means if point stays within a line-comment,
> block-comment or within a string. IMHO this is more robust
> than jde-line-has-incomplete-string...and uses well proved
> Emacs-concepts for this instead of fiddling with some regexps
> and increasing numbers ;-)
>
> (defun syntactic-context ()
> "Check in which syntactic context point is. Return nil if
> no special context
> meaning, otherwise 'string if within a string, 'comment if within a
> line-comment and 'block-comment if within a block-comment."
> (let* ((beg (save-excursion
> (beginning-of-defun)
> (point)))
> (state (save-excursion
> (parse-partial-sexp beg (point)))))
> (cond
> ((nth 3 state) 'string)
> ((nth 4 state) (if (member major-mode
> '(c-mode c++-mode java-mode jde-mode))
> (if (nth 7 state) 'comment 'block-comment)
> 'comment))
> (t nil))))
>
> This function returns 'string if point is within a string -
> so also when point is at the end of an unterminated string.
> In that situation a newline-command should insert a
> (java)string terminator and so on ... As already done by the
> code of this thread. This has the side-effect that when point
> stays within a terminated string a newline-command breaks
> this string by adding a new terminator behind the break...so
> the smart newline-command does not only for unterminated
> strings the right thing but also for terminated.
>
> Thoughts?
>
> BTW: I do not want to upset someone who contributes to this
> thread and code, but i have the strong feeling, that the most
> things could be done more generally with concepts and
> mechanism of the underlying cc-mode. I'm think into the
> direction of `c-hanging-braces-alist' and all this
> stuff...IMHO JDEE and also this contributed new code
> reinvents the wheel in some aspects...
>
> Off topic: JDEE does this also with all the template-stuff -
> where IMHO somehow cumbersomely is specified if a newline
> after a brace or not etc... all this could be done more nifty
> with mechanism of cc-mode and tempo, so the user specifies
> with cc-mode when he wants newlines before or after praces
> etc. and tempo uses this informations instead of introducing
> new options by JDEE so the user has to customize the same
> thing at differrent places.
>
> Klaus
>
> -----Urspr�ngliche Nachricht-----
> Von: Paul Kinnucan [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 12. M�rz 2004 23:04
> An: Suraj Acharya
> Cc: [EMAIL PROTECTED]; Paul Kinnucan; Petter M�hl�n; [EMAIL PROTECTED]
> Betreff: Re: auto newline, indent and close brace on open
> brace, return
>
>
> Hi All,
>
> I've been saving the email on this thread and will review it
> over the weekend. My plan is to include the latest and
> greatest version that comes out of this discussion.
>
> Thanks,
>
> Paul