* Re: Forcing C++ to reformat
[not found] <mailman.328.1071800109.868.help-gnu-emacs@gnu.org>
@ 2003-12-19 4:30 ` Harald Maier
2003-12-19 7:14 ` Marco Gidde
2003-12-19 8:57 ` Alan Mackenzie
2 siblings, 0 replies; 6+ messages in thread
From: Harald Maier @ 2003-12-19 4:30 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> writes:
> Hello,
>
> I use emacs to edit C++ source files. I've modified
> cc mode to format my code as I desire but I' run into
> a common problem. Let's say I'm typing and I
> accidently forget to close a brace or a paren and then
> continue on coding. The following code is (of course)
> formatted correctly according to what I actually typed
> but incorrectly according to what I meant to type :)
> Okay, so I discover the probelm (say a missing close
> paren after an argument list) and go back and fix it.
> How can I force the buffer to be reformatted at this
> point? I hope this makes sense as I'm not too hip to
> all the emacs lingo yet. Thanks in advance for any
> replies.
Have you tried 'M-x show-paren-mode'?
Harald
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Forcing C++ to reformat
[not found] <mailman.328.1071800109.868.help-gnu-emacs@gnu.org>
2003-12-19 4:30 ` Forcing C++ to reformat Harald Maier
@ 2003-12-19 7:14 ` Marco Gidde
2003-12-19 8:57 ` Alan Mackenzie
2 siblings, 0 replies; 6+ messages in thread
From: Marco Gidde @ 2003-12-19 7:14 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> writes:
> I use emacs to edit C++ source files. I've modified
> cc mode to format my code as I desire but I' run into
> a common problem. Let's say I'm typing and I
> accidently forget to close a brace or a paren and then
> continue on coding. The following code is (of course)
> formatted correctly according to what I actually typed
> but incorrectly according to what I meant to type :)
> Okay, so I discover the probelm (say a missing close
> paren after an argument list) and go back and fix it.
> How can I force the buffer to be reformatted at this
> point? I hope this makes sense as I'm not too hip to
> all the emacs lingo yet. Thanks in advance for any
> replies.
Two function come to my mind: c-indent-defun and
c-indent-line-or-region. The first one is very useful in your case
when bound to some key, for example C-c C-q. It reformats the function
you are in. In fact I use it all the time, not only when I mistyped
something, but also when I change the position of some if, switch or
what ever.
--
Marco Gidde
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Forcing C++ to reformat
[not found] <mailman.328.1071800109.868.help-gnu-emacs@gnu.org>
2003-12-19 4:30 ` Forcing C++ to reformat Harald Maier
2003-12-19 7:14 ` Marco Gidde
@ 2003-12-19 8:57 ` Alan Mackenzie
2003-12-20 18:26 ` exits funnel
2 siblings, 1 reply; 6+ messages in thread
From: Alan Mackenzie @ 2003-12-19 8:57 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> wrote on Thu, 18 Dec 2003 17:12:57
-0800 (PST):
> I use emacs to edit C++ source files. I've modified cc mode to format
> my code as I desire but I' run into a common problem. Let's say I'm
> typing and I accidently forget to close a brace or a paren and then
> continue on coding. The following code is (of course) formatted
> correctly according to what I actually typed but incorrectly according
> to what I meant to type :) Okay, so I discover the problem (say a
> missing close paren after an argument list) and go back and fix it.
> How can I force the buffer to be reformatted at this point? I hope
> this makes sense as I'm not too hip to all the emacs lingo yet. Thanks
> in advance for any replies.
C-c C-q will reindent the current function.
C-M-q will reindent the contents of a "sexp". (i.e., put point on an
opening brace, and C-M-q will reindent the innards.)
C-M-\ will reindent the current region. (The "region" is the bit of text
between "point" (the cursor) and the "mark" (where you last typed
C-<space> or started a search, or ....... To find where the mark
currently is, type C-x C-x. Then type C-x C-x again to get back. Lots
of things set the mark in Emacs.)
Hint: In a C++ buffer, type C-h m. This will give you a list of
C++-specific commands. Wherever you see ESC <something> you can type
M-<something> instead.
> -exits
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Forcing C++ to reformat
2003-12-19 8:57 ` Alan Mackenzie
@ 2003-12-20 18:26 ` exits funnel
0 siblings, 0 replies; 6+ messages in thread
From: exits funnel @ 2003-12-20 18:26 UTC (permalink / raw)
--- Alan Mackenzie <none@example.invalid> wrote:
> exits funnel <exitsfunnel@yahoo.com> wrote on Thu,
> 18 Dec 2003 17:12:57
> -0800 (PST):
>
> > I use emacs to edit C++ source files. I've
> modified cc mode to format
> > my code as I desire but I' run into a common
> problem. Let's say I'm
> > typing and I accidently forget to close a brace or
> a paren and then
> > continue on coding. The following code is (of
> course) formatted
> > correctly according to what I actually typed but
> incorrectly according
> > to what I meant to type :) Okay, so I discover the
> problem (say a
> > missing close paren after an argument list) and go
> back and fix it.
> > How can I force the buffer to be reformatted at
> this point? I hope
> > this makes sense as I'm not too hip to all the
> emacs lingo yet. Thanks
> > in advance for any replies.
>
> C-c C-q will reindent the current function.
>
> C-M-q will reindent the contents of a "sexp".
> (i.e., put point on an
> opening brace, and C-M-q will reindent the innards.)
>
> C-M-\ will reindent the current region. (The
> "region" is the bit of text
> between "point" (the cursor) and the "mark" (where
> you last typed
> C-<space> or started a search, or ....... To find
> where the mark
> currently is, type C-x C-x. Then type C-x C-x again
> to get back. Lots
> of things set the mark in Emacs.)
>
> Hint: In a C++ buffer, type C-h m. This will give
> you a list of
> C++-specific commands. Wherever you see ESC
> <something> you can type
> M-<something> instead.
>
> > -exits
>
> --
> Alan Mackenzie (Munich, Germany)
> Email: aacm@muuc.dee; to decode, wherever there is a
> repeated letter
> (like "aa"), remove half of them (leaving, say,
> "a").
Thanks Alan and Marco! You're replies were a big
help. It seems that c-indent-line-or-region is the
function I need. It turns out that on my system it's
not bound to any key by default. So, I'm going to
bind it in my .emacs file but as I'm quite new to
EMACS I have a further question. Is there some way to
get a list of currently unused key-combinations? In
other words, how do I know what is a good key choice
to bind to?
-exits
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.412.1071948489.868.help-gnu-emacs@gnu.org>]
* Re: Forcing C++ to reformat
[not found] <mailman.412.1071948489.868.help-gnu-emacs@gnu.org>
@ 2003-12-20 20:39 ` Johan Bockgård
0 siblings, 0 replies; 6+ messages in thread
From: Johan Bockgård @ 2003-12-20 20:39 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> writes:
> Is there some way to get a list of currently unused key-combinations?
> In other words, how do I know what is a good key choice to bind to?
`C-h b' lists all currently used keys. However,
As a user, you can redefine any key; but it is usually best to stick
to key sequences that consist of `C-c' followed by a letter. These
keys are "reserved for users," so they won't conflict with any
properly designed Emacs extension. The function keys <F5> through
<F9> are also reserved for users.
(info "(emacs)Keymaps")
--
Johan Bockgård
^ permalink raw reply [flat|nested] 6+ messages in thread
* Forcing C++ to reformat
@ 2003-12-19 1:12 exits funnel
0 siblings, 0 replies; 6+ messages in thread
From: exits funnel @ 2003-12-19 1:12 UTC (permalink / raw)
Hello,
I use emacs to edit C++ source files. I've modified
cc mode to format my code as I desire but I' run into
a common problem. Let's say I'm typing and I
accidently forget to close a brace or a paren and then
continue on coding. The following code is (of course)
formatted correctly according to what I actually typed
but incorrectly according to what I meant to type :)
Okay, so I discover the probelm (say a missing close
paren after an argument list) and go back and fix it.
How can I force the buffer to be reformatted at this
point? I hope this makes sense as I'm not too hip to
all the emacs lingo yet. Thanks in advance for any
replies.
-exits
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-12-20 20:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.328.1071800109.868.help-gnu-emacs@gnu.org>
2003-12-19 4:30 ` Forcing C++ to reformat Harald Maier
2003-12-19 7:14 ` Marco Gidde
2003-12-19 8:57 ` Alan Mackenzie
2003-12-20 18:26 ` exits funnel
[not found] <mailman.412.1071948489.868.help-gnu-emacs@gnu.org>
2003-12-20 20:39 ` Johan Bockgård
2003-12-19 1:12 exits funnel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).