groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/04: tmac/an-old.tmac: Enable adjustment control.


From: G. Branden Robinson
Subject: [groff] 01/04: tmac/an-old.tmac: Enable adjustment control.
Date: Fri, 21 Aug 2020 13:50:01 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit e7094b209f0f39fc16de687f116ea9a9c1ba0364
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Aug 22 01:37:28 2020 +1000

    tmac/an-old.tmac: Enable adjustment control.
    
    Some people really hate full justification in man pages.  Some man pages
    turn it off in their sources (VERY BAD, DON'T DO THAT).  mandoc man(1)
    doesn't bother with it.  man-db's man(1) supports an --nj option to
    switch it off by injecting an ".ad l" into the stream before handing a
    page to groff, which may relieve some temptation on the part of page
    authors to do so; the option is fine but the mechanism is a bit of a
    hack.
    
    I don't mind full justification myself except when diffing changes to
    man pages when working on them.  If I change the line count by an odd
    number, the adjustment parity gets thrown off[1] often leading to huge
    amounts of false diff content.  I've been getting by with running "man
    -l --nj", but that uses the system's groff tmac files and not the ones
    in a build.  If an-{old,ext}.tmac deviates from the installed version,
    as it has now, this risks the developer overlooking problems caused by
    the intersection of page content and macro package changes. (It happened
    to me...)
    
    Therefore, support a new AD string for setting the adjustment mode of
    man pages.  Follow classic Unix principles of configuration priority:
    
    (1) If a command-line option is given, use it.
    (2) [Honor user-specific configuration settings.  This is possible with
    a well-written man.local, but not yet feasible to ship as a default;
    see commit message to 499b9f21efd10eb57903cd0a1ea229ef7da23834.]
    (3) Honor a system-wide configuration setting.  That's man.local.
    (4) Use a within-package default.
    
    (If environment variables were applicable, they'd fall between 1 and 2
    above.)
    
    * tmac/an-old.tmac (TH): Set adjustment to user preference with each new
      page rendered, in case a hostile page meddled with '.ad' or '.na'.
    
      (after .mso man.local): Set the default adjustment mode only if a -d
      option or man.local did not.  Also do the same for the HF string;
      relocate its definition here and make it similarly conditional.  Also
      update comment on setting of CS and CT registers and style their
      conditionals consistently with the rest of the package.
    
    [1] groff sets type with justification spacing added to the left or
        right on alternating output lines, to prevent "rivers" in the page.
---
 tmac/an-old.tmac | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index a792e54..3a73810 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -81,9 +81,6 @@
 .
 .nr FT (-.5i)
 .
-.\" Default heading font
-.ds HF B\"
-.
 .nr an-first 1
 .
 .nr an-html 0
@@ -164,6 +161,9 @@
 .  vs \\n[VS]u
 .  ll \\n[LL]u
 .
+.  \" Restore parameters that a previous man page might have messed up.
+.  ad \\*[AD]
+.
 .\" We must select an integer indentation value for nroff;
 .\" see comment in an-do-tag.
 .  if !r IN \{\
@@ -686,9 +686,21 @@
 .\" Load local modifications.
 .mso man.local
 .
-.\" Set CS and CT if and only if man.local did not.
-.if !r CS .nr CS 0
-.if !r CT .nr CT 0
+.\" Determine page title and section heading full-capitalization if and
+.\" only if -r options or man.local did not.
+.if !r CS \
+.  nr CS 0
+.
+.if !r CT \
+.  nr CT 0
+.
+.\" Set the default adjustment mode and heading font only if -d options
+.\" or man.local did not.
+.if !d AD \
+.  ds AD b\"
+.
+.if !d HF \
+.  ds HF B\"
 .
 .cp \n[*groff_an-old_tmac_C]
 .



reply via email to

[Prev in Thread] Current Thread [Next in Thread]