groff-commit
[Top][All Lists]
Advanced

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

[groff] 09/11: tmac/an-old.tmac: Refactor two-font macros.


From: G. Branden Robinson
Subject: [groff] 09/11: tmac/an-old.tmac: Refactor two-font macros.
Date: Mon, 17 May 2021 23:02:49 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 5472eae0961de845b69d8b3f87bcf51bf53e8967
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 18 12:45:20 2021 +1000

    tmac/an-old.tmac: Refactor two-font macros.
    
    * tmac/an-old.tmac: Refactor alternating font macros.  These macros are
      hard enough to understand without adding gratuitous structural
      differences to the reader's burden.  Make their implementations
      rigidly parallel.  Update comments.
    
      (RI, IR, IB, BI, RB, BR): Always define the `an-result` string as
      empty except for a non-printing input break for the sake of
      compatibility mode.
    
      (RI, IR, IB, BI): Defer interpolation of the first argument to the
      while loop if there are at least two (like the existing RB, BR).  This
      way the the font escape style names in the appendment to `an-result`
      match the order of the letters in the macro name (useful to make sense
      of diffs).
    
      (RI, IR, IB, BI, RB, BR): Always remove the `an-result` string after
      interpolating it.
    
      (RB, BR): Only do work if there are any arguments.
---
 ChangeLog        | 18 ++++++++++++
 tmac/an-old.tmac | 90 ++++++++++++++++++++++++++++++--------------------------
 2 files changed, 66 insertions(+), 42 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 38dee9c..d675231 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2021-05-18  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       * tmac/an-old.tmac: Refactor alternating font macros.  These
+       macros are hard enough to understand without adding gratuitous
+       structural differences to the reader's burden.  Make their
+       implementations rigidly parallel.  Update comments.
+       (RI, IR, IB, BI, RB, BR): Always define the `an-result` string
+       as empty except for a non-printing input break for the sake of
+       compatibility mode.
+       (RI, IR, IB, BI): Defer interpolation of the first argument to
+       the while loop if there are at least two (like the existing RB,
+       BR).  This way the the font escape style names in the appendment
+       to `an-result` match the order of the letters in the macro name
+       {useful to make sense of diffs}.
+       (RI, IR, IB, BI, RB, BR): Always remove the `an-result` string
+       after interpolating it.
+       (RB, BR): Only do work if there are any arguments.
+
+2021-05-18  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [man]: Apply italic corrections more consistently.
 
        * tmac/an-old.tmac (BI, IB, IR, RI): Apply italic corrections
diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index 735bb7d..35c9846 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -513,13 +513,24 @@
 .  ns
 ..
 .
+.\"
+.\" Alternating font macros
+.\" -----------------------
+.\"
+.\" Implementation notes:
+.\"
+.\" We always emit a non-printing input break \& before the first
+.\" argument.  This is necessary only when the calling man page is in
+.\" compatibility mode; it works around the surprising AT&T semantics of
+.\" \f escapes at the beginning of an input line.  See "Implementation
+.\" differences" in groff_diff(7) or the groff Texinfo manual.
+.\"
 .\" The italic correction escapes can be visually confusing.  We apply
 .\" the following rules, always on the same input line.
 .\"   (1) Before any italic argument, emit a left italic correction \,
 .\"       before switching to the italic style.
 .\"   (2) After any italic argument, emit an italic correction \/
 .\"       before switching to another style.
-.\"
 .\" It is true that these macros cannot know what style is used in the
 .\" input stream before or after they are called.  We can make
 .\" assumptions based on pragmatics.  In most cases, the caller will not
@@ -533,30 +544,19 @@
 .\" caller would simply have added the relevant characters to the
 .\" arguments of the macro call.
 .\"
-.\" Unrelatedly,
-.\"   (3) Emit a non-printing input break \& before the first argument.
-.\"       This is necessary only when the calling man page is in
-.\"       compatibility mode; it works around the surprising AT&T
-.\"       semantics of \f escapes at the beginning of an input line.
-.\"       See "Implementation differences" in groff_diff(7) or the groff
-.\"       Texinfo manual.)
-.\"   (4) Prefix the string argument to an 'as' request with a double
-.\"       quote (") if it begins with a macro argument interpolation
-.\"       (which might start with a space).  (This would apply to 'ds'
-.\"       as well but for item (3) above.)
 .
 .de1 RI
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
 .  if \\n[.$] \{\
-.    ds an-result \&\f[R]\\$1\"
-.    shift
+.    ds an-result \&\"
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \,\f[I]\\$1\/\f[R]\\$2\"
+.      as an-result \f[R]\\$1\,\f[I]\\$2\/\"
 .      shift 2
 .    \}
-.    if \\n[.$] .as an-result \,\f[I]\\$1\/\"
+.    if \\n[.$] .as an-result \f[R]\\$1\"
 \\*[an-result]
+.    rm an-result
 .    ft R
 .  \}
 ..
@@ -565,14 +565,14 @@
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
 .  if \\n[.$] \{\
-.    ds an-result \&\,\f[I]\\$1\/\f[R]\"
-.    shift
+.    ds an-result \&\"
 .    while (\\n[.$] >= 2) \{\
-.      as an-result "\\$1\,\f[I]\\$2\/\f[R]\"
+.      as an-result \,\f[I]\\$1\/\f[R]\\$2\"
 .      shift 2
 .    \}
-.    if \\n[.$] .as an-result "\\$1\"
+.    if \\n[.$] .as an-result \,\f[I]\\$1\/\"
 \\*[an-result]
+.    rm an-result
 .    ft R
 .  \}
 ..
@@ -581,14 +581,14 @@
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
 .  if \\n[.$] \{\
-.    ds an-result \&\,\f[I]\\$1\/\"
-.    shift
+.    ds an-result \&\"
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \f[B]\\$1\,\f[I]\\$2\/\"
+.      as an-result \,\f[I]\\$1\/\f[B]\\$2\"
 .      shift 2
 .    \}
-.    if \\n[.$] .as an-result \f[B]\\$1\"
+.    if \\n[.$] .as an-result \,\f[I]\\$1\/\"
 \\*[an-result]
+.    rm an-result
 .    ft R
 .  \}
 ..
@@ -597,14 +597,14 @@
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
 .  if \\n[.$] \{\
-.    ds an-result \&\f[B]\\$1\"
-.    shift
+.    ds an-result \&\"
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \,\f[I]\\$1\/\f[B]\\$2\"
+.      as an-result \f[B]\\$1\,\f[I]\\$2\/\"
 .      shift 2
 .    \}
-.    if \\n[.$] .as an-result \,\f[I]\\$1\/\"
+.    if \\n[.$] .as an-result \f[B]\\$1\"
 \\*[an-result]
+.    rm an-result
 .    ft R
 .  \}
 ..
@@ -612,27 +612,33 @@
 .de1 RB
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
-.  ds an-result \&\"
-.  while (\\n[.$] >= 2) \{\
-.    as an-result \f[R]\\$1\f[B]\\$2\"
-.    shift 2
-.  \}
-.  if \\n[.$] .as an-result \f[R]\\$1\"
+.  if \\n[.$] \{\
+.    ds an-result \&\"
+.    while (\\n[.$] >= 2) \{\
+.      as an-result \f[R]\\$1\f[B]\\$2\"
+.      shift 2
+.    \}
+.    if \\n[.$] .as an-result \f[R]\\$1\"
 \\*[an-result]
-.  ft R
+.    rm an-result
+.    ft R
+.  \}
 ..
 .
 .de1 BR
 .  if (\\n[.$] < 2) \
 .    an-style-warn .\\$0 expects at least 2 arguments, got \\n[.$]
-.  ds an-result \&\"
-.  while (\\n[.$] >= 2) \{\
-.    as an-result \f[B]\\$1\f[R]\\$2\"
-.    shift 2
-.  \}
-.  if \\n[.$] .as an-result \f[B]\\$1\"
+.  if \\n[.$] \{\
+.    ds an-result \&\"
+.    while (\\n[.$] >= 2) \{\
+.      as an-result \f[B]\\$1\f[R]\\$2\"
+.      shift 2
+.    \}
+.    if \\n[.$] .as an-result \f[B]\\$1\"
 \\*[an-result]
-.  ft R
+.    rm an-result
+.    ft R
+.  \}
 ..
 .
 .de1 RS



reply via email to

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