unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* tidy up code
@ 2007-12-21  9:04 Umar
  2007-12-21  9:29 ` Jason Rumney
  0 siblings, 1 reply; 11+ messages in thread
From: Umar @ 2007-12-21  9:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I am new to emacs. I want to tidy up my code so that it is more
readable. For example:

int main(void)
{
  int a = 1;
     if (a == 1)
   cout << "true" << endl;
  else
        cout << "false" << endl;
    return 0;
       }

to become

int main(void)
{
  int a = 1;
  if (a == 1)
    cout << "true" << endl;
  else
    cout << "false" << endl;
  return 0;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21  9:04 tidy up code Umar
@ 2007-12-21  9:29 ` Jason Rumney
  2007-12-21 10:23   ` Umar
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Rumney @ 2007-12-21  9:29 UTC (permalink / raw)
  To: help-gnu-emacs

On 21 Dec, 09:04, Umar <umars...@gmail.com> wrote:
> Hi,
>
> I am new to emacs. I want to tidy up my code so that it is more
> readable. For example:

indent-region (C-M-\) sounds like what you want.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21  9:29 ` Jason Rumney
@ 2007-12-21 10:23   ` Umar
  2007-12-21 10:41     ` Torben Knudsen
  2007-12-21 11:18     ` Martin Bealby
  0 siblings, 2 replies; 11+ messages in thread
From: Umar @ 2007-12-21 10:23 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 21, 4:29 pm, Jason Rumney <jasonrum...@gmail.com> wrote:
>
> indent-region (C-M-\) sounds like what you want.

No success. I press Ctrl+Shift+m and then key \. Then the \ character
appears.

I'm totally new to emacs. Can't I just select it using mouse, and then
press some key combination?
TIA

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 10:23   ` Umar
@ 2007-12-21 10:41     ` Torben Knudsen
  2007-12-21 11:00       ` Umar Said
  2007-12-21 11:18     ` Martin Bealby
  1 sibling, 1 reply; 11+ messages in thread
From: Torben Knudsen @ 2007-12-21 10:41 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Umar" == Umar  <umarsaid@gmail.com> writes:

Umar> On Dec 21, 4:29 pm, Jason Rumney <jasonrum...@gmail.com> wrote:
>>  indent-region (C-M-\) sounds like what you want.

Umar> No success. I press Ctrl+Shift+m and then key \. Then the \
Umar> character appears.

I use the command i.e. M-x indent-region because the key short cut do
not (always) work for me.
-- 
Associate Prof. Ph.D Torben Knudsen	Mobile	: (+45) 2787 9826
Section of Automation and Control,	Email	: tk@es.aau.dk   
Department of Electronic Systems,	
Aalborg University 
Fredrik Bajersvej 7 
DK-9220 Aalborg Ø
Denmark 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 10:41     ` Torben Knudsen
@ 2007-12-21 11:00       ` Umar Said
  0 siblings, 0 replies; 11+ messages in thread
From: Umar Said @ 2007-12-21 11:00 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 21 Dec 2007 11:41:25 +0100, Torben Knudsen wrote:
> I use the command i.e. M-x indent-region because the key short cut do
> not (always) work for me.

Still no success. Here is the result:

int main(void)
{
int a = 1				;
if (a == 1)
cout << "true" << endl			;
else
cout << "false" << endl			;
return 0
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 10:23   ` Umar
  2007-12-21 10:41     ` Torben Knudsen
@ 2007-12-21 11:18     ` Martin Bealby
  2007-12-21 11:23       ` Umar Said
  1 sibling, 1 reply; 11+ messages in thread
From: Martin Bealby @ 2007-12-21 11:18 UTC (permalink / raw)
  To: help-gnu-emacs

Umar <umarsaid@gmail.com> writes:

> On Dec 21, 4:29 pm, Jason Rumney <jasonrum...@gmail.com> wrote:
>>
>> indent-region (C-M-\) sounds like what you want.
>
> No success. I press Ctrl+Shift+m and then key \. Then the \ character
> appears.

As you are new to Emacs I'm assuming you are not used to the C-M-<x>
notation.  Note that this does not mean Control + Capital M then \

C, M and S are modifier keys and you press the required ones at the same
time.

C is control.
M is meta (alt on PCs).
S is shift.

Thus, C-M-\ is control + meta (alt) + backslash at the same time.

Martin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 11:18     ` Martin Bealby
@ 2007-12-21 11:23       ` Umar Said
  2007-12-21 12:07         ` nullius.filius
  0 siblings, 1 reply; 11+ messages in thread
From: Umar Said @ 2007-12-21 11:23 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 21 Dec 2007 11:18:15 +0000, Martin Bealby wrote:
> As you are new to Emacs I'm assuming you are not used to the C-M-<x>
> notation.  Note that this does not mean Control + Capital M then \
> 
> C, M and S are modifier keys and you press the required ones at the same
> time.
> 
> C is control.
> M is meta (alt on PCs).
> S is shift.
> 
> Thus, C-M-\ is control + meta (alt) + backslash at the same time.
> 
> Martin

