gbranden pushed a commit to branch master
in repository groff.

commit 049a1f2313a2b22b573c8e972a2363a5acb0c850
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Wed Jul 16 10:36:16 2025 -0500

    [mdoc]: Refactor hyphenation mode handling.
    
    * tmac/doc.tmac: Refactor.
    
      ([initialization]): Stop assigning `HY` register a default value if
      it's unspecified by the user (on the command line or via "man.local").
    
      (doc-reset-args): Stop resetting hyphenation mode here; replacing it
      with a call to `doc-reset-hyphenation-mode` causes infinite macro
      recursion.  (Will this bite us later?)
    
      (doc-print-reference): Call `doc-reset-hyphenation-mode` instead of
      manipulating automatic hyphenation mode directly.
    
    * tmac/mdoc/doc-common ([initialization]): Drop logic that sets up
      `doc-hyphen-flags` register, which we're retiring in favor of a new
      macro.
    
      (Dd, Nd): Call `doc-reset-hyphenation-mode`.  The lack of a
      hyphenation mode reset in the latter macro was apparently an
      oversight, caught by a forthcoming automated test.
    
      (doc-reset-hyphenation-mode): New macro works if the `HY` register is
      not defined.  Use new local register `doc-want-hyphenation` to
      determine which hyphenation mode ultimately gets set (that of the
      locale, or zero).  Remove register when done.
    
      (Sh): Call `doc-reset-hyphenation-mode` instead of manipulating
      automatic hyphenation mode directly.
---
 ChangeLog            | 27 +++++++++++++++++++++++++++
 tmac/doc.tmac        | 11 ++---------
 tmac/mdoc/doc-common | 33 +++++++++++++++++++++++----------
 3 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8f837bfc7..d0184bb5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2025-07-16  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [mdoc]: Refactor hyphenation mode handling.
+
+       * tmac/doc.tmac: Refactor.
+       ([initialization]): Stop assigning `HY` register a default value
+       if it's unspecified by the user (on the command line or via
+       "man.local").
+       (doc-reset-args): Stop resetting hyphenation mode here;
+       replacing it with a call to `doc-reset-hyphenation-mode` causes
+       infinite macro recursion.  (Will this bite us later?)
+       (doc-print-reference): Call `doc-reset-hyphenation-mode` instead
+       of manipulating automatic hyphenation mode directly.
+       * tmac/mdoc/doc-common ([initialization]): Drop logic that sets
+       up `doc-hyphen-flags` register, which we're retiring in favor of
+       a new macro.
+       (Dd, Nd): Call `doc-reset-hyphenation-mode`.  The lack of a
+       hyphenation mode reset in the latter macro was apparently an
+       oversight, caught by a forthcoming automated test.
+       (doc-reset-hyphenation-mode): New macro works if the `HY`
+       register is not defined.  Use new local register
+       `doc-want-hyphenation` to determine which hyphenation mode
+       ultimately gets set (that of the locale, or zero).  Remove
+       register when done.
+       (Sh): Call `doc-reset-hyphenation-mode` instead of manipulating
+       automatic hyphenation mode directly.
+
 2025-07-17  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [mdoc]: Disable hyphenation less aggressively.
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index 70cb79c74..2aa974511 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -213,12 +213,7 @@
 .rr doc-HF-length
 .rm doc-heading-style
 .
-.\" \n[HY] is recognized for groff_man(7) compatibility, particularly
-.\" via andoc.tmac and man(1); see \n[doc-hyphen-flags] in doc-common.
-.\"
-.\" hyphenation enablement
-.if !r HY \
-.  nr HY 1
+.\" `doc-reset-hyphenation-mode` handles the `HY` register.
 .
 .\" groff mdoc does _not_ use groff man's `IN` register.
 .
@@ -561,8 +556,6 @@
 .  nr doc-arg-count 0
 .  nr doc-arg-ptr 0
 .  nr doc-have-slot 0
-.
-.  hy \n[doc-hyphen-flags]
 ..
 .ec
 .
@@ -5881,7 +5874,7 @@ arguments
 .  if \n[doc-reference-count] \
 .    doc-warn unresolved reference problem
 .
-.  hy \n[doc-hyphen-flags]
+.  doc-reset-hyphenation-mode
 ..
 .ec
 .
diff --git a/tmac/mdoc/doc-common b/tmac/mdoc/doc-common
index 314083129..dea488c5a 100644
--- a/tmac/mdoc/doc-common
+++ b/tmac/mdoc/doc-common
@@ -309,6 +309,7 @@
 .  if \n[C] .rr P
 .
 .  doc-reset-titles
+.  doc-reset-hyphenation-mode
 .
 .  if !\n[.$] \
 .    doc-warn .Dd directive expects an argument
@@ -989,15 +990,6 @@
 .ec
 .
 .
-.\" NS doc-hyphen-flags global register
-.\" NS   the parameter for the '.hy' request
-.ie \n[HY] \{\
-.  ie \n[cR] .nr doc-hyphen-flags \n[\*[locale]*hyphenation-mode-base]
-.  el        .nr doc-hyphen-flags \n[\*[locale]*hyphenation-mode-trap]
-.\}
-.el .nr doc-hyphen-flags 0
-.
-.
 .\" NS doc-header macro
 .\" NS   print page header
 .\" NS
@@ -1135,6 +1127,26 @@
 .ec
 .
 .
+.\" NS doc-reset-hyphenation-mode
+.\" NS   Repair automatic hyphenation after man page meddling.
+.
+.eo
+.de doc-reset-hyphenation-mode
+.  nr doc-want-hyphenation 1
+.  if r HY .ie !\n[HY] .nr doc-want-hyphenation 0
+.  ie \n[doc-want-hyphenation] \{\
+.    ie \n[cR] \
+.      nr doc-hyphenation-mode \n[\*[locale]*hyphenation-mode-base]
+.    el \
+.      nr doc-hyphenation-mode \n[\*[locale]*hyphenation-mode-trap]
+.  \}
+.  el .nr doc-hyphenation-mode 0
+.  hy \n[doc-hyphenation-mode]
+.  rr doc-want-hyphenation
+..
+.ec
+.
+.
 .\" NS doc-end-macro macro
 .\" NS   finish output
 .\" NS
@@ -1254,6 +1266,7 @@
 .
 .eo
 .de Nd
+.  doc-reset-hyphenation-mode
 .  nop \[em] \$*
 ..
 .ec
@@ -1420,7 +1433,7 @@
 .    doc-parse-args \$@
 .
 .    ad \*[AD]
-.    hy \n[HY]
+.    doc-reset-hyphenation-mode
 .
 .    ie "\*[doc-sec-head]"\*[doc-section-name]" \{\
 .      doc-set-up-titles

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to