all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indenting
@ 2004-10-26 14:53 Billy N. Patton
  2004-10-26 17:14 ` indenting Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Billy N. Patton @ 2004-10-26 14:53 UTC (permalink / raw)


I'm new to emacs.  Started last Monday with XEmacs and switched this 
monday to gnu emacs.
I've been a 10+ year vim/gvim user.

Here the problem:

I like to line up my variables, = and values in a pretty form that makes 
it more pleasent to the eyes. ex:

int   i1            = 0;
int   another_one   = 1;
char* cp            = '\0';

I do not want tab characters.  done
I want to be able to hit the tab key after I type int and i1. but the 
int indents and follows the tab.  What I end up with is
              int i1 = 0;
THis is no more readable than having everything shifted to the left.

How can I stop this behavior?

I like the auto indenting then I add the { } and the lines afterward.
But I like to line up my code so that it is nice an neat, not a jumbled 
mess.

Any help would be appreciated

my current .emcas file

;;; XEmacs backwards compatibility file
(setq user-init-file
       (expand-file-name "init.el"
                         (expand-file-name ".xemacs" "~")))
(setq custom-file
       (expand-file-name "custom.el"
                         (expand-file-name ".xemacs" "~")))

(load-file user-init-file)
(load-file custom-file)

(add-hook 'c++-mode-hook '(lambda () (setq indent-tabs-mode nil)))
(setq-default indent-tabs-mode nil)
;(setq c-tab-always-indent t)
(setq c-tab-always-indent nil)

-- 
    ___  _ ____       ___       __  __
   / _ )(_) / /_ __  / _ \___ _/ /_/ /____  ___
  / _  / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/   \_,_/\__/\__/\___/_//_/
            /___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455,  b-patton@ti.com

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

* Re: indenting
  2004-10-26 14:53 indenting Billy N. Patton
@ 2004-10-26 17:14 ` Stefan Monnier
  2004-10-26 18:04   ` indenting Billy N. Patton
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2004-10-26 17:14 UTC (permalink / raw)


> I do not want tab characters.

Your (setq-default indent-tabs-mode nil) does that.

> I want to be able to hit the tab key after I type int and i1. but the int
> indents and follows the tab.  What I end up with is
>               int i1 = 0;
> THis is no more readable than having everything shifted to the left.
> How can I stop this behavior?

Your (setq c-tab-always-indent nil) should have done that.  Can you describe
very pedantically precisely every little itsy bitsy detail of what you do,
what you expect, and what happens instead, as if you were talking to
a complete and total idiot ?

> (add-hook 'c++-mode-hook '(lambda () (setq indent-tabs-mode nil)))
                          ^^^
This quote is at best unnecessary.  Better remove it.

> (setq-default indent-tabs-mode nil)

Actually with this default setting your `add-hook' above should not be
necessary at all.

> ;(setq c-tab-always-indent t)

A single ; is indented to comment-column (trying hitting TAB, just for fun).
Use ;; instead.


        Stefan

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

* Re: indenting
  2004-10-26 17:14 ` indenting Stefan Monnier
@ 2004-10-26 18:04   ` Billy N. Patton
  2004-10-26 20:35     ` indenting Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Billy N. Patton @ 2004-10-26 18:04 UTC (permalink / raw)


Stefan Monnier wrote:
>>I do not want tab characters.
> 
> 
> Your (setq-default indent-tabs-mode nil) does that.
> 
> 
>>I want to be able to hit the tab key after I type int and i1. but the int
>>indents and follows the tab.  What I end up with is
>>              int i1 = 0;
>>THis is no more readable than having everything shifted to the left.
>>How can I stop this behavior?
> 
> 
> Your (setq c-tab-always-indent nil) should have done that.  Can you describe
> very pedantically precisely every little itsy bitsy detail of what you do,
> what you expect, and what happens instead, as if you were talking to
> a complete and total idiot ?

I want to type:

int<tab><tab>i1<tab><tab><tab><tab>= 0;
char*<tab>a_pointer<tab><tab> = null;

to end with
int    i            = 0;
char*  a_pointer    = null;

but what I get now is:
               int i = 0;
     char* a_pointer = null;


> 
> 
>>(add-hook 'c++-mode-hook '(lambda () (setq indent-tabs-mode nil)))
> 
>                           ^^^
> This quote is at best unnecessary.  Better remove it.
> 
> 
>>(setq-default indent-tabs-mode nil)
> 
> 
> Actually with this default setting your `add-hook' above should not be
> necessary at all.
> 
> 
>>;(setq c-tab-always-indent t)
> 
> 
> A single ; is indented to comment-column (trying hitting TAB, just for fun).
> Use ;; instead.
> 
> 
>         Stefan


-- 
    ___  _ ____       ___       __  __
   / _ )(_) / /_ __  / _ \___ _/ /_/ /____  ___
  / _  / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/   \_,_/\__/\__/\___/_//_/
            /___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455,  b-patton@ti.com

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

* Re: indenting
  2004-10-26 18:04   ` indenting Billy N. Patton
@ 2004-10-26 20:35     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2004-10-26 20:35 UTC (permalink / raw)


>>>>> "Billy" == Billy N Patton <b-patton@ti.com> writes:

> Stefan Monnier wrote:
>>> I do not want tab characters.
>> Your (setq-default indent-tabs-mode nil) does that.
>> 
>>> I want to be able to hit the tab key after I type int and i1. but the int
>>> indents and follows the tab.  What I end up with is
>>> int i1 = 0;
>>> THis is no more readable than having everything shifted to the left.
>>> How can I stop this behavior?
>> Your (setq c-tab-always-indent nil) should have done that.  Can you
>> describe
>> very pedantically precisely every little itsy bitsy detail of what you do,
>> what you expect, and what happens instead, as if you were talking to
>> a complete and total idiot ?

> I want to type:

> int<tab><tab>i1<tab><tab><tab><tab>= 0;
> char*<tab>a_pointer<tab><tab> = null;

> to end with
> int    i            = 0;
> char*  a_pointer    = null;

> but what I get now is:
>                int i = 0;
>      char* a_pointer = null;

I understand this part, but you left out tons of details, like:\
- how do you start Emacs?
- what version of Emacs?
- what buffer do you type this in (file name? how do you open it?)?
- what is the major mode of that buffer (C-h m tells you)?
- what's the value of c-tab-always-indent in that buffer?
...

When I do:

% emacs-21.2 -q --no-site-file --eval '(setq c-tab-always-indent nil)' ~/tmp/foo.c
int<tab><tab>i1<tab><tab><tab><tab>= 0;

I get a line like:

int		i1				= 0;

which seems pretty close to what you want (except you'll probably want to
hit TAB a bit less often).

I suspect that your (setq c-tab-always-indent nil) is not executed (because
of an error earlier in your .emacs) or it is overruled by something.


        Stefan

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

end of thread, other threads:[~2004-10-26 20:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-26 14:53 indenting Billy N. Patton
2004-10-26 17:14 ` indenting Stefan Monnier
2004-10-26 18:04   ` indenting Billy N. Patton
2004-10-26 20:35     ` indenting Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.