public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: groff <groff@gnu.org>, Ingo Schwarze <schwarze@usta.de>,
	linux-man@vger.kernel.org
Subject: Re: MR macro 4th argument (was: [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters)
Date: Fri, 11 Nov 2022 00:55:18 +0100	[thread overview]
Message-ID: <8f7162fd-cefb-dc31-cb0f-ba4b76ca5011@gmail.com> (raw)
In-Reply-To: <20221110225524.hiojzgiiid5d3k65@illithid>


[-- Attachment #1.1: Type: text/plain, Size: 7194 bytes --]

Hi Branden,

On 11/10/22 23:55, G. Branden Robinson wrote:
> Hi Alex,
> 
> At 2022-11-10T19:04:46+0100, Alejandro Colomar wrote:
>> Of course I forgot to rename the title, and to agg groff@.  Nice.
> 
> It gave me time to reply to this one.  :)

:)

[...]

>> The big issue is that your MR doesn't support leading text:
>>
>>          .MR page‐title manual‐section [trailing‐text]
>>
>> I remember we had this discussion about what to do with it.  A 4th
>> argument?  There's also conflict with a hypothetical link that we
>> might want to add later.
>>
>> My opinion is that the 4th argument should be the leading text.
>> Asking to use the escape (was it \c?) sequence to workaround that
>> limitation is not very nice.   Especially for scripting the change.
> 
> Here's what I did for groff.
> 
> commit 2ab0dacb95863a2e347d06cf970676c74c784ce2
> Author: G. Branden Robinson <g.branden.robinson@gmail.com>
> Date:   Fri Oct 8 00:46:41 2021 +1100
> 
>      [man pages]: Migrate man(7) cross refs to `MR`.
> 
>       # Handle simplest case: ".IR foo (1)".
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\(@MAN[157]EXT@\))$/.MR \2 \3/
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\([1-8a-z]\+\))$/.MR \2 \3/
>       # Handle case: trailing puncutation, e.g., ".IR foo (1),".
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\(@MAN[157]EXT@\))\([^[:space:]]\+\)/.MR \2 \3 \4/
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\([1-8a-z]\+\))\([^[:space:]]\+\)/.MR \2 \3 \4/
>       # Handle case: 3rd+ arguments or trailing comments.  This case is rare
>       # and will require manual fixup if there are 4+ arguments to MR.  Use
>       # groff -man -rCHECKSTYLE=1 to have them automatically reported.
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\(@MAN[157]EXT@\))\( .*\)/.MR \2 \3\4/
>      s/^.[BI]R \(\\%\)*\([@_[:alnum:]\\-]\+\) (\([1-8a-z]\+\))\( .*\)/.MR \2 \3\4/
> 
> You can ignore the 'MAN[157]EXT' lines; they are relevant only to
> within-groff pages (because all of our man pages undergo sed-processing
> to be prepared for installation).

Hmm, will need to parse that.  Anyway, I think now that I have the MR with 4 
arguments, moving the 4th to the previous line with sed and N should not be that 
difficult.

> 
>> If you want a 5th argument for a URI, you can specify the leading text
>> as "", which is not much of an issue.  And you keep the trailing text
>> and the leading one together.
>>
>> What are your thoughts?  What should we do?
> 
> I am reluctant to extend the interface of `MR` at this point because as
> it is it has two nice properties: it aligns with mdoc(7)'s `Xr` macro
> and with Plan 9 from User Space troff's `MR`, which did it first.

Well, being a compatible extension to the others is not that bad.  How does 
mdoc(7) solve it with Xr?

> 
> (Admittedly, P9US troff's `MR` macro doesn't supply the parentheses.  I
> don't know if they intend to change that.  I'm willing to supply a patch
> to change their implementation and their man pages to align with what I
> did in groff.  As shown above, I believe my sed-fu is in order.)
> 
> I think man page authors should learn when the `\c` escape sequence is
> appropriate and use it when warranted, and recast their sentences
> otherwise.  That is why I provided an explicit example in the
> groff_man_style(7) page.
> 
>      .MR page-title manual-section [trailing-text]
>          (since groff 1.23) Set a man page cross reference as "page-
>          title(manual-section)".  If trailing-text (typically
>          punctuation) is specified, it follows the closing parenthesis
>          without intervening space.  Hyphenation is disabled while the
>          cross reference is set.  page-title is set in the font specified
>          by the MF string.  The cross reference hyperlinks to a URI of
>          the form "man:page-title(manual-section)".
> 
>              The output driver
>              .MR grops 1
>              produces PostScript from
>              .I troff
>              output.
>              .
>              The Ghostscript program (\c
>              .MR gs 1 )
>              interprets PostScript and PDF.

One of the biggest issues with this is that it breaks what would otherwise 
represent a single entity, into two lines, so it hurts readability.  See as an 
extreme example the following change I did with my scripts (from posix_spawn(3), 
if you're curious):

@@ -129,7 +129,7 @@ .SH DESCRIPTION
  Below, the functions are described in terms of a three-step process: the
  .MR fork 3
  step, the
-.RB pre- exec ()
+.MR exec 3 "" pre-
  step (executed in the child),
  and the
  .MR exec 3


Having 'pre-' as the last part of some random line, separates it from the other 
part of the word.  The \c alternative would be:

step, the pre-
.MR exec 3
step ...


Not terrible, but I'm not in love with it.


> 
> `\c` solves problems that are complicated to solve any other way.  As
> far as I have seen, you don't ever need it in mdoc(7) pages, for
> example...but you pay a price.  You must learn which of mdoc's several
> dozen macros are "parsed" versus "callable" (and what the heck the
> package even _means_ by those words); you must learn that `Pf` and `Ns`
> exist and when to use them; you must learn that certain two-letter words
> will not behave as you expect; and if you thought using mdoc(7) meant
> you wouldn't have to type any groff escape sequences, think
> again--you'll be putting `\&` all over the place.
> 
> People can use mdoc(7) if they want to (and now that I'm learning it
> better, I will consult as I am able), but its reputation in some circles
> as a superior solution to man(7) on all fronts that should have kicked
> its predecessor into the grave long ago is due solely to irresponsible
> hype from its exponents.
> 
> If you need help automating a change to adapt some Linux man-pages
> documents to use `\c` before an `MR` call on the next line (where you
> were using `RB` before, for instance), just let know.  I am nearly
> certain that a sed script utilizing its hold space feature can get the
> job done.  (I've used the hold space profitably before, but occasions
> for it come up seldom enough that I have to review my past solutions
> before the knowledge comes back.  Or maybe it's creeping senescence.)

I hope I can come up with something, but yes, if not, I'll call you ;)

BTW, so far I've never found a case where I had to use the hold space.  I wonder 
if I may meet a case where I need it in my life.  This week I came up with some 
script for inserting an element into a JSON array at a specified position, but N 
is all that was needed:
<http://www.alejandro-colomar.es/src/alx/nginx/unitcli.git/tree/bin/setup-unit#n969>.
I've met a few more-complex cases, but not really that much.  I always come up 
with some combination of filters that allows me to avoid the hold space. 
Sometimes, two scripts run consecutively also helps keep it simple :)

Cheers,

Alex

> 
> Regards,
> Branden

-- 
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-11-10 23:55 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 21:07 [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters Alejandro Colomar
2022-08-27 11:10 ` Ingo Schwarze
2022-08-27 12:15   ` Alejandro Colomar
2022-08-27 13:08     ` Ingo Schwarze
2022-08-27 18:38       ` Alejandro Colomar
2022-08-28 11:24         ` Alejandro Colomar
     [not found]           ` <CACqA6+mfaj6Viw+LVOG=nE350gQhCwVKXRzycVru5Oi4EJzgTg@mail.gmail.com>
2022-09-02 21:02             ` Alejandro Colomar
2022-09-02 21:57               ` Alejandro Colomar
2022-09-03 12:47                 ` Martin Uecker
2022-09-03 13:29                   ` Ingo Schwarze
2022-09-03 15:08                     ` Alejandro Colomar
2022-09-03 13:41                   ` Alejandro Colomar
2022-09-03 14:35                     ` Martin Uecker
2022-09-03 14:59                       ` Alejandro Colomar
2022-09-03 15:31                         ` Martin Uecker
2022-09-03 20:02                           ` Alejandro Colomar
2022-09-05 14:31                             ` Alejandro Colomar
2022-11-10  0:06                           ` Alejandro Colomar
2022-11-10  0:09                             ` Alejandro Colomar
2022-11-10  1:33                             ` Joseph Myers
2022-11-10  1:39                               ` Joseph Myers
2022-11-10  6:21                                 ` Martin Uecker
2022-11-10 10:09                                   ` Alejandro Colomar
2022-11-10 23:19                                   ` Joseph Myers
2022-11-10 23:28                                     ` Alejandro Colomar
2022-11-11 19:52                                     ` Martin Uecker
2022-11-12  1:09                                       ` Joseph Myers
2022-11-12  7:24                                         ` Martin Uecker
2022-11-12 12:34                                     ` Alejandro Colomar
2022-11-12 12:46                                       ` Alejandro Colomar
2022-11-12 13:03                                       ` Joseph Myers
2022-11-12 13:40                                         ` Alejandro Colomar
2022-11-12 13:58                                           ` Alejandro Colomar
2022-11-12 14:54                                           ` Joseph Myers
2022-11-12 15:35                                             ` Alejandro Colomar
2022-11-12 17:02                                               ` Joseph Myers
2022-11-12 17:08                                                 ` Alejandro Colomar
2022-11-12 15:56                                             ` Martin Uecker
2022-11-13 13:19                                               ` Alejandro Colomar
2022-11-13 13:33                                                 ` Alejandro Colomar
2022-11-13 14:02                                                   ` Alejandro Colomar
2022-11-13 14:58                                                     ` Martin Uecker
2022-11-13 15:15                                                       ` Alejandro Colomar
2022-11-13 15:32                                                         ` Martin Uecker
2022-11-13 16:25                                                           ` Alejandro Colomar
2022-11-13 16:28                                                         ` Alejandro Colomar
2022-11-13 16:31                                                           ` Alejandro Colomar
2022-11-13 16:34                                                             ` Alejandro Colomar
2022-11-13 16:56                                                               ` Alejandro Colomar
2022-11-13 19:05                                                                 ` Alejandro Colomar
2022-11-14 18:13                                                           ` Joseph Myers
2022-11-28 22:59                                                             ` Alex Colomar
2022-11-28 23:18                                                       ` Alex Colomar
2022-11-29  0:05                                                         ` Joseph Myers
2022-11-29 14:58                                                         ` Michael Matz
2022-11-29 15:17                                                           ` Uecker, Martin
2022-11-29 15:44                                                             ` Michael Matz
2022-11-29 16:58                                                               ` Uecker, Martin
2022-11-29 17:28                                                                 ` Alex Colomar
2022-11-29 16:49                                                           ` Joseph Myers
2022-11-29 16:53                                                             ` Jonathan Wakely
2022-11-29 17:00                                                               ` Martin Uecker
2022-11-29 17:19                                                                 ` Alex Colomar
2022-11-29 17:29                                                                   ` Alex Colomar
2022-12-03 21:03                                                                     ` Alejandro Colomar
2022-12-03 21:13                                                                       ` Andrew Pinski
2022-12-03 21:15                                                                       ` Martin Uecker
2022-12-03 21:18                                                                         ` Alejandro Colomar
2022-12-06  2:08                                                                       ` Joseph Myers
2022-11-14 17:52                                                 ` Joseph Myers
2022-11-14 17:57                                                   ` Alejandro Colomar
2022-11-14 18:26                                                     ` Joseph Myers
2022-11-28 23:02                                                       ` Alex Colomar
2022-11-10  9:40                             ` G. Branden Robinson
2022-11-10 10:59                               ` Alejandro Colomar
2022-11-10 17:47                                 ` Alejandro Colomar
2022-11-10 18:04                                   ` MR macro 4th argument (was: [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters) Alejandro Colomar
2022-11-10 18:11                                     ` Alejandro Colomar
2022-11-10 18:20                                       ` Alejandro Colomar
2022-11-10 19:37                                     ` Alejandro Colomar
2022-11-10 20:41                                       ` Alejandro Colomar
2022-11-10 22:55                                     ` G. Branden Robinson
2022-11-10 23:55                                       ` Alejandro Colomar [this message]
2022-11-11  4:44                                         ` G. Branden Robinson
2022-11-10 22:25                                 ` [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters G. Branden Robinson

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=8f7162fd-cefb-dc31-cb0f-ba4b76ca5011@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=g.branden.robinson@gmail.com \
    --cc=groff@gnu.org \
    --cc=linux-man@vger.kernel.org \
    --cc=schwarze@usta.de \
    /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