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

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

Re: turning off all indentation


From: Andreas Politz
Subject: Re: turning off all indentation
Date: Wed, 08 Dec 2010 15:08:09 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Lynn Newton <lynn.newton@gmail.com> writes:

>> (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.
>
The author of cc-mode probably worked hours on this one.

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

This is easily fixed by finding the desired command (obviously not
`indent-for-tab-command').

> 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. And whenever he
> hits RETURN, he wants the cursor to go to column zero
> of the next line, period, no ifs ands or buts.

 Is this any different than simply inserting a tab character ?
 
 (global-set-key [tab] 'self-insert-command)
 
>
> 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.
>
> 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.

Yes, most.

I don't think a foolproof, automatic solution is worth the time. It
would have to examine all bound commands and make a guess about it
being on the blacklist (touching indentation) or not.

Also, unconditionally unbinding tab and return in all mode-maps would
break e.g. help-mode, where return follows a link.

Ask your friend how many modes he really uses. 5-10 ? Not to much for
manually configuration.

Supplementary the idea of a hot-button comes to mind, which your friend
can push and tell Emacs that the last command sucked.  At this point the
binding in the mode-map could be cleared, in order to make way for the
global one.

Or maybe installing an Emacs from a time where people, who wanted to
have full control over indentation, still constituted the majority.

-ap


reply via email to

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