Update of bug #66392 (group groff):
Status: In Progress => Invalid
Open/Closed: Open => Closed
_______________________________________________________
Follow-up Comment #4:
Fair point, Dave.
I managed to muddle this issue by reporting it while I had changes pending
that I have now pushed.
Here's the problem.
$ cat EXPERIMENTS/buggy-hla.groff
.tm .hla=\n[.hla], .hy=\n[.hy]
.ev italian
.mso it.tmac
.tm .hla=\n[.hla], .hy=\n[.hy]
.ev
.tm .hla=\n[.hla], .hy=\n[.hy]
$ ~/groff-stable/bin/groff EXPERIMENTS/buggy-hla.groff
.hla=en, .hy=4
.hla=it, .hy=1
.hla=it, .hy=4
$ ./build/test-groff EXPERIMENTS/buggy-hla.groff
.hla=en, .hy=4
.hla=it, .hy=1
.hla=en, .hy=4
In other words, bug #66387.
*However*, our _me_ and _ms_ implementations both assume the erstwhile
behavior of the formatter. So lines hyphenate and break differently with the
fix to bug #66387 applied--not globally across the document, but in certain
environments.
Does this break backward compatibility?
With AT&T _troff_, no, or the question isn't even well-posed. That formatter
had no concept of a hyphenation language since the only hyphenation rules it
ever applies were those for English (and as you've noticed, some subtle
differences exist even between AT&T and GNU handling of hyphenation
exceptions, such that GNU _troff_ does not assume English's most common
pluralization rule).
With GNU _troff_, the answer is yes. I got pretty far along with a change to
_me_(7), but then decided a better approach would be to simply do stuff behind
the scenes inside the package and the localization files to essentially copy
environment 0's hyphenation language to environments 1 and 2. A bit of a
dance will have to be done since since a default hyphenation language can come
from 3 places: (a) the formatter; (b) a localization macro file that is loaded
*after* the full-service package itself (necessitating a degree of
re-initialization); and (c) from the document.
I aim to do something similar for _ms_.
Anywhere, here's the approach I abandoned with _me_.
mit bdfbc2f61fd758fcd68e1ae2c5aa435dcc4ea0d1
Author: G. Branden Robinson <[email protected]>
Date: Thu Oct 31 04:46:31 2024 -0500
[me]: Fix Savannah #66392.
* tmac/e.tmac: Improve handling of hyphenation in environments 1
(blocks, lists, keeps) and 2 (headers, footers, footnotes).
Historically, these used hyphenation mode 1, which is incorrect with
groff's hyphenation patterns for English and French (for example).
Wrap the `hy` request with a macro. New internal register `_h` stores
the hyphenation mode set by the new `hy` macro.
(xh): Renames `hy` formatter request.
(hy): If the formatter claims groff compatibility, store the
hyphenation language code in new string `_H` and copy it to the
traditional three environments. If given no argument, restore the
previous hyphenation mode given to this macro (or 0 if there was no
previous call). This is not how AT&T troff worked (it supported only
English anyway), but it's what most users expected (see Savannah
#63635).
(ld): Set the hyphenation mode to 6 only if the formatter does not
claim groff compatibility.
* doc/meref.me.in (Miscellaneous) <xh, hy>
(Summary):
* tmac/groff_me.7.man (Description, Macros): Document it.
* NEWS: Add item.
Fixes <https://savannah.gnu.org/bugs/?66392>. Between this change and
the fix for Savannah #66387, the "meintro_fr.me" document now hyphenates
words in its blocks, lists, and keeps as a French speaker would expect.
(...assuming a French *roff user who knows what automatic hyphenation
mode "14", set by the document, means--among other things, "don't
hyphenate a word prior to the third letter".)
diff --git a/ChangeLog b/ChangeLog
index e500abecd..3ffd5b815 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2024-11-01 G. Branden Robinson <[email protected]>
+
+ * tmac/e.tmac: Improve handling of hyphenation in environments 1
+ {blocks, lists, keeps} and 2 {headers, footers, footnotes}.
+ Historically, these used hyphenation mode 1, which is incorrect
+ with groff's hyphenation patterns for English and French (for
+ example). Wrap the `hy` request with a macro. New internal
+ register `_h` stores the hyphenation mode set by the new `hy`
+ macro.
+ (xh): Renames `hy` formatter request.
+ (hy): If the formatter claims groff compatibility, store the
+ hyphenation language code in new string `_H` and copy it to the
+ traditional three environments. If given no argument, restore
+ the previous hyphenation mode given to this macro (or 0 if there
+ was no previous call). This is not how AT&T troff worked (it
+ supported only English anyway), but it's what most users
+ expected (see Savannah #63635).
+ (ld): Set the hyphenation mode to 6 only if the formatter does
+ not claim groff compatibility.
+
+ * doc/meref.me.in (Miscellaneous) <xh, hy>
+ (Summary):
+ * tmac/groff_me.7.man (Description, Macros): Document it.
+
+ * NEWS: Add item.
+
+ Fixes <https://savannah.gnu.org/bugs/?66392>. Between this
+ change and the fix for Savannah #66387, the "meintro_fr.me"
+ document now hyphenates words in its blocks, lists, and keeps
+ as a French speaker would expect. (...assuming a French *roff
+ user who knows what automatic hyphenation mode "14", set by the
+ document, means--among other things, "don't hyphenate a word
+ prior to the third letter".)
+
2024-10-31 G. Branden Robinson <[email protected]>
[troff]: Couple the current hyphenation language more tightly
diff --git a/NEWS b/NEWS
index e578dc8a7..b47abaded 100644
--- a/NEWS
+++ b/NEWS
@@ -398,6 +398,16 @@ Macro packages
* The doc (mdoc) macro package now honors the `U` register and `MF`
string as the an (man) package does.
+* The e (me) macro package now supports a new macro `xh` that
+ configures the hyphenation mode in the current environment only; `hy`
+ now applies the hyphenation mode to all of the environments the
+ package uses by default (the three traditional ones of AT&T troff).
+ If called without an argument, `hy` restores the hyphenation mode
+ specified in the previous `hy` call. If there was none, the default
+ hyphenation mode is as configured by a groff localization file, or
+ "6" (groff me's traditional value) if the formatter does not claim
+ groff compatibility.
+
* The new macro file "koi8-r.tmac" supports the KOI8-R character
encoding, which supports the new Russian locale for groff.
diff --git a/doc/meref.me.in b/doc/meref.me.in
index 61d04c2e2..75bb11431 100644
--- a/doc/meref.me.in
+++ b/doc/meref.me.in
@@ -1700,6 +1700,35 @@ This hook can be used to insert chapter titles
into a table of contents.
.sh 1 "Miscellaneous"
.TL
+.b .xh
+.i n
+.DE
+Set automatic hyphenation mode to
+.i n
+only in the current environment.
+.TL
+.b .hy
+.i n
+.DE
+Set automatic hyphenation mode to
+.i n
+[6]\**
+.(f
+\**
+or as configured by a \*G localization macro file;
+see
+.i groff_tmac (5)
+.)f
+in all environments used by \*(ME.\**
+.(f
+\**
+\*(ME uses only the three environments of AT&T \*T,
+but in GNU \*T,
+the user can create additional ones.
+.)f
+Without an argument,
+restore previously selected hyphenation mode.
+.TL
.b .ld
.DE
Update the
@@ -2346,7 +2375,9 @@ and a square \(sq labels \*G extensions.
\&.hl M draw horizontal line
\en(hm R header margin
\&.hx M suppress next page's headers/footers
-\&.hy M\(sc set automatic hyphenation mode
+.ie \n($m=1 .ds EV env't\"
+.el .ds EV environment\"
+\&.hy M set hyphenation mode in \fIme\fP \*(EVs
\&.i M italicize argument
\&.ie M\(sc conditional with \fB.el\fP
\&.if M\(sc conditional
@@ -2441,6 +2472,8 @@ and a square \(sq labels \*G extensions.
\ew\(aq\fI\,S\/\fP\(aq F\(sc interpolate formatted width of \fIS\fP
\e*(wa S\(sq term for \(lqappendix\(rq used by \fB.$c\fP
\e*(wc S\(sq term for \(lqchapter\(rq used by \fB.$c\fP
+\&.xh M\(sq set hyphenation mode (current \*(EV)
+.rm EV
\&.xl M set line length (current environment)
\&.xp M output index
\en(xs R index entry prespace
diff --git a/tmac/e.tmac b/tmac/e.tmac
index c2b532ce6..fe82ee5ea 100644
--- a/tmac/e.tmac
+++ b/tmac/e.tmac
@@ -537,6 +537,35 @@ .de bp \" *** begin new page
(overrides columns)
.wh 0 @h \" reset header
..
.
+.nr _h 0\" \" previous hyphenation mode
+.rn hy xh \" *** special hyphenation mode (local)
+.de hy
+.if \n(.g .do ds _H \\n[.hla]\" \" hyphenation language code (groff)
+.ie '\\$1'' .nr __ \\n(_h
+.el \
+\{\
+. if \n(.g .if !\B'\\$1' \
+. do @err invalid nonnegative numeric argument to 'hy': \
+'\\$1'
+. nr _h \\$1
+. nr __ \\$1
+.\}
+.nr hy \\n(_h \" *** hypenation mode (evs 0-2)
+.ev 0
+.xh \\n(__
+.if \\n(.g .hla \\*(_H
+.ev
+.ev 1
+.xh \\n(__
+.if \\n(.g .hla \\*(_H
+.ev
+.ev 2
+.xh \\n(__
+.if \\n(.g .hla \\*(_H
+.ev
+.rr __
+..
+.
.rn ll xl \" *** special line length (local)
.de ll
.xl \\$1
@@ -2037,11 +2066,14 @@ .de ld \" *** (re-)initialize date
and localization
.do ds mo \\*[_mo\\n(mo]
.do ds td \\*[_td_format]
.
-.\" Set package default hyphenation mode, but override it with groff's
-.\" localized value if available.
-.hy 6
-.do if r \\*[locale]*hyphenation-mode-trap \
-. do hy \\n[\\*[locale]*hyphenation-mode-trap]
+.\" Set package default hyphenation mode, using groff's localized value
+.\" if available.
+.ie \n(.g \
+\{\
+. do if r \\*[locale]*hyphenation-mode-trap \
+. do hy \\n[\\*[locale]*hyphenation-mode-trap]
+.\}
+.el .hy 6
..
.
.ld
diff --git a/tmac/groff_me.7.man b/tmac/groff_me.7.man
index 9df93c274..0955ce2e4 100644
--- a/tmac/groff_me.7.man
+++ b/tmac/groff_me.7.man
@@ -153,7 +153,6 @@ .SH Description
fc c d set field delimiter \fIc\fP and padding glyph \fId
fi \& enable filling
hc c set hyphenation character to \fIc
-hy m set automatic hyphenation mode to \fIm
ie p t as \fBif\fP, but enable interpretation of later \fBel
if p t if condition \fIp\/\fP, interpret rest of line \fIt
in h set indentation to distance \fIh\fP
@@ -314,6 +313,7 @@ .SS Macros
he set header
hl draw horizontal line
hx suppress next page's headers/footers
+hy set automatic hyphenation mode
i italicize argument
ip begin indented paragraph
ld reset localization and date registers and strings\fB*
@@ -334,6 +334,7 @@ .SS Macros
tp begin title page
u underline argument
uh begin unnumbered section
+xh set automatic hyphenation mode (current environment only)\fB*
xl set line length (current environment only)
xp output index
.TE
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66392>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
