unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: "Mattias Engdegård" <mattiase@acm.org>, emacs-devel@gnu.org
Subject: CPP indentation bikeshed (was: Emacs master build failing on RHEL 6.8)
Date: Wed, 08 May 2019 13:16:07 -0400	[thread overview]
Message-ID: <jwva7fwho6z.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <698f97fc-5034-5a82-247c-5d727af0135e@cs.ucla.edu> (Paul Eggert's message of "Wed, 8 May 2019 08:57:17 -0700")

> 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



  reply	other threads:[~2019-05-08 17:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 12:00 Emacs master build failing on RHEL 6.8 Kaushal Modi
2019-05-07 14:34 ` Eli Zaretskii
2019-05-07 14:41   ` Kaushal Modi
2019-05-07 15:13     ` Eli Zaretskii
2019-05-07 15:30       ` Stefan Monnier
2019-05-07 15:52         ` Eli Zaretskii
2019-05-07 16:01           ` Kaushal Modi
2019-05-07 18:22             ` Eli Zaretskii
2019-05-07 19:46               ` Kaushal Modi
2019-05-08  5:47                 ` Eli Zaretskii
2019-05-08  8:03                   ` Andreas Schwab
2019-05-08 11:42                   ` Kaushal Modi
2019-05-08 12:27                     ` Eli Zaretskii
2019-05-08 12:49                       ` Kaushal Modi
2019-05-08 13:05                         ` Eli Zaretskii
2019-05-08 15:07                           ` Kaushal Modi
2019-05-08 15:41                             ` Paul Eggert
2019-05-08 15:50                               ` Kaushal Modi
2020-02-14 19:49                                 ` WilliamKF
2020-02-14 20:44                                   ` Paul Eggert
2019-05-07 18:49         ` Mattias Engdegård
2019-05-08 15:57           ` Paul Eggert
2019-05-08 17:16             ` Stefan Monnier [this message]
2019-05-09  4:25               ` CPP indentation bikeshed (was: Emacs master build failing on RHEL 6.8) Paul Eggert
2019-05-07 17:37 ` Emacs master build failing on RHEL 6.8 martin rudalics
2019-05-07 18:20   ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwva7fwho6z.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=mattiase@acm.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).