public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "onf" <onf@disroot.org>
To: "G. Branden Robinson" <g.branden.robinson@gmail.com>,
	"Alejandro Colomar" <alx@kernel.org>
Cc: <linux-man@vger.kernel.org>,
	"Jason Yundt" <jason@jasonyundt.email>, <groff@gnu.org>
Subject: Re: [PATCH v1] CONTRIBUTING.d/style/c: Add coding style for the example programs
Date: Sun, 09 Feb 2025 03:20:06 +0100	[thread overview]
Message-ID: <D7NK0L9YCTEA.GUG1NL6I5YZP@disroot.org> (raw)
In-Reply-To: <20250208234619.a3zfan43cawwhae2@illithid>

Hi Branden & Alex,

On Sun Feb 9, 2025 at 12:46 AM CET, G. Branden Robinson wrote:
> [...]
> At 2025-02-08T23:57:07+0100, Alejandro Colomar wrote:
> > On Sat, Feb 08, 2025 at 11:44:43PM +0100, Alejandro Colomar wrote:
> > > Personally, I prefer tabs for actual programming.  But for manual
> > > pages, we can live with 4 spaces for $reasons.
> > > 
> > 
> > [...]
> > 
> > > +Description
> > > +    Indentation
> > > +	Use 4 spaces.  Ideally, tabs would be preferred; however, they
> > > +	cause 5 spaces in manual pages, which is weird, so we use 4
> > > +	spaces.
> > 
> > On a side note, Branden, I've considered changing the manual pages'
> > EXAMPLES' source code to use tabs, and let the formatter do whatever
> > it wants.  Do you have any opinion on that?
>
> The behavior of input tab characters is well-defined in *roff, but
> defined _weirdly_ to most people's sensibilities when filling is
> enabled.  I won't quote the documentation here, merely point to it.
>
> https://www.gnu.org/software/groff/manual/groff.html.node/Tabs-and-Leaders.html
> [...]

TL;DR:
With the default settings, a tab essentially translates into a
horizontal motion. What this means is that when filling is on
and you have text like this:
  int main(int argc, char **argv) {
  \tif (argc != 2 || strcmp(argv[1], "-h") == 0) {
  \t\tfprintf(stderr, usage, argv[0]);
  \t\treturn argc != 2;
  \t}
  \treturn 0;
  }

it ends up like this:
  int  main(int  argc, char **argv) {         if (argc != 2 || str‐
  cmp(argv[1], "‐h") == 0) {                 fprintf(stderr, usage,
  argv[0]);                 return argc != 2;         }         re‐
  turn 0; }

This is because tab stops are related to the beginning of a paragraph
rather than the beginning of an output line as one would expect.

The desired behavior can be enabled with the request .linetabs,
but this is groff-specific and not supported by other troffs.

~ onf

  parent reply	other threads:[~2025-02-09  2:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-08 22:44 [PATCH v1] CONTRIBUTING.d/style/c: Add coding style for the example programs Alejandro Colomar
2025-02-08 22:57 ` Alejandro Colomar
2025-02-08 23:46   ` G. Branden Robinson
2025-02-08 23:59     ` Alejandro Colomar
2025-02-09  0:45       ` G. Branden Robinson
2025-02-09  9:45         ` Alejandro Colomar
2025-02-09  2:20     ` onf [this message]
2025-02-17 20:24 ` Günther Noack
2025-02-17 22:16   ` Alejandro Colomar
2025-02-17 22:35     ` G. Branden Robinson
2025-02-17 23:03       ` Alejandro Colomar

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=D7NK0L9YCTEA.GUG1NL6I5YZP@disroot.org \
    --to=onf@disroot.org \
    --cc=alx@kernel.org \
    --cc=g.branden.robinson@gmail.com \
    --cc=groff@gnu.org \
    --cc=jason@jasonyundt.email \
    --cc=linux-man@vger.kernel.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox