gbranden pushed a commit to branch master
in repository groff.
commit 8c9b16df965c1f30041f7d8c4bbbb1159b67b3bd
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Apr 30 20:18:43 2026 -0500
tmac/an-ext.tmac: Relocate material.
Group all the macro definitions that don't conditionalize their
definitions on the value of the `mG` register before those that do.
---
ChangeLog | 21 ++++++++++++++++++
tmac/an-ext.tmac | 50 ++++++++++++++++++++++---------------------
tmac/an.tmac | 4 ++--
tmac/tests/an-ext_MR-works.sh | 4 ++--
4 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f39fdbc28..298bf1adc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2026-04-30 G. Branden Robinson <[email protected]>
+
+ [man]: Alter extension macro testing technique. What we had
+ wasn't working when copy-and-pasted into man pages formatted
+ with non-groff-compatible formatters. Now people copying these
+ macros can preserve or discard the lines with brace escape
+ sequences surrounding the macro definitions, or not, and things
+ should work either way.
+
+ * tmac/an.tmac: Initialize `mG` register to zero.
+ * tmac/an-ext.tmac: Invert sense of test when defining macros
+ that also have definitions in "tmac/an.tmac".
+ * tmac/tests/an-ext_MR-works.sh: Assign `mG` value of "1" when
+ testing the "an-ext.tmac" file's implementations of macros.
+
+2026-04-30 G. Branden Robinson <[email protected]>
+
+ * tmac/an-ext.tmac: Relocate material. Group all the macro
+ definitions that don't conditionalize their definitions on the
+ value of the `mG` register before those that do.
+
2026-04-30 G. Branden Robinson <[email protected]>
[troff]: Fix Savannah #68285.
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index fadf69c1e..cc91186da 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -23,12 +23,6 @@
.\"
.\" Convention: Auxiliary string, macros, and registers start with 'm'
.\" followed by an uppercase letter or digit.
-.\"
-.\" Setting the `mG` register to a positive value (e.g., on the command
-.\" line) enables usage of macros defined here that have alternative
-.\" definitions in the main groff man macro file. This is for testing.
-.\" The logic uses subtraction due to frustrating, AT&T troff-compatible
-.\" limitations on the '!' operator.
.
.
.\" Protect against being sourced twice.
@@ -120,6 +114,25 @@
..
.
.
+.\" Add supplementary paragraph tag on its own line after TP.
+.de TQ
+. br
+. ns
+. \" Do not quote the argument to `TP`; the user might specify
+. \" their own quotes for multi-word tags or to exercise AT&T troff
+. \" quoting rules.
+. TP \\$1\"
+..
+.
+.
+.\" Setting the `mG` register to "-1" (e.g., on the command line)
+.\" enables usage of macros defined here that have alternative
+.\" definitions in the main groff man macro file. This is for testing.
+.\" The logic uses subtraction due to frustrating, AT&T troff-compatible
+.\" limitations on the '!' operator.
+.nr mG +0
+.
+.
.\" Prepare link text for mail/web hyperlinks. `MT` and `UR` call this.
.de mV
. ds mU \\$1\"
@@ -139,7 +152,7 @@
.
.\" Start URL.
.\" .UR url
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de UR
. mV \\$1
..
@@ -148,7 +161,7 @@
.
.\" End URL.
.\" .UE [punctuation]
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de UE
. mQ \\$1
..
@@ -157,7 +170,7 @@
.
.\" Start email address.
.\" .MT address
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de MT
. mV \\$1
..
@@ -166,7 +179,7 @@
.
.\" End email address.
.\" .ME [punctuation]
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de ME
. mQ \\$1
..
@@ -175,7 +188,7 @@
.
.\" Set a man page cross reference.
.\" .MR page-topic page-section [trailing-text]
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de MR
. mY
. nh
@@ -188,22 +201,11 @@
.\}
.
.
-.\" Add supplementary paragraph tag on its own line after TP.
-.de TQ
-. br
-. ns
-. \" Do not quote the argument to `TP`; the user might specify
-. \" their own quotes for multi-word tags or to exercise AT&T troff
-. \" quoting rules.
-. TP \\$1\"
-..
-.
-.
.\" `EX` and `EE` are Ninth Edition Unix extensions that survived into
.\" Plan 9 troff but other AT&T troff descendants did not adopt.
.
.\" Start example.
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de EX
. br
. if !\\n(mE \{\
@@ -220,7 +222,7 @@
.
.
.\" End example.
-.if \n(.g-\n(mG \{\
+.if !\n(.g-\n(mG \{\
.de EE
. br
. if \\n(mE \{\
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 59e8fd5d3..5d42bf4a2 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -1538,9 +1538,9 @@ contains unsupported escape sequence
. ftr CBI BI
.\}
.
-.\" undocumented register; unset it to test an-ext.tmac extension macros
+.\" undocumented register used to test an-ext.tmac extension macros
.if !r mG \
-. nr mG 1
+. nr mG 0
.
.\" Load man macro extensions.
.mso an-ext.tmac
diff --git a/tmac/tests/an-ext_MR-works.sh b/tmac/tests/an-ext_MR-works.sh
index c75ce232a..dcce35340 100755
--- a/tmac/tests/an-ext_MR-works.sh
+++ b/tmac/tests/an-ext_MR-works.sh
@@ -45,7 +45,7 @@ foo @- a command with a very short name
The real work is done by
.MR bar 1 .'
-output=$(echo "$input" | "$groff" -rmG=0 -Tascii -man -Z | nl)
+output=$(echo "$input" | "$groff" -r mG=1 -T ascii -m an -Z | nl)
echo "$output"
# Expected:
@@ -64,4 +64,4 @@ echo "$output" | grep -Eq '92[[:space:]]+t\(1\)' || wail
test -z "$fail"
-# vim:set ai et sw=4 ts=4 tw=72:
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit