unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Tab problem
@ 2004-09-04 13:45 Nick Chorley
  2004-09-05  2:09 ` Michael Slass
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Nick Chorley @ 2004-09-04 13:45 UTC (permalink / raw)


I have a problem with Emacs which is that I can't seem to enter more 
than 1 tab when in C++/Java mode (it does do the automatic indentation 
like when you're using if statements though). When in the "normal" text 
editing mode, I can't enter any tabs.

Can anyone help?

Thanks.

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

* Re: Tab problem
  2004-09-04 13:45 Tab problem Nick Chorley
@ 2004-09-05  2:09 ` Michael Slass
  2004-09-07 13:53   ` kgold
  2004-09-05  8:26 ` Juraj Kubelka
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Michael Slass @ 2004-09-05  2:09 UTC (permalink / raw)


Nick Chorley <nick@nospam.xyphias.com> writes:

>I have a problem with Emacs which is that I can't seem to enter more
>than 1 tab when in C++/Java mode (it does do the automatic indentation
>like when you're using if statements though). When in the "normal"
>text editing mode, I can't enter any tabs.
>
>Can anyone help?
>
>Thanks.

In those modes, the tab key is bound to a command which indents the
current line according to the program syntax.  You can insert a
literal tab character with
C-q TAB

CTRL-q is a prefix to insert the next character entered literally, not
to run the command bound to the key that generates that character.

Best,

-- 
Mike Slass

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

* Re: Tab problem
  2004-09-04 13:45 Tab problem Nick Chorley
  2004-09-05  2:09 ` Michael Slass
@ 2004-09-05  8:26 ` Juraj Kubelka
       [not found] ` <mailman.1551.1094373130.1998.help-gnu-emacs@gnu.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Juraj Kubelka @ 2004-09-05  8:26 UTC (permalink / raw)
  Cc: help-gnu-emacs


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

On So  4.zář 14:45, Nick Chorley wrote:
> I have a problem with Emacs which is that I can't seem to enter more 
> than 1 tab when in C++/Java mode (it does do the automatic indentation 
> like when you're using if statements though). When in the "normal" text 
> editing mode, I can't enter any tabs.
> 
> Can anyone help?
> 

Try C-q TAB. 

-- 
+ Juraj Kubelka ++++++++++++++++++++++++
+ emailto:Juraj.Kubelka at email.cz    +
+ jabber://cesta at jabber.cz          +
+ icq: 25932918                        +
+ www: http://cestikovo.com            +
+ GPG: http://cestikovo.com/cesta.keys +
++++++++++++++++++++++++++++++++ Cesta +

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 481 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] 8+ messages in thread

* Re: Tab problem
       [not found] ` <mailman.1551.1094373130.1998.help-gnu-emacs@gnu.org>
@ 2004-09-05 16:42   ` Nick Chorley
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Chorley @ 2004-09-05 16:42 UTC (permalink / raw)


Juraj Kubelka wrote:
> On So  4.zář 14:45, Nick Chorley wrote:
> 
>>I have a problem with Emacs which is that I can't seem to enter more 
>>than 1 tab when in C++/Java mode (it does do the automatic indentation 
>>like when you're using if statements though). When in the "normal" text 
>>editing mode, I can't enter any tabs.
>>
>>Can anyone help?
>>
> 
> 
> Try C-q TAB. 
> 

I got it fixed so I can just enter tabs with the tab key. Had to put 
"self-insert-command" in the key binding for the tab key. It involved 
editing .emacs in my home folder.

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

* Re: Tab problem
  2004-09-04 13:45 Tab problem Nick Chorley
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.1551.1094373130.1998.help-gnu-emacs@gnu.org>
@ 2004-09-06  9:58 ` Kai Grossjohann
       [not found] ` <mailman.1642.1094465086.1998.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 8+ messages in thread
From: Kai Grossjohann @ 2004-09-06  9:58 UTC (permalink / raw)


Nick Chorley <nick@nospam.xyphias.com> writes:

> I have a problem with Emacs which is that I can't seem to enter more 
> than 1 tab when in C++/Java mode (it does do the automatic indentation 
> like when you're using if statements though). When in the "normal" text 
> editing mode, I can't enter any tabs.

Can you show why you need it?  The responses you get might be
unexpected and might give you some insight in how to use Emacs better.

For example, if you wish to enter more tabs for indentation, then you
act against Emacs' syntax-driven indenting code.  Using syntax-driven
indentation is a most valuable tool in finding typos.  (A forgotten
"}" will show up real quick because after that "}" the indentation is
all wrong.)

As another example, if you wish to enter tabs to align code, then you
might be happy with marking the lines to align and then typing M-x
align RET.  This will produce things like:

    int   x        = 3;
    float longname = 3.14;

Cool, isn't it?

You can always type M-i to advance to the next tab stop.  Advancing to
the next tab stop does not always equate to inserting a tab character,
but it's related.

Kai

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

* Re: Tab problem
       [not found] ` <mailman.1642.1094465086.1998.help-gnu-emacs@gnu.org>
@ 2004-09-06 11:29   ` Nick Chorley
  2004-09-06 12:16     ` Kai Grossjohann
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Chorley @ 2004-09-06 11:29 UTC (permalink / raw)


Kai Grossjohann wrote:
> Nick Chorley <nick@nospam.xyphias.com> writes:
> 
> 
>>I have a problem with Emacs which is that I can't seem to enter more 
>>than 1 tab when in C++/Java mode (it does do the automatic indentation 
>>like when you're using if statements though). When in the "normal" text 
>>editing mode, I can't enter any tabs.
> 
> 
> Can you show why you need it?  The responses you get might be
> unexpected and might give you some insight in how to use Emacs better.
> 
> For example, if you wish to enter more tabs for indentation, then you
> act against Emacs' syntax-driven indenting code.  Using syntax-driven
> indentation is a most valuable tool in finding typos.  (A forgotten
> "}" will show up real quick because after that "}" the indentation is
> all wrong.)
> 
> As another example, if you wish to enter tabs to align code, then you
> might be happy with marking the lines to align and then typing M-x
> align RET.  This will produce things like:
> 
>     int   x        = 3;
>     float longname = 3.14;
> 
> Cool, isn't it?
> 
> You can always type M-i to advance to the next tab stop.  Advancing to
> the next tab stop does not always equate to inserting a tab character,
> but it's related.
> 
> Kai
> 
> 
> 
> 

It was mainly so I could put comments in without simply entering a load 
of spaces. Apart from that, well, I don't like the way it indents things 
like switch statements (ie. the case x: bits go right underneath the 
word switch, instead of being indented a bit, if you see what I mean). 
There were a few other things too, but I've got it sorted now.

Thanks though :).

Nick

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

* Re: Tab problem
  2004-09-06 11:29   ` Nick Chorley
@ 2004-09-06 12:16     ` Kai Grossjohann
  0 siblings, 0 replies; 8+ messages in thread
From: Kai Grossjohann @ 2004-09-06 12:16 UTC (permalink / raw)


Nick Chorley <nick@nospam.xyphias.com> writes:

> It was mainly so I could put comments in without simply entering a
> load of spaces.

Try to hit M-; when you want to enter a comment.  Also see the
variable comment-column.

> Apart from that, well, I don't like the way it indents things
> like switch statements (ie. the case x: bits go right underneath the 
> word switch, instead of being indented a bit, if you see what I mean). 

That is easy to configure.  First of all, there are different
indentation styles.  You can choose among them with C-c . I believe.
Perhaps one of them suits your coding style.

If not, then choose the one that's closest, then go to the first line
with wrong indentation, use C-c C-o to customize its indentation, then
reindent the line to see if it was right.

If you find an indentation style that's basically right except that
its indentation level is wrong (say it indents 5 inside curlies but
you want 3), then you can simply set c-basic-offset, using M-x
set-variable RET c-basic-offset RET 42 RET.

You can make those changes permanent by writing some small amount of
Lisp:

(defun nick-c-mode-setup ()
  (c-set-style "bla")
  (setq c-basic-offset 42)
  (c-set-offset 'frumple 'foo))
(add-hook 'c-mode-hook 'nick-c-mode-setup)

Similar for other modes, such as c++ or java, instead of c.

The "bla" comes from the C-c . key.

The frumple and foo come from C-c C-o.  You can find the right
c-set-offset statement by typing C-x ESC ESC and then navigating the
history with M-p/M-n.

The CC mode info file explains how to customize indentation much
better than I can.

In any case, imagine how wonderful it would be if you could go to any
unreadable bit of source code, merely hit C-x h C-M-\, and then it
would be indented the way you like!

Kai

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

* Re: Tab problem
  2004-09-05  2:09 ` Michael Slass
@ 2004-09-07 13:53   ` kgold
  0 siblings, 0 replies; 8+ messages in thread
From: kgold @ 2004-09-07 13:53 UTC (permalink / raw)


Nick Chorley <nick@nospam.xyphias.com> writes:

>I have a problem with Emacs which is that I can't seem to enter more
>than 1 tab when in C++/Java mode (it does do the automatic indentation
>like when you're using if statements though). When in the "normal"
>text editing mode, I can't enter any tabs.

If you want is to add tabs after the code and before comments, try:

(add-hook 'c-mode-common-hook
  (function (lambda ()
	(setq c-tab-always-indent nil)
)))

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

end of thread, other threads:[~2004-09-07 13:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-04 13:45 Tab problem Nick Chorley
2004-09-05  2:09 ` Michael Slass
2004-09-07 13:53   ` kgold
2004-09-05  8:26 ` Juraj Kubelka
     [not found] ` <mailman.1551.1094373130.1998.help-gnu-emacs@gnu.org>
2004-09-05 16:42   ` Nick Chorley
2004-09-06  9:58 ` Kai Grossjohann
     [not found] ` <mailman.1642.1094465086.1998.help-gnu-emacs@gnu.org>
2004-09-06 11:29   ` Nick Chorley
2004-09-06 12:16     ` Kai Grossjohann

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