all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: turning off all indentation
Date: Wed, 12 May 2010 19:11:16 +0000 (UTC)	[thread overview]
Message-ID: <hseugk$2pja$1@colin2.muc.de> (raw)
In-Reply-To: 81679436-5d3c-429c-bc39-7121f452d51b@d39g2000yqa.googlegroups.com

Hi, Lynn,

Lynn Newton <lynn.newton@gmail.com> wrote:
>> (add-hook 'after-change-major-mode-hook
>> ? ? ? ? ? (lambda nil
>> ? ? ? ? ? ? (local-set-key [return] nil)
>> ? ? ? ? ? ? (local-set-key [tab] nil)))

> With this, if I start up Emacs and start to edit a file myfile.c,
> I get this far:

> main()
> {
>        int i

> Pretend there's a tab in front of int. When I add a semicolon to that
> line, it backindents it to column 2 (counting from 0), which is what I
> meant about the local modes taking over.

To configure CC Mode not to this, turn off CC Mode's "electric mode", as
described on pages "Minor Modes" and  "Getting Started" in the CC Mode
manual.  Or, if you can't be bothered with the manual, stick this in your
.emacs:

    (setq-default c-electric-flag nil)

.  By default, <CR> just inserts a new line; it doesn't put any
indentation on the new line.

> If I edit a plain text file, e.g., myfile.txt or without an extension,
> a tab indents me only four spaces. If a line is indented more spaces,
> typing a tab on the line below indents the next line to whatever column
> the previous line is indented to.

It's actually cleverer than that; it indents the new line to the
syntactically right place.

> Mind you, I think that's clever and wonderful, but what my friend wants
> is whenever he presses a TAB key, in whatever mode, and in whatever
> context, it skips to the next 8-character tab stop, regardless of the
> mode, the position of the line above, etc.

There's no way of doing this for EVERY mode, because the modes don't
invoke indentation in the same way.  It can be done for _each_ mode in a
small finite set.  To make <TAB> insert a tab in CC Mode, put this into
your .emacs:

    (eval-after-load 'cc-mode
     '(define-key c-mode-base-map ?\C-i 'tab-to-tab-stop))

(not tested).

> And whenever he hits RETURN, he wants the cursor to go to column zero
> of the next line, period, no ifs ands or buts.

This should be happening by default anyway.  Might there be something in
his .emacs which binds <CR> to `newline-and-indent'?

> And I'm pretty sure that when he hits other keys, such as semicolons,
> curly brackets, and other syntactically significant characters within
> some given mode, he wants it *not* to change the alignment of the
> current line or any other line nearby.

See above for CC Mode.

> One would think that would be pretty easy to do, but the subtleties of
> various languages and accompanying modes are so thoroughly built in
> that it's hard to escape them.  Most people consider that a Good Thing.

:-)

-- 
Alan Mackenzie (Nuremberg, Germany).



  parent reply	other threads:[~2010-05-12 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d337ac07-d622-400f-9520-ac22ce0e4f86@k29g2000yqh.googlegroups.com>
2010-05-12 16:44 ` turning off all indentation Andreas Politz
     [not found]   ` <81679436-5d3c-429c-bc39-7121f452d51b@d39g2000yqa.googlegroups.com>
2010-05-12 19:11     ` Alan Mackenzie [this message]
2010-05-12 19:15     ` Lowell Gilbert
2010-05-12 19:59     ` Andreas Politz
     [not found] ` <87pr1145gl.fsf@lola.goethe.zz>
     [not found]   ` <a08c7e68-3949-41de-bdbf-5d4c81e377f9@d27g2000yqc.googlegroups.com>
2010-05-13  0:31     ` Tim X
2010-05-13 14:53       ` Scott Frazer

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

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

  git send-email \
    --in-reply-to='hseugk$2pja$1@colin2.muc.de' \
    --to=acm@muc.de \
    --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.
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.