Hi,
This seems like a good idea to me, but I had two problems when trying it
out. First, I got an error message saying something like "if: wrong number
of arguments". I then tried the following update which I think is correct
(added parentheses around the else clause):
(define-key jde-mode-map [return]
(lambda ()
(interactive)
(if (save-excursion
(backward-char)
(not (looking-at "{}?$")))
(newline-and-indent)
;; else
((newline-and-indent)
(newline-and-indent)
(when (not (looking-at "}"))
(insert "}")
(c-indent-command)
)
(previous-line)
(c-indent-command)
))))
But then I got an error message saying: "if: Invalid function:
(newline-and-indent)". Where is newline-and-indent defined?
/ Petter
> -----Original Message-----
> From: Suraj Acharya [mailto:[EMAIL PROTECTED]
> Sent: den 3 mars 2004 13:55
> To: [EMAIL PROTECTED]
> Subject: auto newline, indent and close brace on open brace, return
>
>
> Intellij does this thing where if you type a open curly brace
> and then a
> return it inserts a matching closing brace and puts point
> on a empty line between the braces and indents the two
> newlines. So if
> before you had:
>
> pubic void function () {
> ^
> You now have:
>
> pubic void function () {
>
> }^
>
> Simple but handy.
>
> (define-key jde-mode-map [return]
> (lambda ()
> (interactive)
> (if (save-excursion
> (backward-char)
> (not (looking-at "{}?$")))
> (newline-and-indent)
> ;; else
> (newline-and-indent)
> (newline-and-indent)
> (when (not (looking-at "}"))
> (insert "}")
> (c-indent-command)
> )
> (previous-line)
> (c-indent-command)
> )))
>
>
> Suraj
>
> PS: The above is slightly more complicated than needs be
> because I use
> Erik Hilsdale's balanced.el which, among other things, automatically
> inserts matching close parenthese when you type any kind of open
> parentheses.
>
>