does anyone know how to setup emacs so that the tab key do indentation
as usual but never insert any space?
recently i discovered Microsoft Visual Studio takes that approach.
Also, Google Go language has a mechanical means to force all
indentation to be tabs.
On Tuesday, February 28, 2012 2:28:27 AM UTC-6, Xah Lee wrote:
> On Feb 27, 2:21 am, hjuvi <hjuvi-goo...@yahoo.fr> wrote:
> > Add this line in your ~/.emacs:
> > (setq-default indent-tabs-mode t)
On Tuesday, 28 February 2012 16:28:27 UTC+8, Xah Lee wrote:
> On Feb 27, 2:21 am, hjuvi <hjuvi-goo...@yahoo.fr> wrote:
> > Add this line in your ~/.emacs:
> > (setq-default indent-tabs-mode t)
> that gives you mixed tabs and spaces.
You may need to set tab-width to the basic indentation step that you require. Default is 8.
On Feb 26, 9:35 pm, Xah Lee <xah...@gmail.com> wrote:
> does anyone know how to setup emacs so that the tab key do indentation
> as usual but never insert any space?
> recently i discovered Microsoft Visual Studio takes that approach.
> Also, Google Go language has a mechanical means to force all
> indentation to be tabs.
On Feb 28, 11:09 am, stan <smo...@exis.net> wrote:
> Do you want all spaces or are you suggesting some hidden code that
> knows how to indent?
In gnu.emacs.help Xah Lee <xah...@gmail.com> wrote:
> does anyone know how to setup emacs so that the tab key do indentation
> as usual but never insert any space?
In elisp, no chance, unless you set tab-width to 1. ;-)
In C-like languages, set tab-width and c-basic-offset to be the same, and
set entries in c-offsets-alist to indent only in multiples of
c-basic-offset.
In other language modes it is surely possible and easy.
> recently i discovered Microsoft Visual Studio takes that approach.
> Also, Google Go language has a mechanical means to force all
> indentation to be tabs.
> Xah
thanks coming to the rescue. Of all the people, am thinking you are
the top expert i know of on this.
Xah Lee wrote:
«does anyone know how to setup emacs so that the tab key do
indentation as usual but never insert any space?»
Alan Mackenzie wrote:
« In elisp, no chance, unless you set tab-width to 1. ;-)»
aww. Sad.
Alan wrote:
«In C-like languages, set tab-width and c-basic-offset to be the same,
and set entries in c-offsets-alist to indent only in multiples of c-
basic-offset.»
Cool. I'll try to see if i can get that to work in perl and python
mode. Not a need, but been wanting to experiment on this for long.
really wanted for elisp mode but too bad.
Btw, is there one place that document/tutorial in detail perhaps with
clarity on all the indentation related settings for c-mode? e.g. if i
want X style, do this and that, if i want Y style, do that and this.
>> does anyone know how to setup emacs so that the tab key do indentation
>> as usual but never insert any space?
> In elisp, no chance, unless you set tab-width to 1. ;-)
Actually, you might be able to get some major gross hack working in 99%
of the programming language modes by advising indent-to along the lines
of:
Of course, one major hurdle will be to make this advice actually active,
because indent-to has its own byte-code (yup, as if this was
a performance-sensitive operation), so all uses of indent-to from .elc
files will happily ignore the advice.
Xah Lee wrote:
> «does anyone know how to setup emacs so that the tab key do
> indentation as usual but never insert any space?»
> Alan Mackenzie wrote:
> « In elisp, no chance, unless you set tab-width to 1. ;-)»
> aww. Sad.
Are you actually concerned with how emacs does indent or the final
stored results? What I mean is would an external filter work? You're
only concerned about the leading tabs (indentation) and not all tabs
anywhere in a line right?
> Xah Lee wrote:
> ?does anyone know how to setup emacs so that the tab key do
> indentation as usual but never insert any space??
> Alan Mackenzie wrote:
> ? In elisp, no chance, unless you set tab-width to 1. ?;-)?
> aww. Sad.
> Alan wrote:
> ?In C-like languages, set tab-width and c-basic-offset to be the same,
> and set entries in c-offsets-alist to indent only in multiples of c-
> basic-offset.?
> Cool. I'll try to see if i can get that to work in perl and python
> mode. Not a need, but been wanting to experiment on this for long.
> really wanted for elisp mode but too bad.
> Btw, is there one place that document/tutorial in detail perhaps with
> clarity on all the indentation related settings for c-mode? e.g. if i
> want X style, do this and that, if i want Y style, do that and this.
It's all in the CC Mode manual. ;-) In the chapter "Customizing
Indentation".
Xah Lee <xah...@gmail.com> writes:
> Xah Lee wrote:
> «does anyone know how to setup emacs so that the tab key do
> indentation as usual but never insert any space?»
> Alan Mackenzie wrote:
> « In elisp, no chance, unless you set tab-width to 1. ;-)»
> aww. Sad.
Not really; it's not *impossible*, but it requires agreeing on the
display width of a tab. In my experience, that's a major task even in
all-vi shops. It's a little harder in emacs because so many emacs
programmers have swung away from even trying to agree on tab widths; but it's a political battle more than a technical one, and I'd rather
not waste my time on political battles in how to save source code.
> Alan wrote:
> «In C-like languages, set tab-width and c-basic-offset to be the same,
> and set entries in c-offsets-alist to indent only in multiples of c-
> basic-offset.»
> Cool. I'll try to see if i can get that to work in perl and python
> mode. Not a need, but been wanting to experiment on this for long.
> really wanted for elisp mode but too bad.
Well, that depends on what you want the indentation to actually
look like. My own indentation for elisp is (admittedly) a little
idiosyncratic, but even I can't imagine finding elisp readable
with indentations that were limited to multiples of something
larger than 1. I'd probably need to see a specific example to
understand the underlying principles.
> Btw, is there one place that document/tutorial in detail perhaps with
> clarity on all the indentation related settings for c-mode? e.g. if i
> want X style, do this and that, if i want Y style, do that and this.
Don't use styles for C-related modes. They are useful for imitating
someone else's style, not for creating your own. Once you have
indentation doing what you want, you can define a *new* style with the
settings you want.