Thank you Martin. Yes I'm new to Emacs and confused with it. I've tried to
press control+alt+\ as you told me. Here is the result:

   
   int main(void)
   {
     int a = 1;
         if (a == 1)
	  cout << "true" << endl;
	       else
	         cout << "false" << endl;
		 return 0
		      }

I've also tried M-x indent-region and other indent command, but still no
success.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 11:23       ` Umar Said
@ 2007-12-21 12:07         ` nullius.filius
  2007-12-21 12:30           ` Umar Said
  0 siblings, 1 reply; 11+ messages in thread
From: nullius.filius @ 2007-12-21 12:07 UTC (permalink / raw)
  To: help-gnu-emacs

X-no-archive: Yes

Umar Said wrote:

>
> Yes I'm new to Emacs and confused with it. [I'm try to format]
>
>    int main(void)
>    {
>      int a = 1;
>          if (a == 1)
> 	  cout << "true" << endl;
> 	       else
> 	         cout << "false" << endl;
> 		 return 0
> 		      }
>
> I've also tried M-x indent-region and other indent command, but still no
> success.

You have to give a hint to emacs that you want to format a c++ file.
You do that by naming the file before you try and format it.

Go to the file menu and click on the menu item 'Visit new File' go to
the directory you want to save your file, and type in your file name
(test.cpp) and click the open button.

Now paste your code into emacs.

Once emacs has a hint on what type of file it is formatting, then
it can format it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 12:07         ` nullius.filius
@ 2007-12-21 12:30           ` Umar Said
  2007-12-23  6:01             ` Gabriel Parrondo
       [not found]             ` <mailman.5343.1198389653.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Umar Said @ 2007-12-21 12:30 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 21 Dec 2007 04:07:05 -0800, nullius.filius wrote:
> X-no-archive: Yes
> 
> 
> You have to give a hint to emacs that you want to format a c++ file.
> You do that by naming the file before you try and format it.
> 
> Go to the file menu and click on the menu item 'Visit new File' go to
> the directory you want to save your file, and type in your file name
> (test.cpp) and click the open button.
> 
> Now paste your code into emacs.
> 
> Once emacs has a hint on what type of file it is formatting, then
> it can format it.

Thank you nullius. It solves the problem.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
  2007-12-21 12:30           ` Umar Said
@ 2007-12-23  6:01             ` Gabriel Parrondo
       [not found]             ` <mailman.5343.1198389653.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Gabriel Parrondo @ 2007-12-23  6:01 UTC (permalink / raw)
  To: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 1190 bytes --]

El vie, 21-12-2007 a las 13:30 +0100, Umar Said escribió:
> On Fri, 21 Dec 2007 04:07:05 -0800, nullius.filius wrote:
> > X-no-archive: Yes
> > 
> > 
> > You have to give a hint to emacs that you want to format a c++ file.
> > You do that by naming the file before you try and format it.
> > 
> > Go to the file menu and click on the menu item 'Visit new File' go to
> > the directory you want to save your file, and type in your file name
> > (test.cpp) and click the open button.
> > 
> > Now paste your code into emacs.
> > 
> > Once emacs has a hint on what type of file it is formatting, then
> > it can format it.
> 
> Thank you nullius. It solves the problem.

Note that you don't really need to name the file with the usual
extension for the file format. You can tell emacs that you're editing a
C++ file with "M-x c++-mode", despite of its name.

I strongly recommend reading the emacs tutorial (C-h t) if you didn't
already.


-- 
Gabriel Parrondo
GNU/Linux User #404138
GnuPG Public Key ID: BED7BF43
JID: gabrielp@xmpp.us

"The only difference between theory and practice is that, in theory, there's no difference between theory and practice."

[-- Attachment #1.2: Esta parte del mensaje está firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 222 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: tidy up code
       [not found]             ` <mailman.5343.1198389653.18990.help-gnu-emacs@gnu.org>
@ 2007-12-26  3:02               ` Umar Said
  0 siblings, 0 replies; 11+ messages in thread
From: Umar Said @ 2007-12-26  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

On Sun, 23 Dec 2007 03:01:32 -0300, Gabriel Parrondo wrote:
> Note that you don't really need to name the file with the usual
> extension for the file format. You can tell emacs that you're editing a
> C++ file with "M-x c++-mode", despite of its name.
> 
Thank you. That also helps.

> I strongly recommend reading the emacs tutorial (C-h t) if you didn't
> already.
> 
I have. Still it is not easy to comprehend though.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-12-26  3:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-21  9:04 tidy up code Umar
2007-12-21  9:29 ` Jason Rumney
2007-12-21 10:23   ` Umar
2007-12-21 10:41     ` Torben Knudsen
2007-12-21 11:00       ` Umar Said
2007-12-21 11:18     ` Martin Bealby
2007-12-21 11:23       ` Umar Said
2007-12-21 12:07         ` nullius.filius
2007-12-21 12:30           ` Umar Said
2007-12-23  6:01             ` Gabriel Parrondo
     [not found]             ` <mailman.5343.1198389653.18990.help-gnu-emacs@gnu.org>
2007-12-26  3:02               ` Umar Said

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).