From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: CPP indentation bikeshed (was: Emacs master build failing on RHEL 6.8) Date: Wed, 08 May 2019 13:16:07 -0400 Message-ID: References: <834l66jpty.fsf@gnu.org> <831s1ajo0w.fsf@gnu.org> <342C2B19-E4BB-40FE-B979-74B72FF96442@acm.org> <698f97fc-5034-5a82-247c-5d727af0135e@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="1962"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Mattias =?windows-1252?Q?Engdeg=E5rd?= , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 08 19:18:34 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 1hOQDB-0000M9-3k for ged-emacs-devel@m.gmane.org; Wed, 08 May 2019 19:18:33 +0200 Original-Received: from localhost ([127.0.0.1]:40600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOQDA-00006v-3w for ged-emacs-devel@m.gmane.org; Wed, 08 May 2019 13:18:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOQAt-0007ep-Hq for emacs-devel@gnu.org; Wed, 08 May 2019 13:16:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOQAs-0001VU-LU for emacs-devel@gnu.org; Wed, 08 May 2019 13:16:11 -0400 Original-Received: from mail01.iro.umontreal.ca ([132.204.25.201]:55038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hOQAs-0001VJ-E7 for emacs-devel@gnu.org; Wed, 08 May 2019 13:16:10 -0400 Original-Received: from mail01.iro.umontreal.ca (mail01.iro.umontreal.ca [127.0.0.1]) by mail01.iro.umontreal.ca (Postfix) with ESMTP id B29FF8940717 for ; Wed, 8 May 2019 13:16:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; h=content-type:content-type:mime-version:user-agent:in-reply-to :date:date:references:message-id:subject:subject:to:from:from; s=dkim; t=1557335768; x=1558199769; bh=X6UmWqVFvjf5Cn3SSIH4jKD8 wqSRWrfP1aPtoq0TybE=; b=ljP1PU3WSEdTOvIeOEOlag6fU55VF8AFASonrwXh QtvDRKMaJLW6F5uWbJmPSK1b7U4psx+dbS2uAipudtnBXT+h2KNzDqbC73h030xh sT/vgXi/FWDR8ya8ssE+wqINZ9XANwcjeB9e0tefOSpQsUrg/1gBwkzKNrkS/CyT 69QIwTgdXP13qPp83V/zVU8ausStEMOoABfpQ8CXJtLTPvKdBQN5Vqg2g2Y3WFi8 M3KSVKTdPbp2IqTx45z3vczS/aysN10k+P+DseavGxohucCGeM+h/xr6PmNX5UjN Cdlt6XIFWdCN6maVHHPTyokjW/V+iV83Qxr+h7mg+4oTsg== X-Virus-Scanned: amavisd-new at iro.umontreal.ca Original-Received: from mail01.iro.umontreal.ca ([127.0.0.1]) by mail01.iro.umontreal.ca (mail01.iro.umontreal.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lSFtQy8WzOa6 for ; Wed, 8 May 2019 13:16:08 -0400 (EDT) Original-Received: from alfajor (modemcable213.149-175-137.mc.videotron.ca [137.175.149.213]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4B86A8940705; Wed, 8 May 2019 13:16:08 -0400 (EDT) In-Reply-To: <698f97fc-5034-5a82-247c-5d727af0135e@cs.ucla.edu> (Paul Eggert's message of "Wed, 8 May 2019 08:57:17 -0700") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.201 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:236300 Archived-At: > That's correct. C89-and-later allows white space (but not comments) > before the leading "#" in a line. K&R C did not. Aha! So it comes from K&R! Thanks. >> It's common in style rules to mandate # at the left margin, but that >> always looked like superstition (or perverted aesthetics) to me. > Yes, that common style is often hard to read. It exists mostly because > of inertia. For example, by default cc-mode insists on jamming the "#" > on the left and I have been too lazy so far to fix that (at least it > should respect the already-existing style). FWIW, I find indentation such as the chunk below from coding.c: if (VECTORP (eol_type)) { /* Format of end-of-line decided by system. This is Qunix on Unix and Mac, Qdos on DOS/Windows. This has an effect only for external encoding (i.e., for output to file and process), not for in-buffer or Lisp string encoding. */ Lisp_Object system_eol_type = Qunix; #ifdef DOS_NT system_eol_type = Qdos; #endif to be philosophically wrong: CPP doesn't know anything about C's syntactic structure (such as {...} nesting), so its indentation should only pay attention to previous CPP statement and not surrounding C code. Basically, the way I see it, you have code from two different languages (C and CPP) that is interleaved (in completely arbitrary ways, not always obeying nesting) and indentation of one should not impact indentation of the other. E.g. the reverse situation is also something I wouldn't like: # ifdef FOO extern toto (); # else extern toto (int x); # endif As for jamming # to the left: I like to do that probably mostly out of habit, but I can rationalize it based on the argument that CPP is applied "outside" of the C execution, so CPP statement and "layed over" the text of the C source. Stefan