Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

electric braces - move point *inside* the braces?

0 views
Skip to first unread message

M

unread,
Nov 19, 2000, 3:00:00 AM11/19/00
to
Hi,

I've been experimenting with electric braces, and for now if I type :

"for(bla){"
electrically I get

"for(bla)
{
}
_ "<<point is here and indented correctly

What do I need to change to get instead
for(bla){
_ <<<< point is here and indented correctly
}

I've looked at changing c-hanging-braces-alist but the doc in my opinion is
not very clear...I've tried adding
(substatement-open after) and (defun-open after) and that part works.

What do I have to do to get it to move point *inside* the braces?
thx
M

Kai Großjohann

unread,
Nov 19, 2000, 3:00:00 AM11/19/00
to
On Sun, 19 Nov 2000, Montr...@hotREMOVmail.com wrote:

> What do I need to change to get instead
> for(bla){
> _ <<<< point is here and indented correctly
> }

Since you didn't tell us what you were doing initially, how can we
know what you need to change?

I recommend using skeletons for this. You can easily define a
skeleton which inserts a for loop. And then you can define an abbrev
which runs the function that is the skeleton. Hint: type C-h f
define-abbrev RET for information on using that from Lisp. You need
to use it from Lisp to do what you want.

kai
--
The arms should be held in a natural and unaffected way and never
be conspicuous. -- Revised Technique of Latin American Dancing

M

unread,
Nov 20, 2000, 3:00:00 AM11/20/00
to
To clarify,

I've got yhe following in my .emacs :

(c-toggle-auto-state 1)
(c-set-style "stroustrup")

which acticvates the electric braces (among other) features. In the case
that interests me, using electric braces means: typing an opening brace '{'
causes emacs to automatically enter a new line and indent. In the same way,
typing a closing brace '}' causes emacs to enter a newline. That behaviour,
of course, is duplicatable with skeletons or macros, but why not use
built-in features of the styles functions? That's why, I would like to know
if in addition to customizing the addition of newlines (begore, after) I can
also customize where the point will be (as decribed in my first post).

Hope it is clearer.

Thx
M

"M" <Montr...@hotREMOVmail.com> wrote in message
news:dARR5.4205$B6.3...@news20.bellglobal.com...


> Hi,
>
> I've been experimenting with electric braces, and for now if I type :
>
> "for(bla){"
> electrically I get
>

> "for(bla)
> {
> }
> _ "<<point is here and indented correctly
>
> What do I need to change to get instead
> for(bla){
> _ <<<< point is here and indented correctly
> }
>

Nicolas Rist

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Have you tried to customize: "C Hanging Braces Alist" ?

Nicolas

M

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Yes, but I could not find anything about specifying the position of the
point...I can specify where to add a newline ('before, 'after) but not
(AFAIK) where to pisotion the cursor/point.

thx
M


"Nicolas Rist" <Nicola...@alcatel.de> wrote in message
news:3A1A77B7...@alcatel.de...

Nicolas Rist

unread,
Nov 22, 2000, 3:00:00 AM11/22/00
to
For me by default I haven't the second brace. So is the cursor always at
the right position 8-). But I don't know the option for that.

Nicolas

Kai Großjohann

unread,
Nov 22, 2000, 3:00:00 AM11/22/00
to
I think that the normal style functions just don't ave the
functionality you're looking for, so it doesn't make sense to try to
use them. Instead, use skeletons and be happy.

But if you find out how to get the cc-mode style functions to do what
you want, please tell me...

M

unread,
Nov 22, 2000, 3:00:00 AM11/22/00
to
Thanks to all!

I"ll keep looking...for a little while longer...and then I'll probably
revert to skeletons or macros....

M

"Kai Großjohann" <Kai.Gro...@CS.Uni-Dortmund.DE> wrote in message
news:vafn1es...@lucy.cs.uni-dortmund.de...

0 new messages