From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Supporting tabs for indentation, spaces for alignment Date: Fri, 12 Apr 2019 15:54:42 +0000 Message-ID: <20190412155442.GD4588@ACM> References: <20190411090223.GA5183@ACM> <20190411102405.vcwdygrz36cjt3ld@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="185316"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 12 17:55:43 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hEyWl-000m5R-CK for ged-emacs-devel@m.gmane.org; Fri, 12 Apr 2019 17:55:43 +0200 Original-Received: from localhost ([127.0.0.1]:39074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEyWk-0006UD-Ci for ged-emacs-devel@m.gmane.org; Fri, 12 Apr 2019 11:55:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEyVs-0006Sj-Mk for emacs-devel@gnu.org; Fri, 12 Apr 2019 11:54:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEyVr-0003NV-I2 for emacs-devel@gnu.org; Fri, 12 Apr 2019 11:54:48 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:51069 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1hEyVr-0003Mj-6Q for emacs-devel@gnu.org; Fri, 12 Apr 2019 11:54:47 -0400 Original-Received: (qmail 56848 invoked by uid 3782); 12 Apr 2019 15:54:44 -0000 Original-Received: from acm.muc.de (p4FE15D0C.dip0.t-ipconnect.de [79.225.93.12]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 12 Apr 2019 17:54:44 +0200 Original-Received: (qmail 26582 invoked by uid 1000); 12 Apr 2019 15:54:42 -0000 Content-Disposition: inline In-Reply-To: <20190411102405.vcwdygrz36cjt3ld@Ergus> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235348 Archived-At: 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).