gbranden pushed a commit to branch master in repository groff. commit 22eb8770c5a087d204b31e88879a939d0d534c8e Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Tue Apr 30 12:17:36 2024 -0500
[troff]: Implement new `pline` request. [troff]: Add new request `pline` to dump list of nodes corresponding to most recently seen input line. * src/roff/troff/env.h (class environment): Declare new `dump_node_list` member function. * src/roff/troff/env.cpp (environment::dump_node_list): New function calls `debug_node_list()` if the most recent input line was productive of output. (print_node_list): New function dumps list of nodes pending in the environment and produced by the most recent input line. (init_env_requests): Wire up `pline` request to `print_node_list()`. * doc/groff.texi (Manipulating Filling and Adjustment, Debugging): * man/groff.7.man (Request short reference, Debugging): * man/groff_diff.7.man (New requests, Debugging): * NEWS: Document it. --- ChangeLog | 22 ++++++++++++++++++++++ NEWS | 5 +++++ doc/groff.texi.in | 24 +++++++++++++++++++----- man/groff.7.man | 15 +++++++++++++-- man/groff_diff.7.man | 15 +++++++++++++-- src/roff/troff/env.cpp | 12 ++++++++++++ src/roff/troff/env.h | 1 + 7 files changed, 85 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e26a7ce1..fb04e4c1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2024-04-30 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Add new request `pline` to dump list of nodes + corresponding to most recently seen input line. + + * src/roff/troff/env.h (class environment): Declare new + `dump_node_list` member function. + * src/roff/troff/env.cpp (environment::dump_node_list): New + function calls `debug_node_list()` if the most recent input line + was productive of output. + (print_node_list): New function dumps list of nodes + pending in the environment and produced by the most recent input + line. + (init_env_requests): Wire up `pline` request to + `print_node_list()`. + + * doc/groff.texi (Manipulating Filling and Adjustment) + (Debugging): + * man/groff.7.man (Request short reference, Debugging): + * man/groff_diff.7.man (New requests, Debugging): + * NEWS: Document it. + 2024-04-30 G. Branden Robinson <g.branden.robin...@gmail.com> * src/roff/troff/div.cpp (page_number): diff --git a/NEWS b/NEWS index cb9cedf22..11d5e7994 100644 --- a/NEWS +++ b/NEWS @@ -85,6 +85,11 @@ o A new request, `pcomposite`, reports to the standard error stream the o A new request, `phw`, reports to the standard error stream the current list of hyphenation exceptions. +o A new request, `pline`, reports to the standard error stream the list + of nodes (an internal data structure) corresponding to the most + recently seen input line. The list is empty if there was no previous + input line or if it was not productive. + o The `hla` request, when invoked with no arguments, now clears the hyphenation language, disabling automatic hyphenation. diff --git a/doc/groff.texi.in b/doc/groff.texi.in index 877b56894..1f6b17622 100644 --- a/doc/groff.texi.in +++ b/doc/groff.texi.in @@ -8353,10 +8353,13 @@ lines containing requests like @code{tl} or escape sequences like counted, but their interpolated contents can be. Empty requests, and requests and escape sequences that define registers or strings or alter the formatting environment (as with changes to the size, face, height, -slant, or color of the type) are not productive. We will also preview -the output line continuation escape sequence, @code{\c}, which -``connects'' two input lines that would otherwise be counted separately. -@footnote{@xref{Line Continuation}.} +slant, or color of the type) are not productive.@footnote{If you're not +sure whether an input line has been productive, you can use the +@code{pline} request to see whether it produced any formatting nodes. +@xref{Debugging}.} We will also preview the output line continuation +escape sequence, @code{\c}, which ``connects'' two input lines that +would otherwise be counted separately. @footnote{@xref{Line +Continuation}.} @Example @c .ll 56n @@ -17026,7 +17029,8 @@ exit codes respectively, to halt further processing when continuing would be fruitless. Examine the state of the formatter with requests that write lists of defined names (macros, strings, and diversions), colors, composite characters, environments, hyphenation exceptions, -registers, and page location traps to the standard error stream. +registers, page location traps, and a list of nodes corresponding to +the most recent input line to the standard error stream. @c END Keep parallel with section "Debugging" of groff(7). @Defreq {lf, line [@Var{file}]} @@ -17140,6 +17144,16 @@ hyphenation pattern file rather than with the @code{hw} request) are suffixed with a tab and asterisk (@code{*}). @endDefreq +@Defreq {pline, } +@cindex dumping node list of most recent input line (@code{pline}) +@cindex node list of most recent input line, dumping (@code{pline}) +@cindex most recent input line, dumping node list of (@code{pline}) +Report, to the standard error stream, the list of nodes corresponding to +the most recently seen input line. The list is empty if there was no +previous input line or if it was not productive; recall +@xref{Manipulating Filling and Adjustment}. +@endDefreq + @Defreq {pm, } @cindex dumping symbol table (@code{pm}) @cindex symbol table, dumping (@code{pm}) diff --git a/man/groff.7.man b/man/groff.7.man index c0b828222..3b0c336dd 100644 --- a/man/groff.7.man +++ b/man/groff.7.man @@ -3983,6 +3983,15 @@ Change page length to .scaleindicator v ). . .TPx +.REQ .pline +Report, +to the standard error stream, +the list of nodes corresponding to the most recently seen input line. +. +The list is empty if there was no previous input line or if it was not +productive. +. +.TPx .REQ .pm Report, to the standard error stream, @@ -8414,8 +8423,10 @@ hyphenation exceptions .RB ( .phw ); registers .RB ( .pnr ); -and page location traps -.RB ( .ptr ) +page location traps +.RB ( .ptr ); +and a list of nodes corresponding to the most recent input line +.RB ( .pline ) to the standard error stream. .\" END Keep (roughly) parallel with groff.texi node "Debugging". . diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man index 5b9159b5f..7f6ba35f5 100644 --- a/man/groff_diff.7.man +++ b/man/groff_diff.7.man @@ -3196,6 +3196,15 @@ request) are suffixed with a tab and asterisk .RB ( * ). . +.TP +.B .pline +Report, +to the standard error stream, +the list of nodes corresponding to the most recently seen input line. +. +The list is empty if there was no previous input line or if it was not +productive. +. . .TP .B .pnr @@ -5343,8 +5352,10 @@ hyphenation exceptions .RB ( phw ), registers .RB ( pnr ), -and page location traps -.RB ( ptr ) +page location traps +.RB ( ptr ), +and a list of nodes corresponding to the most recent input line +.RB ( .pline ) to the standard error stream. . . diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp index 166af81d6..e84510f36 100644 --- a/src/roff/troff/env.cpp +++ b/src/roff/troff/env.cpp @@ -2393,6 +2393,12 @@ void environment::dump_troff_state() #undef SPACES } +void environment::dump_node_list() +{ + if (line != 0 /* nullptr */) + line->debug_node_list(); +} + statem *environment::construct_state(bool has_only_eol) { if (is_html) { @@ -3559,6 +3565,11 @@ void print_env() skip_line(); } +static void print_nodes_from_input_line() +{ + curenv->dump_node_list(); +} + // Hyphenation - TeX's hyphenation algorithm with a less fancy implementation. struct trie_node; @@ -4151,6 +4162,7 @@ void init_env_requests() init_request("nm", number_lines); init_request("nn", no_number); init_request("pev", print_env); + init_request("pline", print_nodes_from_input_line); init_request("ps", point_size); init_request("pvs", post_vertical_spacing); init_request("rj", right_justify); diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h index c94b323b4..a8be68781 100644 --- a/src/roff/troff/env.h +++ b/src/roff/troff/env.h @@ -370,6 +370,7 @@ public: int /* fill */); void construct_new_line_state(node *n); void dump_troff_state(); + void dump_node_list(); friend void title_length(); friend void space_size(); _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit