emacs-devel
[Top][All Lists]
Advanced

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

Re: Supporting tabs for indentation, spaces for alignment


From: Alan Mackenzie
Subject: Re: Supporting tabs for indentation, spaces for alignment
Date: Fri, 12 Apr 2019 15:54:42 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Ergus.

On Thu, Apr 11, 2019 at 12:24:05 +0200, Ergus wrote:
> Hi Alan:

> Very thanks for replying. I will try to implement your solution for now
> in my config.

> But I'm wondering if after 11 years, with much better machines, improved
> emacs with many new functionalities (most of them nothing to do with a
> text editor) and the constant growing of languages that uses cc-mode as
> a base (rust || C++>=11 for example).

> But also with new indentation styles (like the google's one which is
> by far the most popular package in melpa). 

> And this package which seems to work; so some experience already:

> https://github.com/jcsalomon/smarttabs

> And the increase in popularity of other editors/ides which use different
> policies (from vim, kdevelop, eclipse, notepad++, visual-studio-code);
> so a emacs user (like me) needs to attach and don't break the global
> project schema. Maybe it makes sense to think how to add other
> tab-indent-policies and styles in the c-indent-alist list. Even if they
> are not the defaults.

All of what you have just written is far more vague and abstract than
your previous posts.

Getting concrete again, my understanding (please correct me if I am
wrong) of what you are suggesting is: "continuation" CC Mode source
lines should be indented with tabs up to the indent position of the
"main" line, and spaces after that.  For some value of "continuation"
and "main" (see below).

This might not be all that difficult to implement.  First the
"continuation" CC Mode syntactic symbols (e.g. arglist-cont-nonempty)
will need to be firmly identified, and a list made of them, say
c-continuation-syntactic-symbols.

Then the writer of the CC Mode style will need to set a flag (which
might be called c-limit-indentation-tabs or something like that) to
non-nil in the style.  Also she will need to set indent-tabs-mode to
non-nil.

At run time, if the main symbol in the syntactic context is a member of
c-continuation-syntactic-symbols, the column number of its anchor
position will be determined.  The CC Mode indenting function will not
permit the initial sequence of tabs to extend beyond this anchor
position, replacing such tabs with spaces beyond that point.

> So the users could find their needs without writing 40 lisp lines and
> read 20 manual pages full of therms that makes sense only after reading
> 1000 previous pages. Or needing to install an external package that
> potentially gets abandon.

I think you're exaggerating just a little bit; it was only 27 lines of
Lisp.  ;-)  But I take the point.  That workaround was only really
suitable for a Lisp hacker.

Have you any views on my above proposed strategy?

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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