unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Steve Revilak <steve@srevilak.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs behavior
Date: Sun, 2 May 2010 22:13:04 -0400	[thread overview]
Message-ID: <20100503021304.GD11102@srevilak.net> (raw)
In-Reply-To: <20100502051849.6B0CF70000090@urquell.c3sl.ufpr.br>

[-- 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 --]

  reply	other threads:[~2010-05-03  2:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-02  5:18 Emacs behavior VICTOR TARABOLA CORTIANO
2010-05-03  2:13 ` Steve Revilak [this message]
2010-05-04  3:44   ` VICTOR TARABOLA CORTIANO
2010-05-04 18:03     ` Gary
2010-05-06  1:21       ` VICTOR TARABOLA CORTIANO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100503021304.GD11102@srevilak.net \
    --to=steve@srevilak.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).