* Emacs behavior
@ 2010-05-02 5:18 VICTOR TARABOLA CORTIANO
2010-05-03 2:13 ` Steve Revilak
0 siblings, 1 reply; 5+ messages in thread
From: VICTOR TARABOLA CORTIANO @ 2010-05-02 5:18 UTC (permalink / raw)
To: help-gnu-emacs
Hi.
I would like to change the default behavior of Emacs in C mode, I
use tabs instead of spaces for editing, so I changed my .emacs[1]
to behave the way I want.
For instance, I want:
function()
{
commands;
}
But Emacs automatically modify the text to:
function()
{
commands;
}
It works the way I want in text-mode, but I want syntax highligting.
I would like Emacs to behave like mg or vi in C mode.
[1] This is the relevant part in my .emacs file:
;Tab stuff
(global-set-key (kbd "TAB") 'self-insert-command)
(global-set-key (kbd "TAB") 'tab-to-tab-stop)
(setq-default tab-width 8)
(setq-default tab-stop-list (list 8 16 24 32 40 ))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Emacs behavior
2010-05-02 5:18 Emacs behavior VICTOR TARABOLA CORTIANO
@ 2010-05-03 2:13 ` Steve Revilak
2010-05-04 3:44 ` VICTOR TARABOLA CORTIANO
0 siblings, 1 reply; 5+ messages in thread
From: Steve Revilak @ 2010-05-03 2:13 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]
>From: "VICTOR TARABOLA CORTIANO"
>I would like to change the default behavior of Emacs in C mode, I
>use tabs instead of spaces for editing, so I changed my .emacs[1]
>to behave the way I want.
>
>For instance, I want:
>
>function()
>{
> commands;
>}
>
>But Emacs automatically modify the text to:
>
>function()
> {
> commands;
> }
>
>It works the way I want in text-mode, but I want syntax highligting.
>
>I would like Emacs to behave like mg or vi in C mode.
I've been working on a C project where most of the source code was
indented using tabs, and I wanted my edits to follow the same
formatting. A solution that worked for me was
/*
* Local Variables:
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/
I added this Local Variables block at the bottom of each .c file I
needed to edit. (I didn't want to change the behavior of C mode
globally; instead, I merely wanted to change it in a few specific
files.)
Putting something like
(setq c-basic-offset 8
indent-tabs-mode t)
into ~/.emacs may give some of the behavior you're looking for.
You can also try
(setq c-indentation-style "linux")
For a description of cc-mode styles, these are good places to start:
http://www.gnu.org/software/emacs/manual/html_node/ccmode/Choosing-a-Style.html#Choosing-a-Style
http://www.gnu.org/software/emacs/manual/html_node/ccmode/Built_002din-Styles.html#Built_002din-Styles
Finally, c-insert-tab-function might also be useful to you.
http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html#index-TAB-17
Steve
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Emacs behavior
2010-05-03 2:13 ` Steve Revilak
@ 2010-05-04 3:44 ` VICTOR TARABOLA CORTIANO
2010-05-04 18:03 ` Gary
0 siblings, 1 reply; 5+ messages in thread
From: VICTOR TARABOLA CORTIANO @ 2010-05-04 3:44 UTC (permalink / raw)
To: help-gnu-emacs, steve
> Putting something like
>
> (setq c-basic-offset 8
> indent-tabs-mode t)
>
> into ~/.emacs may give some of the behavior you're looking for.
>
> You can also try
>
> (setq c-indentation-style "linux")
>
Thank you. I removed my old .emacs and put that instead, it
works almost perfectly. The only issue is:
function()
{
}
It puts the first "{" in the wrong place, but it's just a matter of
C-d and then it goes to its place:
function()
{
}
It would be fine to make it right in the first place. But it's good
enough now. It's just a matter of deleting an extra tab...
Thank you very much.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-06 1:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-02 5:18 Emacs behavior VICTOR TARABOLA CORTIANO
2010-05-03 2:13 ` Steve Revilak
2010-05-04 3:44 ` VICTOR TARABOLA CORTIANO
2010-05-04 18:03 ` Gary
2010-05-06 1:21 ` VICTOR TARABOLA CORTIANO
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).