help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting emacs variables


From: Gerald A Winters
Subject: Re: setting emacs variables
Date: Mon, 8 Oct 2001 23:52:44 -0400 (EDT)

Olivier,

Thanks for the reply.  Your code below showed me
how to customize the indentation along with
the help facility.

However, according to the emacs help this should work:

(setq c-basic-offset 4)

but it doesn't -- it has absolutely no effect that I can tell.
If you understand why the above statement won't work I'd
like to know.  But regardless thanks for the help.

--jerry

> 
> Gerald A Winters wrote:
> 
>  > I am a C-programmer and am using v20.7.  I would like to
>  > change the default indentation level from "2" to "4" when
>  > in C-mode.  I have a couple manuals and both indicate to
>  > change the emacs varibale "c-indent-level".  However, neither
>  > of these works in my .emacs file:
>  >
>  > (setq c-indent-level 4)
>  > (setq-default c-indent-level 4)
>  >
>  > I would be *very* grateful if someone can suggest a solution.
>  > thanks.
>  >
>  > --jerry
>  >
>  >
>  > _______________________________________________
>  > Help-gnu-emacs mailing list
>  > Help-gnu-emacs@gnu.org
>  > http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
>  >
>  >
> 
> Emacs uses the cc-mode to fontify C files, and to indent too. Indentation
> is based on the 'tab-width' variable, which can be redifined for each
> mode. The C structure's indentation is related to
> c-basic-offset variable and an offset for the different part of the 
> structure. In order to have more
> precise informations try M-x hell RET i RET C-s 'CC mode', section 
> Customizing indentation and try this in your .emacs file :
> 
> 
>     (setq tab-width 4)
>     ;; this will make sure spaces are used instead of tabs
>     (setq indent-tabs-mode nil)
>     (setq c-tab-always-indent t)
> 
>     ;; Highlight matching parantheses
>     (show-paren-mode 1)
> 
>     ;;--------------------------
>     ;; indentation
>     ;; For more information : M-x info cc-mode
>     (setq c-comment-only-line-offset      0);; -1000 to have it at the
> beginning of the line
>     (setq c-basic-offset                  3);; general value for
> indentation on wich every arg of the
>     ;; c-set-offset will be based on
>     ;; + mean c-basic-offset*1
>     (c-set-offset   'arglist-close        0);; 0 mean c-basic-offset*0
>     (c-set-offset   'arglist-intro       '+);; function parameters
>     (c-set-offset   'substatement-open    0);; indentation of braces for
> if, for, while
>     (c-set-offset   'substatement        '+);; indentation of a statement
> (each line of a function)
>     (c-set-offset   'case-label          '+);; indentation for the label
> in a switch-case structure
>     (c-set-offset   'defun-block-intro   '+);; indentation of variable
> def for a function (no tab)
> 
>     (c-set-offset   'statement            0);; indentation of the
> function's body (the first line
>     ;; starts at this point)
>     ;;--------------------------
> 
> The wright way to do this is to mak a new hook for the c-mode. You can 
> see the documentation about hooks : M_x help RET i -RET and look for 
> hook description.
> -- 
> -----------------------------------------------------------------
> Olivier PIERRAT                   Tel.   : +33 (0) 03 90 40 00 00
> ALPLOG                            Port.  : +33 (0) 06 76 41 16 00
> Immeuble le Platon                mailto : o.pierrat@alplog.fr
> 67400 ILLKIRCH                    mailto : o.pierrat@free.fr
> 
> -----------------------------------------------------------------
> 
> 
> 
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]