[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indentation, setting variables, commands, and M-x
From: |
Alan Mackenzie |
Subject: |
Re: indentation, setting variables, commands, and M-x |
Date: |
Fri, 3 Feb 2006 08:54:28 +0000 |
User-agent: |
tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) |
John M. Gabriele <john_sips_teaz@yahooz.com> wrote on Fri, 03 Feb 2006
00:18:20 -0500:
> Hi, I've just started to learn emacs, and would like to try using it as
> my primary editor/IDE, but first need to get a few things set up. For
> one thing, the indentation issue.
> I'd like to only get spaces in my files, 4 for each level of
> indentation, and also have the autoindent work (filling in spaces as
> necessary). That is, when I hit the TAB key, I want to get enough
> spaces to the next indent-level, filling in spaces along the way.
This is an absolutely standard setup for Emacs. You're in good company!
Actually, TAB doesn't indent to the next indent-level, it indents to the
_correct_ level, as determined by the syntax of the source code.[*] So
if you pressed TAB on the following line:
if (foo)
{
bar () ;
baz () ; <===== press TAB on this line
, you'd get this:
if (foo)
{
bar () ;
baz () ;
[*] If you really, really, really want TAB to indent to the _next_ level,
you can configure this.
> I just read here: http://www.emacswiki.org/cgi-bin/wiki/NoTabs
> that I can add this
> (setq-default indent-tabs-mode nil)
> to my .emacs file (which I haven't yet created). That page says
> I can "customize the indent-tabs-mode variable". What does that
> mean exactly? How do I go about "customizing" it?
A bit of background: your .emacs, your configuration file, is "just" a
file, and you can edit it like any other file. The best way to create it
is with C-x C-f <ret> ~/.emacs <ret>.
However, editing .emacs means knowing at least a minimal amount of Lisp.
The "customization" facility is a form-based point-and-click interface
which changes your .emacs without you having to grok Lisp.
To "customize the indent-tabs-mode variable", you'd do this: M-x
customize-variable <ret> indent-tabs-mode <ret>. You then change the
fields on the form, finally clicking on <save-for-future-sessions>. This
writes something like "(setq-default indent-tabs-mode t)" into your
.emacs file, creating the file if necessary.
Note that you might find the customization form not as simple and
straightforward as you might expect.
> I'm also curious: what's the translation between adding the above line
> to my .emacs, and typing something in while editing (presumably "M-x
> something")? That is, if someone tells me a line to add to my .emacs
> file, how can I figure out how to do the same thing from within the
> editor while editing?
If you execute some Lisp whilst editing, its effect won't be saved for
future sessions. The simplest way to execute lisp is with M-: (that's
"meta-colon"; use "<escape> :" if your keyboard can't do M-:).
> Continuing with the indentation issue, I read here:
> http://www.emacswiki.org/cgi-bin/wiki/IndentationBasics that there's a
> number of "variables" I can set. I see "tab-width" there. Yay! That
> looks like what I want. :) But, again, how do I "set a variable" for
> emacs (both in my .emacs file, and live, while editing)?
Whilst editing: either M-x set-variable, or M-: (setq tab-width 4), or
use customize-variable. That's a matter of personal taste. For your
.emacs, either customize-variable, or write (setq-default tab-width 4)
directly into the file.
There is an extra complication with tab-width: it is a "buffer-local"
variable, i.e. when you set it, the setting only has effect in the
current buffer. To change the default, use `setq-default'. To change
the value in the current buffer, use `setq'.
> Regarding the autoindent, Reading here:
> http://www.emacswiki.org/cgi-bin/wiki/AutoIndentation it sounds like
> autoindent isn't something that comes free, but instead, to get it, you
> have to put a one-liner into your .emacs file. Seems like maybe
> something that should be default behaviour, no?
Autoindentation is enabled by default for programming modes like C Mode
and Emacs Lisp Mode.
> ---J
Have fun!
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
- indentation, setting variables, commands, and M-x, John M. Gabriele, 2006/02/03
- Re: indentation, setting variables, commands, and M-x, Eli Zaretskii, 2006/02/03
- Re: indentation, setting variables, commands, and M-x,
Alan Mackenzie <=
- Re: indentation, setting variables, commands, and M-x, Peter Dyballa, 2006/02/03
- RE: indentation, setting variables, commands, and M-x, Drew Adams, 2006/02/03
- Re: indentation, setting variables, commands, and M-x, john_sips_tea, 2006/02/03
- Re: indentation, setting variables, commands, and M-x, john_sips_tea, 2006/02/03
- Re: indentation, setting variables, commands, and M-x, Peter Dyballa, 2006/02/03
- Re: indentation, setting variables, commands, and M-x, Kevin Rodgers, 2006/02/06
- Re: indentation, setting variables, commands, and M-x, Peter Dyballa, 2006/02/06
- Message not available
- Prev by Date:
Re: indentation, setting variables, commands, and M-x
- Next by Date:
Re: indentation, setting variables, commands, and M-x
- Previous by thread:
Re: indentation, setting variables, commands, and M-x
- Next by thread:
Re: indentation, setting variables, commands, and M-x
- Index(es):