[Top][All Lists]

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

Re: Is c-indent-line-or-region already doing the same thing as smart-tab

From: Alan Mackenzie
Subject: Re: Is c-indent-line-or-region already doing the same thing as smart-tabs?
Date: Thu, 02 Jun 2016 15:21:29 -0000
User-agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.3-RELEASE (amd64))

Hello, John.

john smith <address@hidden> wrote:
> In Emacs 24.5.1 is c-indent-line-or-region already doing the same
> thing as smart-tabs or do I miss something?  As I tried this snippet
> from

>     int f(int x,
>     int y) {
>     return g(x,
>     y);
>     }

> I got exactly same result when marking the whole function and pressing
> Tab key regardless of smart-tabs-mode state.  It seems that
> c-indent-line-or-region can add both spaces and tabs on its own.  Is
> my thinking correct?

Sort of, I think.  C Mode can certainly add both spaces and tabs when
indent-tabs-mode is non-nil.  Whether it will do exactly the same as
smart-tabs-mode depends on your CC Mode configuration, and possibly your
smart-tabs-mode configuration (if that mode can, in fact, be configured).

An easy way to get a glimpse of your CC Mode configuration is to put
point on a line of text and type C-c C-o.  It will prompt you with
something like:

    Syntactic symbol to change: arglist-cont-nonempty

.  arglist-cont-nonempty is the "syntactic symbol" of the line.  Hit
<CR>.  It will tell you that the "offset" for arglist-cont-nonempty is
something like:

    (c-lineup-gcc-asm-reg c-lineup-arglist)

.  This is a list with two elements, both of which are functions.  The CC
Mode indentation engine first tries (and fails) #'c-lineup-gcc-asm-reg,
then tries (and succeeds with) #'c-lineup-arglist.

To find further details of this mechanism, have a look at chapters
"Indentation Engine Basics" and "Customizing Indentation", together with
their sections and subsections, in the CC Mode manual.

> Are smart-tabs needed for other other modes apart from C?

That depends entirely on what you want to do.  (Sorry for that non-answer
- what it really means is "I don't know" ;-).

I think the fact that you got the same results in C Mode with
smart-tabs-mode enabled and disabled is a bit of a coincidence - CC Mode
can certainly be configured to do what smart-tabs-mode says it does.

Disclaimer: I know a fair bit about CC Mode, but only came across
smart-tabs-mode this afternoon as a result of reading your post.

> -- 
> <address@hidden>

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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