On Tue Feb 4, 2025 at 10:13 PM CET, Dave Kemper wrote: > On Tue, Feb 4, 2025 at 1:54 PM onf <o...@disroot.org> wrote: > > In other words, hyphenation language setting is not local to the > > environment... which seems like a really unintuitive behavior, > > Being one of the disqualifieds from this challenge (having been in > prior discussion about it on savannah), I've had a few extra days to > ruminate, and I think I can make a case for the nonintuitive behavior. > > Historically, environments were intended to be used to store state of > page elements (e.g. titles and footnotes) that were separate from > running text. One might well want different word-breaking _rules_ in > these other elements, but less likely based on a different language. > Thus the hyphenation mode (the rules about if and when words can be > broken) is part of the environment, but the language to which those > rules are applied is global. > [...]
Historically, sure, but they are no longer used just for that. I learned troff on the minimal Mk macro package, which uses a separate environment for every page element, i.e. one for text, another for headings, another for subheading, etc. The only effect it really has is that it makes it easier to momentarily change the behavior of these elements by switching to their environment, though. A much more reasonable use I have found for them are arbitrarily nestable page elements (inspired by the experimental meta macro package); see the attached demo. I thus intuitivelly expected environments to save all formatting-related properties. ~ onf
demo.pdf
Description: Adobe PDF document
.\" groff -wall -Tpdf -P-pa5 FILE.tr > FILE.pdf .ig Copyright 2025 onf Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. This software is provided "AS IS" and any warranties, express or implied, are hereby DISCLAIMED. IN NO EVENT shall the copyright holder be liable for any damages arising IN ANY WAY out of the use of this software. .. .\" ===== MACROS ===== .de warn . backtrace . tm warning: \\$* .. . .nr nest:lvl 0 . .\" $1 = nest name .de nest:enter . if !(\\n[.$] == 1) .warn missing argument . nr nest:lvl +1 . ds \\n[nest:lvl]:name \\$1 . br . ds _prev \\n[.ev] . ev \\n[nest:lvl] . evc \\*[_prev] .. . .\" $1 = nest name .de nest:exit . if !(\\n[.$] == 1) .warn missing argument . if (\\n[nest:lvl] == 0) .warn stray closing tag . if !'\\$1'\\*[\\n[nest:lvl]:name]' .warn mismatched opening & closing tag . br . ev . rm \\n[nest:lvl]:name . nr nest:lvl -1 .. . .\" $1? = prefix, $2? = number format, $3? = suffix, $4? = indent .de <n . nest:enter n . nr \\n[nest:lvl]:nr 0 +1 . if !'\\$2'' .af \\n[nest:lvl]:nr \\$2 . if !'\\$1'' .ds \\n[nest:lvl]:pre "\\$1\" . ie !'\\$3'' .ds \\n[nest:lvl]:post "\\$3\" . el .ds \\n[nest:lvl]:post . . ie !'\\$4'' .in +\\$4 . el .in +1m . ad l . nh .. . .de /n> . if !(\\n[.$] == 0) .warn too many arguments . nest:exit n .. . .\" $1? = bullet, $2? = indent .de <u . nest:enter u . ie !'\\$1'' .ds \\n[nest:lvl]:bu "\\$1\" . el .ds \\n[nest:lvl]:bu \(bu . ie !'\\$2'' .in +\\$2 . el .in +1m .. . .de /u> . if !(\\n[.$] == 0) .warn too many arguments . nest:exit u .. . .de * . nr _L \\n[nest:lvl] . if !(\\n[.$] == 0) .warn too many arguments . ie '\\*[\\n[_L]:name]'n' .ds _txt \\n+[\\n[_L]:nr]\" . el \{.ie '\\*[\\n[_L]:name]'u' .ds _txt "\\*[\\n[_L]:bu]\" . el .warn list item macro used outside a list . \} . ds _txt "\\*[\\n[_L]:pre]\\*[_txt]\\*[\\n[_L]:post]\h'1n'\" . br . ti -\w'\\*[_txt]'u \\*[_txt]\c .. . .de <q . sp 0.5 . nest:enter q . if !'\\$1'' .ds \\n[nest:lvl]:author "\\$1\" . in 4n . ll -4n . ps -1 . vs -1 .. . .de /q> . br . if !'\\*[\\n[nest:lvl]:author]'' \{\ . ad r \[em]\ \fI\\*[\\n[nest:lvl]:author]\fP . br . \} . nest:exit q . sp 0.5 .. . .\" ===== BEGIN DEMO ===== .pl 21c-1.5c .po 1.5c .ll 14.8c-3c .ev header . evc 0 .ev .de header . ev header . sp |1.5c-1v . ev .. .wh 0 header . Aliquam eu diam rhoncus, fringilla libero at, aliquam lorem. Praesent vitae ultricies libero, vel ullamcorper ante. Sed eget convallis tortor. .<q Anonymous Pellentesque malesuada egestas orci, facilisis dignissim leo volutpat nec. Nam tincidunt, erat nec pulvinar bibendum, sapien lorem laoreet tortor, id venenatis purus quam sit amet enim. Vivamus sit amet dui a erat pharetra mattis. Ut eu dolor quis neque molestie accumsan: . sp 0.25 . <n "" A . 3m . * Lorem ipsum dolor sit amet, consectetur adipiscing elit. . <n . * Curabitur gravida sapien dolor, et tempus neque luctus ultrices. . * Curabitur ultrices lobortis feugiat. . <u . * Proin eget placerat purus. . * Aliquam erat voluptat. . /u> . * Ut ullamcorper ultricies lacus ut pellentesque. . * Quisque fringilla neque ac velit lobortis ornare. . <n "" a ) . * Ut fermentum eu sapien sed egestas. . * In vel pretium elit. . /n> . /n> . * Ut diam mauris, dignissim in lacus eu, mollis posuere mi. . /n> . sp 0.25 Aenean et metus at tellus volutpat euismod eu sit amet augue. Sed vitae mi id arcu convallis dapibus. Suspendisse hendrerit orci quis elit congue dapibus. Morbi dictum fermentum orci, a hendrerit magna aliquam vitae. Aenean at massa pharetra, sodales elit et, dictum ante. ./q>