From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Is c-indent-line-or-region already doing the same thing as smart-tabs?
Date: Tue, 17 May 2016 16:09:23 +0000 (UTC) [thread overview]
Message-ID: <nhffnj$18au$1@colin.muc.de> (raw)
In-Reply-To: mailman.2860.1463347193.7477.help-gnu-emacs@gnu.org
Hello, John.
john smith <wempwer@gmail.com> 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 https://www.emacswiki.org/emacs/SmartTabs:
> 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.
> --
> <wempwer@gmail.com>
--
Alan Mackenzie (Nuremberg, Germany).
next parent reply other threads:[~2016-05-17 16:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2860.1463347193.7477.help-gnu-emacs@gnu.org>
2016-05-17 16:09 ` Alan Mackenzie [this message]
2016-05-15 21:19 Is c-indent-line-or-region already doing the same thing as smart-tabs? john smith
2016-05-18 18:13 ` john smith
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='nhffnj$18au$1@colin.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.